cvs: php4 /main main.c /sapi/apache mod_php4.c /sapi/isapi php4isapi.c /sapi/pi3web pi3web_sapi.c /sapi/roxen roxen.c
| From: | Sascha Schumann | Date: | Sun, 20 Aug 2000 14:29:00 +0000 |
| Subject: | cvs: php4 /main main.c /sapi/apache mod_php4.c /sapi/isapi php4isapi.c /sapi/pi3web pi3web_sapi.c /sapi/roxen roxen.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1261@lists.php.net to get a copy of this message | ||
sas Sun Aug 20 07:29:00 2000 EDT
Modified files:
/php4/main main.c
/php4/sapi/apache mod_php4.c
/php4/sapi/isapi php4isapi.c
/php4/sapi/pi3web pi3web_sapi.c
/php4/sapi/roxen roxen.c
Log:
The status quo in PHP is that the current directory is initialized
to the directory where the executing script is located.
Since this needs to be implemented for all SAPI modules anyway, this
change moves the functionality to php_execute_script() and gets rid
of the per-module code.
Index: php4/main/main.c
diff -u php4/main/main.c:1.293 php4/main/main.c:1.294
--- php4/main/main.c:1.293 Tue Aug 15 10:05:37 2000
+++ php4/main/main.c Sun Aug 20 07:28:59 2000
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.293 2000/08/15 17:05:37 sas Exp $ */
+/* $Id: main.c,v 1.294 2000/08/20 14:28:59 sas Exp $ */
#include <stdio.h>
@@ -1109,6 +1109,7 @@
{
zend_file_handle *prepend_file_p, *append_file_p;
zend_file_handle prepend_file, append_file;
+ char old_cwd[4096] = "";
SLS_FETCH();
php_hash_environment(ELS_C SLS_CC PLS_CC);
@@ -1138,6 +1139,8 @@
if (setjmp(EG(bailout))!=0) {
+ if (old_cwd[0] != '\0')
+ V_CHDIR(old_cwd);
return;
}
@@ -1145,6 +1148,20 @@
UpdateIniFromRegistry(primary_file->filename);
#endif
+ if (primary_file->type == ZEND_HANDLE_FILENAME
+ && primary_file->filename) {
+ char *filename;
+
+ filename = strrchr(primary_file->filename, PHP_SEPARATOR);
+
+ if (filename) {
+ filename++;
+ V_GETCWD(old_cwd, sizeof(old_cwd)-1);
+ V_CHDIR_FILE(primary_file->filename);
+ primary_file->filename = filename;
+ }
+ }
+
if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) {
prepend_file.filename = PG(auto_prepend_file);
prepend_file.opened_path = NULL;
@@ -1164,6 +1181,9 @@
append_file_p = NULL;
}
zend_execute_scripts(ZEND_REQUIRE CLS_CC ELS_CC, 3, prepend_file_p, primary_file, append_file_p);
+
+ if (old_cwd[0] != '\0')
+ V_CHDIR(old_cwd);
}
PHPAPI int php_lint_script(zend_file_handle *file CLS_DC ELS_DC PLS_DC)
Index: php4/sapi/apache/mod_php4.c
diff -u php4/sapi/apache/mod_php4.c:1.64 php4/sapi/apache/mod_php4.c:1.65
--- php4/sapi/apache/mod_php4.c:1.64 Sun Aug 20 07:20:21 2000
+++ php4/sapi/apache/mod_php4.c Sun Aug 20 07:29:00 2000
@@ -17,7 +17,7 @@
| PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php4.c,v 1.64 2000/08/20 14:20:21 sas Exp $ */
+/* $Id: mod_php4.c,v 1.65 2000/08/20 14:29:00 sas Exp $ */
#define NO_REGEX_EXTRA_H
#ifdef WIN32
@@ -496,7 +496,6 @@
SG(server_context) = r;
php_save_umask();
- V_CHDIR_FILE(filename);
add_common_vars(r);
add_cgi_vars(r);
Index: php4/sapi/isapi/php4isapi.c
diff -u php4/sapi/isapi/php4isapi.c:1.53 php4/sapi/isapi/php4isapi.c:1.54
--- php4/sapi/isapi/php4isapi.c:1.53 Fri Aug 18 07:18:57 2000
+++ php4/sapi/isapi/php4isapi.c Sun Aug 20 07:29:00 2000
@@ -20,12 +20,10 @@
#ifdef PHP_WIN32
# include <windows.h>
# include <process.h>
-# define SEPARATOR '\\'
#else
# define __try
# define __except(val)
# define __declspec(foo)
-# define SEPARATOR '/'
#endif
#include <httpext.h>
@@ -481,15 +479,6 @@
SG(request_info).headers_only = 1;
} else {
SG(request_info).headers_only = 0;
- }
- {
- char *path_end = strrchr(SG(request_info).path_translated, SEPARATOR);
-
- if (path_end) {
- *path_end = 0;
- V_CHDIR(SG(request_info).path_translated);
- *path_end = SEPARATOR;
- }
}
if (!bFilterLoaded) { /* we don't have valid ISAPI Filter information */
SG(request_info).auth_user = SG(request_info).auth_password = NULL;
Index: php4/sapi/pi3web/pi3web_sapi.c
diff -u php4/sapi/pi3web/pi3web_sapi.c:1.6 php4/sapi/pi3web/pi3web_sapi.c:1.7
--- php4/sapi/pi3web/pi3web_sapi.c:1.6 Wed Aug 2 15:48:44 2000
+++ php4/sapi/pi3web/pi3web_sapi.c Sun Aug 20 07:29:00 2000
@@ -20,13 +20,10 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pi3web_sapi.c,v 1.6 2000/08/02 22:48:44 rasmus Exp $ */
+/* $Id: pi3web_sapi.c,v 1.7 2000/08/20 14:29:00 sas Exp $ */
#if WIN32|WINNT
# include <windows.h>
-# define PATH_DELIMITER '\\'
-#else
-# define PATH_DELIMITER '/'
#endif
#include "pi3web_sapi.h"
@@ -83,7 +80,7 @@
PUTS("<table border=5 width=600>\n");
PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR
"\">Pi3Web Server Information</th></tr>\n");
php_info_print_table_header(2, "Information Field", "Value");
- php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.6
2000/08/02 22:48:44 rasmus Exp $");
+ php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.7
2000/08/20 14:29:00 sas Exp $");
php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp());
snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled());
php_info_print_table_row(2, "Debug Enabled", variable_buf);
@@ -309,8 +306,8 @@
static void init_request_info(sapi_globals_struct *sapi_globals, LPCONTROL_BLOCK lpCB)
{
- char *path_end = strrchr(lpCB->lpszFileName, PATH_DELIMITER);
- if ( path_end ) *path_end = PATH_DELIMITER;
+ char *path_end = strrchr(lpCB->lpszFileName, PHP_SEPARATOR);
+ if ( path_end ) *path_end = PHP_SEPARATOR;
SG(server_context) = lpCB;
SG(request_info).request_method = lpCB->lpszMethod;
@@ -384,20 +381,12 @@
DWORD fnWrapperProc(LPCONTROL_BLOCK lpCB)
{
zend_file_handle file_handle;
- char *path_end;
SLS_FETCH();
CLS_FETCH();
ELS_FETCH();
PLS_FETCH();
if (setjmp( EG(bailout)) != 0 ) return PIAPI_ERROR;
-
- path_end = strrchr( lpCB->lpszFileName, PATH_DELIMITER );
- if ( path_end ) {
- *path_end = 0;
- chdir( lpCB->lpszFileName );
- *path_end = PATH_DELIMITER;
- };
file_handle.filename = lpCB->lpszFileName;
file_handle.free_filename = 0;
Index: php4/sapi/roxen/roxen.c
diff -u php4/sapi/roxen/roxen.c:1.35 php4/sapi/roxen/roxen.c:1.36
--- php4/sapi/roxen/roxen.c:1.35 Sun Aug 13 11:00:39 2000
+++ php4/sapi/roxen/roxen.c Sun Aug 20 07:29:00 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: roxen.c,v 1.35 2000/08/13 18:00:39 stas Exp $ */
+/* $Id: roxen.c,v 1.36 2000/08/20 14:29:00 sas Exp $ */
#include "php.h"
#ifdef HAVE_ROXEN
@@ -447,7 +447,7 @@
{
/* char buf[512]; */
php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.35 2000/08/13
18:00:39 stas Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.36 2000/08/20
14:29:00 sas Exp $");
/* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -591,19 +591,6 @@
#ifdef ROXEN_USE_ZTS
GET_THIS();
#endif
-#endif
-
-#ifdef VIRTUAL_DIR
- /* Change virtual directory, if the feature is enabled */
- dir = malloc(len = strlen(THIS->filename));
- strcpy(dir, THIS->filename);
- while(--len >= 0 && dir[len] != '/')
- ;
- if(len > 0) {
- dir[len] = '\0';
- }
- V_CHDIR(dir);
- free(dir);
#endif
file_handle.type = ZEND_HANDLE_FILENAME;