Commit 87dbb999 authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4650 (Some users may have error when temp file created)

parent a771e8bd
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -503,9 +503,9 @@ END;
                flock($myfile, LOCK_UN);
                fclose($myfile);
            } else { // Via FTP
                $path2 = tempnam((((str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1') || ((@strval(ini_get('open_basedir')) != '') && (preg_match('#(^|:|;)/tmp($|:|;|/)#', ini_get('open_basedir')) == 0))) ? get_custom_file_base() . '/safe_mode_temp/' : '/tmp/'), 'cmsce');
                $path2 = @tempnam((((str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1') || ((@strval(ini_get('open_basedir')) != '') && (preg_match('#(^|:|;)/tmp($|:|;|/)#', ini_get('open_basedir')) == 0))) ? get_custom_file_base() . '/safe_mode_temp/' : '/tmp/'), 'cmsce');
                if ($path2 === false) {
                    $path2 = tempnam(get_custom_file_base() . '/safe_mode_temp/', 'cmsce');
                    $path2 = @tempnam(get_custom_file_base() . '/safe_mode_temp/', 'cmsce');
                }

                $h = fopen($path2, 'wt');
@@ -695,9 +695,9 @@ function ce_cms_tempnam($prefix = '')
    $server_path = '/tmp/';
    $tmp_path = $problem_saving ? $local_path : $server_path;
    if ((function_exists('tempnam')) && (strpos(@ini_get('disable_functions'), 'tempnam') === false)) {
        $tempnam = tempnam($tmp_path, 'tmpfile__' . $prefix);
        $tempnam = @tempnam($tmp_path, 'tmpfile__' . $prefix);
        if (($tempnam === false) && (!$problem_saving)) {
            $tempnam = tempnam($local_path, $prefix);
            $tempnam = @tempnam($local_path, $prefix);
        }
    } else {
        $tempnam = $prefix . strval(mt_rand(0, mt_getrandmax()));
+3 −2
Original line number Diff line number Diff line
@@ -239,9 +239,10 @@ function _cms_tempnam($prefix = '')
    list($tmp_path, $problem_saving, $server_path, $local_path) = cms_get_temp_dir();
    if (php_function_allowed('tempnam')) {
        // Create a real temporary file
        $tempnam = tempnam($tmp_path, 'tmpfile__' . $prefix);
        //  We have to use "@" in case of "file created in the system's temporary directory" notice
        $tempnam = @tempnam($tmp_path, 'tmpfile__' . $prefix);
        if ((($tempnam === false) || ($tempnam == ''/*Should not be blank, but seen in the wild*/)) && (!$problem_saving)) {
            $tempnam = tempnam($local_path, 'tmpfile__' . $prefix); // Try saving in local path even if we didn't think there'd be a problem saving into the system path
            $tempnam = @tempnam($local_path, 'tmpfile__' . $prefix); // Try saving in local path even if we didn't think there'd be a problem saving into the system path
        }
    } else {
        // A fake temporary file, as true ones have been disabled on PHP