summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2001-07-21 15:11:30 +0000
committerAndi Gutmans <andi@php.net>2001-07-21 15:11:30 +0000
commit4715403906a6ce35bb16bea710fb90796b95ae8a (patch)
treed8a1b50f97cdfa6d0e1026d15305637728648cab /sapi
parent336004f4bc72fb5f1a4f8c992d90673960d74856 (diff)
downloadphp-git-4715403906a6ce35bb16bea710fb90796b95ae8a.tar.gz
- Fix __FILE__ in the main script in CGI/command line mode.
Diffstat (limited to 'sapi')
-rw-r--r--sapi/cgi/cgi_main.c11
-rw-r--r--sapi/servlet/servlet.c15
2 files changed, 12 insertions, 14 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index e72483375d..a10a62293e 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -368,6 +368,7 @@ int main(int argc, char *argv[])
int exit_status = SUCCESS;
int cgi = 0, c, i, len;
zend_file_handle file_handle;
+ int retval = FAILURE;
char *s;
/* temporary locals */
int behavior=PHP_MODE_STANDARD;
@@ -676,6 +677,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
file_handle.type = ZEND_HANDLE_FP;
file_handle.handle.fp = stdin;
file_handle.opened_path = NULL;
+ file_handle.free_filename = 0;
/* This actually destructs the elements of the list - ugly hack */
zend_llist_apply(&global_vars, (llist_apply_func_t) php_register_command_line_global_vars);
@@ -703,11 +705,10 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
}
}
if (cgi || SG(request_info).path_translated) {
- file_handle.handle.fp = php_fopen_primary_script();
- file_handle.filename = SG(request_info).path_translated;
+ retval = php_fopen_primary_script(&file_handle);
}
- if (cgi && !file_handle.handle.fp) {
+ if (cgi && (retval == FAILURE)) {
if(!argv0 || !(file_handle.handle.fp = VCWD_FOPEN(argv0, "rb"))) {
PUTS("No input file specified.\n");
php_request_shutdown((void *) 0);
@@ -715,7 +716,8 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
return FAILURE;
}
file_handle.filename = argv0;
- } else if (file_handle.handle.fp && file_handle.handle.fp!=stdin) {
+ file_handle.opened_path = expand_filepath(argv0, NULL);
+ } else if (retval == SUCCESS) {
/* #!php support */
c = fgetc(file_handle.handle.fp);
if (c == '#') {
@@ -728,7 +730,6 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
}
}
- file_handle.free_filename = 0;
switch (behavior) {
case PHP_MODE_STANDARD:
exit_status = php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c
index 385795e704..84d1493506 100644
--- a/sapi/servlet/servlet.c
+++ b/sapi/servlet/servlet.c
@@ -315,6 +315,7 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send
jstring authUser, jboolean display_source_mode)
{
zend_file_handle file_handle;
+ int retval;
#ifndef VIRTUAL_DIR
char cwd[MAXPATHLEN];
#endif
@@ -352,7 +353,7 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send
*/
SETSTRING( SG(request_info).path_translated, pathTranslated );
#ifdef VIRTUAL_DIR
- file_handle.handle.fp = php_fopen_primary_script();
+ retval = php_fopen_primary_script(&file_handle);
#else
/*
* The java runtime doesn't like the working directory to be
@@ -360,15 +361,11 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send
* in the hopes that Java doesn't notice.
*/
getcwd(cwd,MAXPATHLEN);
- file_handle.handle.fp = php_fopen_primary_script();
+ retval = php_fopen_primary_script(&file_handle);
chdir(cwd);
#endif
- file_handle.filename = SG(request_info).path_translated;
- file_handle.opened_path = NULL;
- file_handle.free_filename = 0;
- file_handle.type = ZEND_HANDLE_FP;
-
- if (!file_handle.handle.fp) {
+
+ if (retval == FAILURE) {
php_request_shutdown((void *) 0);
php_module_shutdown();
ThrowIOException(jenv,file_handle.filename);
@@ -385,7 +382,7 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send
if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) {
php_get_highlight_struct(&syntax_highlighter_ini);
- sapi_send_headers();
+ sapi_send_headers();
zend_highlight(&syntax_highlighter_ini);
}
} else {