General: Work items 17936 and 17840 - Fix for environments where there is no access to /tmp but to upload_tmp_dir
Provided an option to set the sys_get_temp_dir() call to use the upload_tmp_dir; though by default the standard temp directory will still be used
This commit is contained in:
parent
9a29129ec7
commit
4f070fc349
|
@ -35,6 +35,35 @@
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Shared_File
|
class PHPExcel_Shared_File
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Use Temp or File Upload Temp for temporary files
|
||||||
|
*
|
||||||
|
* @protected
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected static $_useUploadTempDirectory = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the flag indicating whether the File Upload Temp directory should be used for temporary files
|
||||||
|
*
|
||||||
|
* @param boolean $useUploadTempDir Use File Upload Temporary directory (true or false)
|
||||||
|
*/
|
||||||
|
public static function setUseUploadTempDirectory($useUploadTempDir = FALSE) {
|
||||||
|
self::$_useUploadTempDirectory = (boolean) $useUploadTempDir;
|
||||||
|
} // function setUseUploadTempDirectory()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the flag indicating whether the File Upload Temp directory should be used for temporary files
|
||||||
|
*
|
||||||
|
* @return boolean Use File Upload Temporary directory (true or false)
|
||||||
|
*/
|
||||||
|
public static function getUseUploadTempDirectory() {
|
||||||
|
return self::$_useUploadTempDirectory;
|
||||||
|
} // function getUseUploadTempDirectory()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify if a file exists
|
* Verify if a file exists
|
||||||
*
|
*
|
||||||
|
@ -105,9 +134,19 @@ class PHPExcel_Shared_File
|
||||||
*/
|
*/
|
||||||
public static function sys_get_temp_dir()
|
public static function sys_get_temp_dir()
|
||||||
{
|
{
|
||||||
|
if (self::$_useUploadTempDirectory) {
|
||||||
|
// use upload-directory when defined to allow running on environments having very restricted
|
||||||
|
// open_basedir configs
|
||||||
|
if (ini_get('upload_tmp_dir') !== FALSE) {
|
||||||
|
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
|
// sys_get_temp_dir is only available since PHP 5.2.1
|
||||||
// http://php.net/manual/en/function.sys-get-temp-dir.php#94119
|
// http://php.net/manual/en/function.sys-get-temp-dir.php#94119
|
||||||
|
|
||||||
if ( !function_exists('sys_get_temp_dir')) {
|
if ( !function_exists('sys_get_temp_dir')) {
|
||||||
if ($temp = getenv('TMP') ) {
|
if ($temp = getenv('TMP') ) {
|
||||||
if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); }
|
if ((!empty($temp)) && (file_exists($temp))) { return realpath($temp); }
|
||||||
|
|
|
@ -29,6 +29,8 @@ Fixed in develop branch:
|
||||||
- Bugfix: (MBaker) Work item 18794 - CSV files without a file extension being identified as HTML
|
- Bugfix: (MBaker) Work item 18794 - CSV files without a file extension being identified as HTML
|
||||||
- Bugfix: (AndreKR) Work item GH-66 - Wrong check for maximum number of rows in Excel5 Writer
|
- Bugfix: (AndreKR) Work item GH-66 - Wrong check for maximum number of rows in Excel5 Writer
|
||||||
- General: (kea) Work item GH-69 - Improved AdvancedValueBinder for currency
|
- General: (kea) Work item GH-69 - Improved AdvancedValueBinder for currency
|
||||||
|
- General: (MBaker) Work items 17936 and 17840 - Fix for environments where there is no access to /tmp but to upload_tmp_dir
|
||||||
|
Provided an option to set the sys_get_temp_dir() call to use the upload_tmp_dir; though by default the standard temp directory will still be used
|
||||||
- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows
|
- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows
|
||||||
- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges
|
- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges
|
||||||
- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't
|
- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't
|
||||||
|
|
Loading…
Reference in New Issue