From: Michael M Slusarz Date: Sun, 7 Mar 2010 07:25:49 +0000 (-0700) Subject: If 1st parameter to tempnam() is empty, it will use system tempdir default X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b31c060de708a23be3739d8fe57dae8ab6735bb3;p=horde.git If 1st parameter to tempnam() is empty, it will use system tempdir default --- diff --git a/framework/Text_Diff/Diff.php b/framework/Text_Diff/Diff.php index 2b65bcfc4..a5564ba68 100644 --- a/framework/Text_Diff/Diff.php +++ b/framework/Text_Diff/Diff.php @@ -210,43 +210,6 @@ class Text_Diff { } /** - * Determines the location of the system temporary directory. - * - * @static - * - * @access protected - * - * @return string A directory name which can be used for temp files. - * Returns false if one could not be found. - */ - function _getTempDir() - { - $tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp', - 'c:\windows\temp', 'c:\winnt\temp'); - - /* Try PHP's upload_tmp_dir directive. */ - $tmp = ini_get('upload_tmp_dir'); - - /* Otherwise, try to determine the TMPDIR environment variable. */ - if (!strlen($tmp)) { - $tmp = getenv('TMPDIR'); - } - - /* If we still cannot determine a value, then cycle through a list of - * preset possibilities. */ - while (!strlen($tmp) && count($tmp_locations)) { - $tmp_check = array_shift($tmp_locations); - if (@is_dir($tmp_check)) { - $tmp = $tmp_check; - } - } - - /* If it is still empty, we have failed, so return false; otherwise - * return the directory determined. */ - return strlen($tmp) ? $tmp : false; - } - - /** * Checks a diff for validity. * * This is here only for debugging purposes. diff --git a/framework/Text_Diff/Diff/Engine/shell.php b/framework/Text_Diff/Diff/Engine/shell.php index faf387032..5ddaf4d66 100644 --- a/framework/Text_Diff/Diff/Engine/shell.php +++ b/framework/Text_Diff/Diff/Engine/shell.php @@ -36,11 +36,9 @@ class Text_Diff_Engine_shell { array_walk($from_lines, array('Text_Diff', 'trimNewlines')); array_walk($to_lines, array('Text_Diff', 'trimNewlines')); - $temp_dir = Text_Diff::_getTempDir(); - // Execute gnu diff or similar to get a standard diff file. - $from_file = tempnam($temp_dir, 'Text_Diff'); - $to_file = tempnam($temp_dir, 'Text_Diff'); + $from_file = tempnam(null, 'Text_Diff'); + $to_file = tempnam(null, 'Text_Diff'); $fp = fopen($from_file, 'w'); fwrite($fp, implode("\n", $from_lines)); fclose($fp); diff --git a/framework/Util/lib/Horde/Util.php b/framework/Util/lib/Horde/Util.php index 350ed6ac9..e5e9c2b4b 100644 --- a/framework/Util/lib/Horde/Util.php +++ b/framework/Util/lib/Horde/Util.php @@ -401,13 +401,9 @@ class Horde_Util $secure = false) { $tempDir = (empty($dir) || !is_dir($dir)) - ? self::getTempDir() + ? null : $dir; - if (empty($tempDir)) { - return false; - } - $tempFile = tempnam($tempDir, $prefix); // If the file was created, then register it for deletion and return. @@ -418,6 +414,7 @@ class Horde_Util if ($delete) { self::deleteAtShutdown($tempFile, true, $secure); } + return $tempFile; }