Class phpexcel_shared_file{protected Static $_useuploadtempdirectory = false;public static function Sys_get_temp_dir () {if (self::$_useuploadtempdirectory) {//Use upload-directory when defined to allow running on en Vironments having very restricted//Open_basedir configs if (ini_get (' Upload_tmp_dir ')!== FAL SE) {if ($temp = Ini_get (' Upload_tmp_dir ')) {if (file_exists ($temp)) Return Realpath ($temp); }}}//Sys_get_temp_dir is only available since PHP 5.2.1//HTTP://PHP.NET/MANUAL/EN/FU nction.sys-get-temp-dir.php#94119 if (!function_exists (' Sys_get_temp_dir ')) {if ($temp = getenv (' TMP ') {if (!empty ($temp)) && (File_exists ($temp)) {return Realpath ($temp);} if ($temp = getenv (' temp ')) {if (!empty ($temp)) && (File_exists ($temp))){return Realpath ($temp);} if ($temp = getenv (' TMPDIR ')) {if ((!empty ($temp)) && (File_exists ($temp))) {return Realpath ($temp); }}//trick for creating a file in System ' s temporary dir//without knowing the path of The system ' s temporary dir $temp = Tempnam (__file__, '); if (file_exists ($temp)) {unlink ($temp); Return Realpath (DirName ($temp)); } return null; }//Use ordinary built-in PHP function//There should is no problem with the 5.2.4 Suhosin Realpath () b UG, because this line should only//is called if we ' re running 5.2.1 or earlier return Realpath (Sys_ Get_temp_dir ()); }}}
This is a piece of code that is picked out. Two questions
1:protected static $_useuploadtempdirectory = FALSE; Constant false, then if (self::$_useuploadtempdirectory) This judgment is not tenable, why still write this if statement?
2:if (!function_exists (' Sys_get_temp_dir ')) this if statement is in the Sys_get_temp_dir function, that is to say, this function always exists ah?? Then the following statement will not be executed.
I don't know, I understand, right? This is also a relatively mature CMS code. Why do you write this??
Reply content:
Class phpexcel_shared_file{protected Static $_useuploadtempdirectory = false;public static function Sys_get_temp_dir () {if (self::$_useuploadtempdirectory) {//Use upload-directory when defined to allow running on en Vironments having very restricted//Open_basedir configs if (ini_get (' Upload_tmp_dir ')!== FAL SE) {if ($temp = Ini_get (' Upload_tmp_dir ')) {if (file_exists ($temp)) Return Realpath ($temp); }}}//Sys_get_temp_dir is only available since PHP 5.2.1//HTTP://PHP.NET/MANUAL/EN/FU nction.sys-get-temp-dir.php#94119 if (!function_exists (' Sys_get_temp_dir ')) {if ($temp = getenv (' TMP ') {if (!empty ($temp)) && (File_exists ($temp)) {return Realpath ($temp);} if ($temp = getenv (' temp ')) {if (!empty ($temp)) && (File_exists ($temp))){return Realpath ($temp);} if ($temp = getenv (' TMPDIR ')) {if ((!empty ($temp)) && (File_exists ($temp))) {return Realpath ($temp); }}//trick for creating a file in System ' s temporary dir//without knowing the path of The system ' s temporary dir $temp = Tempnam (__file__, '); if (file_exists ($temp)) {unlink ($temp); Return Realpath (DirName ($temp)); } return null; }//Use ordinary built-in PHP function//There should is no problem with the 5.2.4 Suhosin Realpath () b UG, because this line should only//is called if we ' re running 5.2.1 or earlier return Realpath (Sys_ Get_temp_dir ()); }}}
This is a piece of code that is picked out. Two questions
1:protected static $_useuploadtempdirectory = FALSE; Constant false, then if (self::$_useuploadtempdirectory) This judgment is not tenable, why still write this if statement?
2:if (!function_exists (' Sys_get_temp_dir ')) this if statement is in the Sys_get_temp_dir function, that is to say, this function always exists ah?? Then the following statement will not be executed.
I don't know, I understand, right? This is also a relatively mature CMS code. Why do you write this??
1 static only, but can be modified
2 Sys_get_temp_dir refers to a function that comes with a PHP system, not a function in a class
Have you ever thought that its inheriting class might set $_useuploadtempdirectory to true?