mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
- This version of chdir_file should be compatible with the Apache one.
This commit is contained in:
parent
ce283e2326
commit
d8e64d623e
4 changed files with 22 additions and 1 deletions
|
@ -291,11 +291,13 @@ PHPAPI int cfg_get_string(char *varname, char **result);
|
|||
#define PHP_GETCWD(buff, size) virtual_getcwd(buff,size)
|
||||
#define PHP_FOPEN(path, mode) virtual_fopen(path, mode)
|
||||
#define PHP_CHDIR(path) virtual_chdir(path)
|
||||
#define PHP_CHDIR_FILE(path) virtual_chdir_file(path)
|
||||
#define PHP_GETWD(buf)
|
||||
#else
|
||||
#define PHP_GETCWD(buff, size) getcwd(buff,size)
|
||||
#define PHP_FOPEN(path, mode) fopen(path, mode)
|
||||
#define PHP_CHDIR(path) chdir(path)
|
||||
#define PHP_CHDIR_FILE(path) chdir_file(path)
|
||||
#define PHP_GETWD(buf) getwd(buf)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -286,6 +286,24 @@ int virtual_chdir(char *path)
|
|||
return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok);
|
||||
}
|
||||
|
||||
int virtual_chdir_file(char *path)
|
||||
{
|
||||
int length = strlen(path);
|
||||
|
||||
if (length == 0) {
|
||||
return 1; /* Can't CD to empty string */
|
||||
}
|
||||
while(--length >= 0 && !IS_SLASH(path[length])) {
|
||||
}
|
||||
|
||||
if (length == -1) {
|
||||
return virtual_chdir(path);
|
||||
}
|
||||
path[length] = DEFAULT_SLASH;
|
||||
return virtual_chdir(path);
|
||||
}
|
||||
|
||||
|
||||
int virtual_filepath(char *path, char **filepath)
|
||||
{
|
||||
cwd_state new_state;
|
||||
|
|
|
@ -25,6 +25,7 @@ void virtual_cwd_startup();
|
|||
char *virtual_getcwd_ex(int *length);
|
||||
char *virtual_getcwd(char *buf, size_t size);
|
||||
int virtual_chdir(char *path);
|
||||
int virtual_chdir_file(char *path);
|
||||
int virtual_filepath(char *path, char **filepath);
|
||||
FILE *virtual_fopen(char *path, const char *mode);
|
||||
|
||||
|
|
|
@ -483,7 +483,7 @@ int send_php(request_rec *r, int display_source_mode, char *filename)
|
|||
SG(server_context) = r;
|
||||
|
||||
php_save_umask();
|
||||
chdir_file(filename);
|
||||
PHP_CHDIR_FILE(filename);
|
||||
add_common_vars(r);
|
||||
add_cgi_vars(r);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue