#ifdef PHP_WIN32
extern int OS_SetImpersonate(void);
#else
-/* XXX this will need to change later when threaded fastcgi is
+/* XXX this will need to change later when threaded fastcgi is
implemented. shane */
struct sigaction act, old_term, old_quit, old_int;
#endif
}
/* Check wheater to send RFC2616 style headers compatible with
* PHP versions 4.2.3 and earlier compatible with web servers
- * such as IIS. Default is informal CGI RFC header compatible
+ * such as IIS. Default is informal CGI RFC header compatible
* with Apache.
*/
if (cfg_get_long("cgi.rfc2616_headers", &rfc2616_headers) == FAILURE) {
if (SG(sapi_headers).http_response_code != 200) {
int len;
-
+
if (rfc2616_headers) {
- len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH,
+ len = snprintf(buf, SAPI_CGI_MAX_HEADER_LENGTH,
"%s\r\n", SG(sapi_headers).http_status_line);
if (len > SAPI_CGI_MAX_HEADER_LENGTH) {
PHPWRITE_H("\r\n", 2);
efree(hd);
}
-
+
h = zend_llist_get_first_ex(&sapi_headers->headers, &pos);
while (h) {
PHPWRITE_H(h->header, h->header_len);
"cgi", /* name */
"CGI", /* pretty name */
#endif
-
+
php_cgi_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
char *env_path_translated;
SG(request_info).path_translated = NULL;
- /*
+ /*
* If for some reason the CGI interface is not setting the
* PATH_TRANSLATED correctly, SG(request_info).path_translated is NULL.
* We still call php_fopen_primary_script, because if you set doc_root
* the filename as a side effect of php_fopen_primary_script.
*
* Fixup path stuff to conform to CGI spec
- *
- * http://localhost/info.php/test?a=b
- *
+ *
+ * http://localhost/info.php/test?a=b
+ *
* should produce, which btw is the same as if
* we were running under mod_cgi on apache (ie. not
* using ScriptAlias directives):
- *
+ *
* PATH_INFO=/test
* PATH_TRANSLATED=/docroot/test
* SCRIPT_NAME=/info.php
* REQUEST_URI=/info.php/test?a=b
* SCRIPT_FILENAME=/docroot/info.php
* QUERY_STRING=a=b
- *
+ *
* cgi/mod_fastcgi under apache produce:
- *
+ *
* PATH_INFO=/info.php/test
* PATH_TRANSLATED=/docroot/info.php/test
* SCRIPT_NAME=/php/php-cgi (from the Action setting I suppose)
* REQUEST_URI=/info.php/test?a=b
* SCRIPT_FILENAME=/path/to/php/bin/php-cgi (Action setting translated)
* QUERY_STRING=a=b
- *
+ *
* Comments in the code below refer to using the above URL in a request
- *
- */
+ *
+ */
env_path_translated = sapi_cgibin_getenv("PATH_TRANSLATED",0 TSRMLS_CC);
__riscosify_control|=__RISCOSIFY_DONT_CHECK_DIR;
env_path_translated=__unixify(env_path_translated,0,NULL,1,0);
#endif
-
+
#if ENABLE_PATHINFO_CHECK
/*
* if the file doesn't exist, try to extract PATH_INFO out
* then we can modify PATH_INFO
* accordingly
*
- * we now have the makings of
+ * we now have the makings of
* PATH_INFO=/test
* SCRIPT_FILENAME=/docroot/info.php
*
*/
_sapi_cgibin_putenv("SCRIPT_NAME",pt+l TSRMLS_CC);
- /*
+ /*
* PATH_TRANSATED = DOCUMENT_ROOT + PATH_INFO
*/
path_translated_len = l + strlen(path_info) + 2;
efree(path_translated);
} else if (env_script_name &&
strstr(pt,env_script_name)) {
- /*
+ /*
* PATH_TRANSATED = PATH_TRANSATED - SCRIPT_NAME + PATH_INFO
*/
int ptlen = strlen(pt)-strlen(env_script_name);
/* this is old logic, and completely incorrect by CGI spec
* this is used to generate PHP_SELF, which should actually
* match SCRIPT_NAME. This is being left so PHP will be as broken
- * as it was before if a server does not set SCRIPT_NAME.
+ * as it was before if a server does not set SCRIPT_NAME.
*/
SG(request_info).request_uri = sapi_cgibin_getenv("PATH_INFO",0 TSRMLS_CC);
}
/* server didn't set script_filename, default to path_translated */
SG(request_info).path_translated = sapi_cgibin_getenv("PATH_TRANSLATED",0 TSRMLS_CC);
}
- if (SG(request_info).path_translated)
+ if (SG(request_info).path_translated)
SG(request_info).path_translated = estrdup(SG(request_info).path_translated);
SG(request_info).content_type = (content_type ? content_type : "" );
SG(request_info).content_length = (content_length?atoi(content_length):0);
SG(sapi_headers).http_response_code = 200;
-
+
/* The CGI RFC allows servers to pass on unvalidated Authorization data */
auth = sapi_cgibin_getenv("HTTP_AUTHORIZATION",0 TSRMLS_CC);
php_handle_auth_data(auth TSRMLS_CC);
* http://www.koehntopp.de/php.
* -- kk@netuse.de
*/
- if (!getenv("REDIRECT_STATUS")
+ if (!getenv("REDIRECT_STATUS")
&& !getenv ("HTTP_REDIRECT_STATUS")
/* this is to allow a different env var to be configured
in case some server does something different than above */
#if PHP_FASTCGI
&& !fastcgi
#endif
- ) { /* never execute the arguments if you are a CGI */
+ ) { /* never execute the arguments if you are a CGI */
if (SG(request_info).argv0) {
free(SG(request_info).argv0);
SG(request_info).argv0 = NULL;
}
if (cgi_sapi_module.php_ini_path_override && cgi_sapi_module.php_ini_ignore) {
- no_headers = 1;
+ no_headers = 1;
php_output_startup();
php_output_activate(TSRMLS_C);
SG(headers_sent) = 1;
php_end_ob_buffers(1 TSRMLS_CC);
exit(1);
}
-
+
while ((c = ap_php_getopt(argc, argv, OPTSTRING)) != -1) {
switch (c) {
-
+
case 'a': /* interactive mode */
printf("Interactive mode enabled\n\n");
interactive=1;
break;
-
+
case 'C': /* don't chdir to the script directory */
SG(options) |= SAPI_OPTION_NO_CHDIR;
break;
case 'd': /* define ini entries on command line */
define_command_line_ini_entry(ap_php_optarg);
break;
-
+
case 'e': /* enable extended info output */
CG(extended_info) = 1;
break;
case 'h': /* help & quit */
case '?':
- no_headers = 1;
+ no_headers = 1;
php_output_startup();
php_output_activate(TSRMLS_C);
SG(headers_sent) = 1;
break;
#if 0 /* not yet operational, see also below ... */
- case '': /* generate indented source mode*/
+ case '': /* generate indented source mode*/
behavior=PHP_MODE_INDENT;
break;
#endif
exit(1);
break;
- case 'w':
+ case 'w':
behavior=PHP_MODE_STRIP;
break;
/* 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 TSRMLS_CC);
zend_llist_destroy(&global_vars);
-
+
if (cgi || SG(request_info).path_translated) {
retval = php_fopen_primary_script(&file_handle TSRMLS_CC);
}
}
file_handle.filename = argv0;
file_handle.opened_path = expand_filepath(argv0, NULL TSRMLS_CC);
- }
+ }
if (file_handle.handle.fp && (file_handle.handle.fp != stdin)) {
/* #!php support */
{
char *path_translated;
-
+
/* Go through this trouble so that the memory manager doesn't warn
* about SG(request_info).path_translated leaking
*/
STR_FREE(SG(request_info).path_translated);
SG(request_info).path_translated = path_translated;
}
-
+
php_request_shutdown((void *) 0);
if (SG(request_info).path_translated) {
} zend_end_try();
php_module_shutdown(TSRMLS_C);
+ sapi_shutdown();
#ifdef ZTS
tsrm_shutdown();