php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #55491
Patch tmp_dir.patch revision 2011-08-23 14:18 UTC by royanee at yahoo dot com

Patch tmp_dir.patch for PHP options/info functions Bug #55491

Patch version 2011-08-23 14:18 UTC

Return to Bug #55491 | Download this patch
Patch Revisions:

Developer: royanee@yahoo.com

Index: php.ini-production
===================================================================
--- php.ini-production	(revision 315365)
+++ php.ini-production	(working copy)
@@ -861,6 +861,10 @@
 ; http://php.net/cgi.rfc2616-headers
 ;cgi.rfc2616_headers = 0
 
+; Default temporary directory (will use system default if not specified).
+; http://php.net/tmp-dir
+;tmp_dir =
+
 ;;;;;;;;;;;;;;;;
 ; File Uploads ;
 ;;;;;;;;;;;;;;;;
Index: main/php_globals.h
===================================================================
--- main/php_globals.h	(revision 315365)
+++ main/php_globals.h	(working copy)
@@ -95,6 +95,7 @@
 	char *include_path;
 	char *open_basedir;
 	char *extension_dir;
+	char *tmp_dir;
 
 	char *upload_tmp_dir;
 	long upload_max_filesize;
Index: main/php_open_temporary_file.c
===================================================================
--- main/php_open_temporary_file.c	(revision 315365)
+++ main/php_open_temporary_file.c	(working copy)
@@ -196,6 +196,19 @@
 		return temporary_directory;
 	}
 
+	char* t = PG(tmp_dir);
+	if (t && *t) {
+		int lent = strlen(t);
+
+		if (t[lent - 1] == DEFAULT_SLASH) {
+			temporary_directory = zend_strndup(t, lent - 1);
+		} else {
+			temporary_directory = zend_strndup(t, lent);
+		}
+
+		return temporary_directory;
+	}
+
 #ifdef PHP_WIN32
 	/* We can't count on the environment variables TEMP or TMP,
 	 * and so must make the Win32 API call to get the default
Index: main/main.c
===================================================================
--- main/main.c	(revision 315365)
+++ main/main.c	(working copy)
@@ -495,6 +495,7 @@
 	PHP_INI_ENTRY("max_execution_time",			"30",		PHP_INI_ALL,			OnUpdateTimeout)
 	STD_PHP_INI_ENTRY("open_basedir",			NULL,		PHP_INI_ALL,		OnUpdateBaseDir,			open_basedir,			php_core_globals,	core_globals)
 	STD_PHP_INI_ENTRY("safe_mode_exec_dir",		PHP_SAFE_MODE_EXEC_DIR,	PHP_INI_SYSTEM,		OnUpdateString,			safe_mode_exec_dir,		php_core_globals,	core_globals)
+	STD_PHP_INI_ENTRY("tmp_dir",				NULL,		PHP_INI_SYSTEM,		OnUpdateStringUnempty,	tmp_dir,			php_core_globals,	core_globals)
 
 	STD_PHP_INI_BOOLEAN("file_uploads",			"1",		PHP_INI_SYSTEM,		OnUpdateBool,			file_uploads,			php_core_globals,	core_globals)
 	STD_PHP_INI_ENTRY("upload_max_filesize",	"2M",		PHP_INI_SYSTEM|PHP_INI_PERDIR,		OnUpdateLong,			upload_max_filesize,	php_core_globals,	core_globals)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 28 06:01:28 2024 UTC