summaryrefslogtreecommitdiff
path: root/sapi/apache_hooks
diff options
context:
space:
mode:
authorJani Taskinen <jani@php.net>2010-03-11 10:24:29 +0000
committerJani Taskinen <jani@php.net>2010-03-11 10:24:29 +0000
commit06f072cb5e4e3582e20b8762141eccbc4dce85fa (patch)
tree511382440db96edad3a2627ce361113e29d672ab /sapi/apache_hooks
parentf60946eb5430cd11daa9f88503dc9b1a9b7bd634 (diff)
downloadphp-git-06f072cb5e4e3582e20b8762141eccbc4dce85fa.tar.gz
MFH: Improved / fixed output buffering (Michael Wallner)
Diffstat (limited to 'sapi/apache_hooks')
-rw-r--r--sapi/apache_hooks/mod_php5.c218
-rw-r--r--sapi/apache_hooks/php_apache.c495
-rw-r--r--sapi/apache_hooks/sapi_apache.c97
3 files changed, 384 insertions, 426 deletions
diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php5.c
index 7b6d18de9a..1d8bed4671 100644
--- a/sapi/apache_hooks/mod_php5.c
+++ b/sapi/apache_hooks/mod_php5.c
@@ -53,10 +53,9 @@ static void php_child_exit_handler(server_rec *s, pool *p);
#define CONST_PREFIX
#endif
-
typedef struct _sapi_stack {
- int top, max, persistent;
- void **elements;
+ int top, max, persistent;
+ void **elements;
} sapi_stack;
typedef struct _php_per_dir_config {
@@ -76,7 +75,6 @@ typedef struct _php_per_server_config {
sapi_stack requires;
} php_per_server_config;
-
static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2);
static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2);
@@ -108,67 +106,67 @@ typedef struct _php_per_dir_entry {
*/
/* This code is ripped part and parcel from zend_stack.[ch]. Assuming that the
- patch supporting zend_stack_init_ex is applied, all but the bottom two
+ patch supporting zend_stack_init_ex is applied, all but the bottom two
module-specific iterators will be removed
*/
int sapi_stack_init_ex(sapi_stack *stack, int persistent)
{
- stack->top = 0;
- stack->persistent = persistent;
- stack->elements = (void **) pemalloc(sizeof(void **) * STACK_BLOCK_SIZE, persistent);
- if (!stack->elements) {
- return FAILURE;
- } else {
- stack->max = STACK_BLOCK_SIZE;
- return SUCCESS;
- }
+ stack->top = 0;
+ stack->persistent = persistent;
+ stack->elements = (void **) pemalloc(sizeof(void **) * STACK_BLOCK_SIZE, persistent);
+ if (!stack->elements) {
+ return FAILURE;
+ } else {
+ stack->max = STACK_BLOCK_SIZE;
+ return SUCCESS;
+ }
}
+
int sapi_stack_push(sapi_stack *stack, void *element)
{
- if (stack->top >= stack->max) { /* we need to allocate more memory */
- stack->elements = (void **) perealloc(stack->elements,
- (sizeof(void **) * (stack->max += STACK_BLOCK_SIZE)), stack->persistent);
- if (!stack->elements) {
- return FAILURE;
- }
+ if (stack->top >= stack->max) { /* we need to allocate more memory */
+ stack->elements = (void **) perealloc(stack->elements, (sizeof(void **) * (stack->max += STACK_BLOCK_SIZE)), stack->persistent);
+ if (!stack->elements) {
+ return FAILURE;
}
- stack->elements[stack->top] = (void *) element;
- return stack->top++;
+ }
+ stack->elements[stack->top] = (void *) element;
+ return stack->top++;
}
-void* sapi_stack_pop(sapi_stack *stack) {
- if(stack->top == 0) {
+
+void* sapi_stack_pop(sapi_stack *stack)
+{
+ if (stack->top == 0) {
return NULL;
- }
- else {
+ } else {
return stack->elements[--stack->top];
}
}
int sapi_stack_destroy(sapi_stack *stack)
{
- return SUCCESS;
+ return SUCCESS;
}
int sapi_stack_apply_with_argument_all(sapi_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg)
{
- int i, retval;
-
- switch (type) {
- case ZEND_STACK_APPLY_TOPDOWN:
- for (i=stack->top-1; i>=0; i--) {
- retval = apply_function(stack->elements[i], arg);
- }
- break;
- case ZEND_STACK_APPLY_BOTTOMUP:
- for (i=0; i<stack->top; i++) {
- retval = apply_function(stack->elements[i], arg);
- }
- break;
- }
- return retval;
-}
+ int i, retval;
+ switch (type) {
+ case ZEND_STACK_APPLY_TOPDOWN:
+ for (i=stack->top-1; i>=0; i--) {
+ retval = apply_function(stack->elements[i], arg);
+ }
+ break;
+ case ZEND_STACK_APPLY_BOTTOMUP:
+ for (i=0; i<stack->top; i++) {
+ retval = apply_function(stack->elements[i], arg);
+ }
+ break;
+ }
+ return retval;
+}
int sapi_stack_apply_with_argument_stop_if_equals(sapi_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg, int stopval)
{
@@ -224,7 +222,7 @@ void php_handler_stack_destroy(sapi_stack *stack)
free(ph);
}
}
-/* }}} */
+/* }}} */
/* {{{ php_save_umask
*/
@@ -240,7 +238,7 @@ static void php_save_umask(void)
static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC)
{
int ret=0;
-
+
if (SG(server_context)) {
ret = rwrite(str, str_length, (request_rec *) SG(server_context));
}
@@ -282,7 +280,7 @@ static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
if (!SG(read_post_bytes) && !ap_should_client_block(r)) {
return total_read_bytes;
}
-
+
handler = signal(SIGPIPE, SIG_IGN);
while (total_read_bytes<count_bytes) {
hard_timeout("Read POST information", r); /* start timeout timer */
@@ -293,7 +291,7 @@ static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
}
total_read_bytes += read_bytes;
}
- signal(SIGPIPE, handler);
+ signal(SIGPIPE, handler);
return total_read_bytes;
}
/* }}} */
@@ -312,7 +310,8 @@ static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_head
{
char *header_name, *header_content, *p;
request_rec *r = (request_rec *) SG(server_context);
- if(!r) {
+
+ if (!r) {
return 0;
}
@@ -363,15 +362,15 @@ static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_head
*/
static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
{
- if(SG(server_context) == NULL) { /* server_context is not here anymore */
+ if (SG(server_context) == NULL) { /* server_context is not here anymore */
return SAPI_HEADER_SEND_FAILED;
}
((request_rec *) SG(server_context))->status = SG(sapi_headers).http_response_code;
/* check that we haven't sent headers already, we use our own
- * headers_sent since we may send headers at anytime
+ * headers_sent since we may send headers at anytime
*/
- if(!AP(headers_sent)) {
+ if (!AP(headers_sent)) {
send_http_header((request_rec *) SG(server_context));
AP(headers_sent) = 1;
}
@@ -455,15 +454,16 @@ static void php_apache_log_message(char *message)
static void php_apache_request_shutdown(void *dummy)
{
TSRMLS_FETCH();
+
AP(current_hook) = AP_CLEANUP;
- php_output_set_status(0 TSRMLS_CC);
+ php_output_set_status(PHP_OUTPUT_DISABLED TSRMLS_CC);
SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */
- if(SG(sapi_started)) {
+ if (SG(sapi_started)) {
php_request_shutdown(dummy);
SG(sapi_started) = 0;
}
AP(in_request) = 0;
- if(AP(setup_env)) {
+ if (AP(setup_env)) {
AP(setup_env) = 0;
}
AP(current_hook) = AP_WAITING_FOR_REQUEST;
@@ -475,7 +475,7 @@ static void php_apache_request_shutdown(void *dummy)
*/
static int php_apache_sapi_activate(TSRMLS_D)
{
- request_rec *r = (request_rec *) SG(server_context);
+ request_rec *r = (request_rec *) SG(server_context);
/*
* For the Apache module version, this bit of code registers a cleanup
@@ -483,7 +483,7 @@ static int php_apache_sapi_activate(TSRMLS_D)
* We need this because at any point in our code we can be interrupted
* and that may happen before we have had time to free our memory.
* The php_request_shutdown function needs to free all outstanding allocated
- * memory.
+ * memory.
*/
block_alarms();
register_cleanup(r->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec);
@@ -519,7 +519,7 @@ static char *php_apache_getenv(char *name, size_t name_len TSRMLS_DC)
static sapi_module_struct apache_sapi_module = {
"apache", /* name */
"Apache", /* pretty name */
-
+
php_apache_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
@@ -560,7 +560,6 @@ static sapi_module_struct apache_sapi_module = {
NULL, /* exe location */
0, /* ini ignore */
NULL
-
};
/* }}} */
@@ -598,20 +597,20 @@ static void init_request_info(TSRMLS_D)
SG(request_info).auth_password = NULL;
if (authorization && !auth_type(r)) {
- if (!strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
- tmp = uudecode(r->pool, authorization);
- tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
- if (tmp_user) {
- r->connection->user = pstrdup(r->connection->pool, tmp_user);
- r->connection->ap_auth_type = "Basic";
- SG(request_info).auth_user = estrdup(tmp_user);
- }
- if (tmp) {
- SG(request_info).auth_password = estrdup(tmp);
- }
- } else if (!strcasecmp(getword(r->pool, &authorization, ' '), "Digest")) {
- r->connection->ap_auth_type = "Digest";
- SG(request_info).auth_digest = estrdup(authorization);
+ if (!strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
+ tmp = uudecode(r->pool, authorization);
+ tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
+ if (tmp_user) {
+ r->connection->user = pstrdup(r->connection->pool, tmp_user);
+ r->connection->ap_auth_type = "Basic";
+ SG(request_info).auth_user = estrdup(tmp_user);
+ }
+ if (tmp) {
+ SG(request_info).auth_password = estrdup(tmp);
+ }
+ } else if (!strcasecmp(getword(r->pool, &authorization, ' '), "Digest")) {
+ r->connection->ap_auth_type = "Digest";
+ SG(request_info).auth_digest = estrdup(authorization);
}
}
}
@@ -630,8 +629,8 @@ static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_
*/
static char *php_apache_get_default_mimetype(request_rec *r TSRMLS_DC)
{
-
char *mimetype;
+
if (SG(default_mimetype) || SG(default_charset)) {
/* Assume output will be of the default MIME type. Individual
scripts may change this later. */
@@ -653,6 +652,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
int retval;
php_per_dir_config *per_dir_conf;
TSRMLS_FETCH();
+
if (AP(in_request)) {
zend_file_handle fh;
@@ -724,16 +724,16 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
hard_timeout("send", r);
SG(server_context) = r;
-
+
php_save_umask();
- if(!AP(setup_env)) {
+ if (!AP(setup_env)) {
AP(setup_env) = 1;
add_common_vars(r);
add_cgi_vars(r);
}
init_request_info(TSRMLS_C);
apache_php_module_main(r, display_source_mode TSRMLS_CC);
-
+
/* Done, restore umask, turn off timeout, close file and return */
php_restore_umask();
kill_timeout(r);
@@ -749,9 +749,8 @@ static int send_parsed_php(request_rec * r)
{
int result = send_php(r, 0, NULL);
TSRMLS_FETCH();
-
- ap_table_setn(r->notes, "mod_php_memory_usage",
- ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC)));
+
+ ap_table_setn(r->notes, "mod_php_memory_usage", ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC)));
return result;
}
@@ -765,7 +764,6 @@ static int send_parsed_php_source(request_rec * r)
}
/* }}} */
-
/* {{{ destroy_per_dir_entry
*/
static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry)
@@ -821,7 +819,7 @@ static void php_destroy_per_server_info(php_per_server_config *conf)
/* {{{ php_destroy_per_dir_info
*/
-static void php_destroy_per_dir_info(php_per_dir_config *conf)
+static void php_destroy_per_dir_info(php_per_dir_config *conf)
{
zend_hash_destroy(conf->ini_settings);
php_handler_stack_destroy(&conf->response_handlers);
@@ -843,20 +841,19 @@ static void *php_create_server(pool *p, char *dummy)
php_per_server_config *conf;
conf = (php_per_server_config *) malloc(sizeof(php_per_server_config));
register_cleanup(p, (void *) conf, (void (*)(void *)) php_destroy_per_server_info, (void (*)(void *)) php_destroy_per_server_info);
-
+
sapi_stack_init_ex(&conf->requires, 1);
sapi_stack_init_ex(&conf->uri_handlers, 1);
return conf;
}
-
/* }}} */
-
/* {{{ php_create_dir
*/
static void *php_create_dir(pool *p, char *dummy)
{
php_per_dir_config *conf;
+
conf = (php_per_dir_config *) malloc(sizeof(php_per_dir_config));
conf->ini_settings = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(conf->ini_settings, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1, 0);
@@ -869,10 +866,9 @@ static void *php_create_dir(pool *p, char *dummy)
sapi_stack_init_ex(&conf->logger_handlers, 1);
sapi_stack_init_ex(&conf->post_read_handlers, 1);
register_cleanup(p, (void *) conf, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) php_destroy_per_dir_info);
-
+
return conf;
}
-
/* }}} */
/* {{{ php_merge_dir
@@ -991,7 +987,7 @@ static CONST_PREFIX char *php_set_dir_handler(php_per_dir_config *conf, char *ar
return NULL;
}
-/* {{{ php_set_uri_handler
+/* {{{ php_set_uri_handler
*/
static CONST_PREFIX char *php_set_uri_handler(cmd_parms *cmd, void *dummy, char *arg1)
{
@@ -1018,7 +1014,7 @@ static CONST_PREFIX char *php_set_header_handler_code(cmd_parms *cmd, php_per_di
}
/* }}} */
-/* {{{ php_set_auth_handler
+/* {{{ php_set_auth_handler
*/
static CONST_PREFIX char *php_set_auth_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
{
@@ -1028,7 +1024,6 @@ static CONST_PREFIX char *php_set_auth_handler_code(cmd_parms *cmd, php_per_dir_
{
return php_set_dir_handler(conf, arg1, AP_AUTHENTICATION, AP_HANDLER_TYPE_METHOD);
}
-
/* }}} */
/* {{{ php_set_access_handler
@@ -1041,7 +1036,6 @@ static CONST_PREFIX char *php_set_access_handler_code(cmd_parms *cmd, php_per_di
{
return php_set_dir_handler(conf, arg1, AP_ACCESS_CONTROL, AP_HANDLER_TYPE_METHOD);
}
-
/* }}} */
/* {{{ php_set_type_handler
@@ -1054,7 +1048,6 @@ static CONST_PREFIX char *php_set_type_handler_code(cmd_parms *cmd, php_per_dir_
{
return php_set_dir_handler(conf, arg1, AP_TYPE_CHECKING, AP_HANDLER_TYPE_METHOD);
}
-
/* }}} */
/* {{{ php_set_fixup_handler
@@ -1079,8 +1072,7 @@ static CONST_PREFIX char *php_set_logger_handler_code(cmd_parms *cmd, php_per_di
{
return php_set_dir_handler(conf, arg1, AP_LOGGING, AP_HANDLER_TYPE_METHOD);
}
-
-/* }}} */
+/* }}} */
/* {{{ php_set_post_read_handler
*/
@@ -1092,13 +1084,10 @@ static CONST_PREFIX char *php_set_post_read_handler_code(cmd_parms *cmd, php_per
{
return php_set_dir_handler(conf, arg1, AP_POST_READ, AP_HANDLER_TYPE_METHOD);
}
-
-
/* }}} */
/* {{{ php_set_require
*/
-
static CONST_PREFIX char *php_set_require(cmd_parms *cmd, void *dummy, char *arg1)
{
return php_set_server_handler(cmd->server, arg1, 0, AP_HANDLER_TYPE_FILE);
@@ -1116,7 +1105,7 @@ static CONST_PREFIX char *php_set_response_handler_code(cmd_parms *cmd, php_per_
return php_set_dir_handler(conf, arg1, AP_RESPONSE, AP_HANDLER_TYPE_METHOD);
}
/* }}} */
-
+
/* {{{ php_apache_value_handler
*/
static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2)
@@ -1145,7 +1134,7 @@ static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *
bool_val[0] = '0';
}
bool_val[1] = 0;
-
+
return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode);
}
/* }}} */
@@ -1193,7 +1182,7 @@ static int php_xbithack_handler(request_rec * r)
if (conf) {
zend_hash_apply((HashTable *) conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
}
- if(!AP(xbithack)) {
+ if (!AP(xbithack)) {
r->allowed |= (1 << METHODS) - 1;
zend_try {
zend_ini_deactivate(TSRMLS_C);
@@ -1213,7 +1202,7 @@ static void apache_php_module_shutdown_wrapper(void)
#if MODULE_MAGIC_NUMBER >= 19970728
/* This function is only called on server exit if the apache API
- * child_exit handler exists, so shutdown globally
+ * child_exit handler exists, so shutdown globally
*/
sapi_shutdown();
#endif
@@ -1267,10 +1256,9 @@ static int php_run_hook(php_handler *handler, request_rec *r)
{
zval *ret = NULL;
php_per_dir_config *conf;
-
TSRMLS_FETCH();
- if(!AP(apache_config_loaded)) {
+ if (!AP(apache_config_loaded)) {
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
if (conf)
zend_hash_apply((HashTable *)conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
@@ -1296,16 +1284,16 @@ static int php_run_hook(php_handler *handler, request_rec *r)
}
return HTTP_INTERNAL_SERVER_ERROR;
}
-
static int php_uri_translation(request_rec *r)
-{
+{
php_per_server_config *conf;
TSRMLS_FETCH();
+
AP(current_hook) = AP_URI_TRANS;
conf = (php_per_server_config *) get_module_config(r->server->module_config, &php5_module);
- return sapi_stack_apply_with_argument_stop_if_equals(&conf->uri_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
+ return sapi_stack_apply_with_argument_stop_if_equals(&conf->uri_handlers,
+ ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook, r, OK);
}
@@ -1313,6 +1301,7 @@ static int php_header_hook(request_rec *r)
{
php_per_dir_config *conf;
TSRMLS_FETCH();
+
AP(current_hook) = AP_HEADER_PARSE;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->headers_handlers,
@@ -1324,10 +1313,11 @@ static int php_auth_hook(request_rec *r)
{
php_per_dir_config *conf;
TSRMLS_FETCH();
+
AP(current_hook) = AP_AUTHENTICATION;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
- return sapi_stack_apply_with_argument_stop_if_equals(&conf->auth_handlers,
- ZEND_STACK_APPLY_BOTTOMUP,
+ return sapi_stack_apply_with_argument_stop_if_equals(&conf->auth_handlers,
+ ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook, r, OK);
}
@@ -1336,6 +1326,7 @@ static int php_access_hook(request_rec *r)
php_per_dir_config *conf;
int status = DECLINED;
TSRMLS_FETCH();
+
AP(current_hook) = AP_ACCESS_CONTROL;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
status = sapi_stack_apply_with_argument_stop_if_http_error(&conf->access_handlers,
@@ -1349,6 +1340,7 @@ static int php_type_hook(request_rec *r)
{
php_per_dir_config *conf;
TSRMLS_FETCH();
+
AP(current_hook) = AP_TYPE_CHECKING;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
return sapi_stack_apply_with_argument_stop_if_equals(&conf->type_handlers,
@@ -1361,6 +1353,7 @@ static int php_fixup_hook(request_rec *r)
{
php_per_dir_config *conf;
TSRMLS_FETCH();
+
AP(current_hook) = AP_FIXUP;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->fixup_handlers,
@@ -1373,6 +1366,7 @@ static int php_logger_hook(request_rec *r)
{
php_per_dir_config *conf;
TSRMLS_FETCH();
+
AP(current_hook) = AP_LOGGING;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->logger_handlers,
@@ -1380,15 +1374,16 @@ static int php_logger_hook(request_rec *r)
(int (*)(void *element, void *)) php_run_hook,
r);
}
-
+
static int php_post_read_hook(request_rec *r)
{
php_per_dir_config *conf;
php_per_server_config *svr;
TSRMLS_FETCH();
+
AP(current_hook) = AP_POST_READ;
svr = get_module_config(r->server->module_config, &php5_module);
- if(ap_is_initial_req(r)) {
+ if (ap_is_initial_req(r)) {
sapi_stack_apply_with_argument_all(&svr->requires, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
}
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
@@ -1401,6 +1396,7 @@ static int php_response_handler(request_rec *r)
{
php_per_dir_config *conf;
TSRMLS_FETCH();
+
AP(current_hook) = AP_RESPONSE;
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
return sapi_stack_apply_with_argument_all(&conf->response_handlers, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
@@ -1413,7 +1409,7 @@ handler_rec php_handlers[] =
{"application/x-httpd-php", send_parsed_php},
{"application/x-httpd-php-source", send_parsed_php_source},
{"text/html", php_xbithack_handler},
- {"php-script", php_response_handler},
+ {"php-script", php_response_handler},
{NULL}
};
/* }}} */
diff --git a/sapi/apache_hooks/php_apache.c b/sapi/apache_hooks/php_apache.c
index 3e0c9f0a35..fe142c9a17 100644
--- a/sapi/apache_hooks/php_apache.c
+++ b/sapi/apache_hooks/php_apache.c
@@ -110,7 +110,6 @@ static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRML
apache_globals->in_request = 0;
}
-
#define APREQ_GET_THIS(ZVAL) if (NULL == (ZVAL = getThis())) { \
php_error(E_WARNING, "%s(): underlying ApacheRequest object missing", \
get_active_function_name(TSRMLS_C)); \
@@ -162,7 +161,6 @@ zval *php_apache_request_new(request_rec *r)
{
zval *req;
zval *addr;
-
TSRMLS_FETCH();
MAKE_STD_ZVAL(addr);
@@ -201,7 +199,6 @@ static void apache_request_read_string_slot(int offset, INTERNAL_FUNCTION_PARAME
}
/* }}} */
-
/* {{{ apache_request_string_slot()
*/
static void apache_request_string_slot(int offset, INTERNAL_FUNCTION_PARAMETERS)
@@ -286,7 +283,6 @@ static void apache_request_int_slot(int offset, INTERNAL_FUNCTION_PARAMETERS)
}
/* }}} */
-
/* {{{ access string slots of request rec
*/
@@ -338,7 +334,6 @@ PHP_FUNCTION(apache_request_boundary)
}
/* }}} */
-
/* {{{ proto string ApacheRequest::content_type([string new_type])
*/
PHP_FUNCTION(apache_request_content_type)
@@ -424,7 +419,6 @@ PHP_FUNCTION(apache_request_assbackwards)
}
/* }}} */
-
/* {{{ proto int ApacheRequest::proxyreq([int new_proxyreq])
*/
PHP_FUNCTION(apache_request_proxyreq)
@@ -441,7 +435,6 @@ PHP_FUNCTION(apache_request_chunked)
}
/* }}} */
-
/* {{{ proto int ApacheRequest::header_only()
*/
PHP_FUNCTION(apache_request_header_only)
@@ -553,25 +546,21 @@ PHP_FUNCTION(apache_request_read_body)
}
/* }}} */
-
/* }}} access int slots of request_rec */
-
/* {{{ proto array apache_request_headers_in()
- * fetch all incoming request headers
- */
+ Fetch all incoming request headers */
PHP_FUNCTION(apache_request_headers_in)
{
zval *id;
request_rec *r;
-
+
APREQ_GET_REQUEST(id, r);
apache_table_to_zval(r->headers_in, 0, return_value);
}
/* }}} */
-
/* {{{ add_header_to_table
*/
static void add_header_to_table(table *t, INTERNAL_FUNCTION_PARAMETERS)
@@ -582,7 +571,6 @@ static void add_header_to_table(table *t, INTERNAL_FUNCTION_PARAMETERS)
char *string_key;
uint string_key_len;
ulong num_key;
-
zend_bool replace = 0;
HashPosition pos;
@@ -646,18 +634,15 @@ static void add_header_to_table(table *t, INTERNAL_FUNCTION_PARAMETERS)
RETURN_FALSE;
}
}
-
/* }}} */
-
/* {{{ proto array apache_request_headers_out([{string name|array list} [, string value [, bool replace = false]]])
- * fetch all outgoing request headers
- */
+ Fetch all outgoing request headers */
PHP_FUNCTION(apache_request_headers_out)
{
zval *id;
request_rec *r;
-
+
APREQ_GET_REQUEST(id, r);
if (ZEND_NUM_ARGS() > 0) {
@@ -668,15 +653,13 @@ PHP_FUNCTION(apache_request_headers_out)
}
/* }}} */
-
/* {{{ proto array apache_request_err_headers_out([{string name|array list} [, string value [, bool replace = false]]])
- * fetch all headers that go out in case of an error or a subrequest
- */
+ Fetch all headers that go out in case of an error or a subrequest */
PHP_FUNCTION(apache_request_err_headers_out)
{
zval *id;
request_rec *r;
-
+
APREQ_GET_REQUEST(id, r);
if (ZEND_NUM_ARGS() > 0) {
@@ -687,7 +670,6 @@ PHP_FUNCTION(apache_request_err_headers_out)
}
/* }}} */
-
/* {{{ proxy functions for the ap_* functions family
*/
@@ -755,7 +737,6 @@ PHP_FUNCTION(apache_request_update_mtime)
}
/* }}} */
-
/* {{{ proto void apache_request_set_etag()
*/
PHP_FUNCTION(apache_request_set_etag)
@@ -843,7 +824,6 @@ PHP_FUNCTION(apache_request_satisfies)
}
/* }}} */
-
/* {{{ proto bool apache_request_is_initial_req()
*/
PHP_FUNCTION(apache_request_is_initial_req)
@@ -934,12 +914,12 @@ PHP_FUNCTION(apache_request_basic_auth_pw)
long status;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zpw) == FAILURE) {
- return;
+ return;
}
if (!PZVAL_IS_REF(zpw)) {
- zend_error(E_WARNING, "Parameter wasn't passed by reference");
- RETURN_NULL();
+ zend_error(E_WARNING, "Parameter wasn't passed by reference");
+ RETURN_NULL();
}
APREQ_GET_REQUEST(id, r);
@@ -955,129 +935,128 @@ PHP_FUNCTION(apache_request_basic_auth_pw)
}
/* }}} */
-
/* http_protocol.h */
PHP_FUNCTION(apache_request_send_http_header)
{
- zval *id;
- request_rec *r;
- char *type = NULL;
- int typelen;
+ zval *id;
+ request_rec *r;
+ char *type = NULL;
+ int typelen;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &typelen) == FAILURE) {
- return;
+ return;
}
- APREQ_GET_REQUEST(id, r);
- if(type) {
- r->content_type = pstrdup(r->pool, type);
- }
- ap_send_http_header(r);
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
- RETURN_TRUE;
+ APREQ_GET_REQUEST(id, r);
+ if (type) {
+ r->content_type = pstrdup(r->pool, type);
+ }
+ ap_send_http_header(r);
+ SG(headers_sent) = 1;
+ AP(headers_sent) = 1;
+ RETURN_TRUE;
}
PHP_FUNCTION(apache_request_basic_http_header)
{
- zval *id;
- request_rec *r;
+ zval *id;
+ request_rec *r;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
+ APREQ_GET_REQUEST(id, r);
- ap_basic_http_header((request_rec *)SG(server_context));
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
- RETURN_TRUE;
+ ap_basic_http_header((request_rec *)SG(server_context));
+ SG(headers_sent) = 1;
+ AP(headers_sent) = 1;
+ RETURN_TRUE;
}
PHP_FUNCTION(apache_request_send_http_trace)
{
- zval *id;
- request_rec *r;
+ zval *id;
+ request_rec *r;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
-
- APREQ_GET_REQUEST(id, r);
- ap_send_http_trace((request_rec *)SG(server_context));
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
- RETURN_TRUE;
+ APREQ_GET_REQUEST(id, r);
+
+ ap_send_http_trace((request_rec *)SG(server_context));
+ SG(headers_sent) = 1;
+ AP(headers_sent) = 1;
+ RETURN_TRUE;
}
PHP_FUNCTION(apache_request_send_http_options)
{
- zval *id;
- request_rec *r;
+ zval *id;
+ request_rec *r;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
+ APREQ_GET_REQUEST(id, r);
- ap_send_http_options((request_rec *)SG(server_context));
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
- RETURN_TRUE;
+ ap_send_http_options((request_rec *)SG(server_context));
+ SG(headers_sent) = 1;
+ AP(headers_sent) = 1;
+ RETURN_TRUE;
}
PHP_FUNCTION(apache_request_send_error_response)
{
- zval *id;
- request_rec *r;
+ zval *id;
+ request_rec *r;
long rec = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &rec) == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
+ APREQ_GET_REQUEST(id, r);
ap_send_error_response(r, (int) rec);
- RETURN_TRUE;
+ RETURN_TRUE;
}
PHP_FUNCTION(apache_request_set_content_length)
{
long length;
- zval *id;
- request_rec *r;
+ zval *id;
+ request_rec *r;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &length) == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
+ APREQ_GET_REQUEST(id, r);
- ap_set_content_length(r, length);
- RETURN_TRUE;
+ ap_set_content_length(r, length);
+ RETURN_TRUE;
}
PHP_FUNCTION(apache_request_set_keepalive)
{
- zval *id;
- request_rec *r;
+ zval *id;
+ request_rec *r;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
-
- APREQ_GET_REQUEST(id, r);
- ap_set_keepalive(r);
- RETURN_TRUE;
+
+ APREQ_GET_REQUEST(id, r);
+ ap_set_keepalive(r);
+ RETURN_TRUE;
}
/* This stuff should use streams or however this is implemented now
-PHP_FUNCTION(apache_request_send_fd)
+PHP_FUNCTION(apache_request_send_fd)
{
}
@@ -1089,26 +1068,26 @@ PHP_FUNCTION(apache_request_send_fd_length)
/* These are for overriding default output behaviour */
PHP_FUNCTION(apache_request_rputs)
{
- char *buffer;
+ char *buffer;
int buffer_len;
- zval *id;
- request_rec *r;
+ zval *id;
+ request_rec *r;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buffer, &buffer_len) == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
- ap_rwrite(buffer, buffer_len, (request_rec*)SG(server_context));
+ APREQ_GET_REQUEST(id, r);
+ ap_rwrite(buffer, buffer_len, (request_rec*)SG(server_context));
}
-/* This stuff would be useful for custom POST handlers,
+/* This stuff would be useful for custom POST handlers,
which should be supported. Probably by not using
sapi_activate at all inside a phpResponseHandler
and instead using a builtin composed of the below
calls as a apache_read_request_body() and allow
people to custom craft their own.
-
+
PHP_FUNCTION(apache_request_setup_client_block)
{
}
@@ -1132,165 +1111,154 @@ PHP_FUNCTION(apache_request_discard_request_body)
*/
PHP_FUNCTION(apache_request_log_error)
{
- zval *id;
+ zval *id;
char *z_errstr;
int z_errstr_len;
- long facility = APLOG_ERR;
- request_rec *r;
+ long facility = APLOG_ERR;
+ request_rec *r;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &z_errstr, &z_errstr_len, &facility) == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
+ APREQ_GET_REQUEST(id, r);
ap_log_error(APLOG_MARK, (int) facility, r->server, "%s", z_errstr);
- RETURN_TRUE;
+ RETURN_TRUE;
}
/* }}} */
/* http_main.h */
/* {{{ proto object apache_request_sub_req_lookup_uri(string uri)
- Returns sub-request for the specified uri. You would
- need to run it yourself with run()
-*/
+ Returns sub-request for the specified uri. You would need to run it yourself with run() */
PHP_FUNCTION(apache_request_sub_req_lookup_uri)
{
- zval *id;
+ zval *id;
char *file;
int file_len;
- request_rec *r, *sub_r;
+ request_rec *r, *sub_r;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
- sub_r = ap_sub_req_lookup_uri(file, r);
+ APREQ_GET_REQUEST(id, r);
+ sub_r = ap_sub_req_lookup_uri(file, r);
- if (!sub_r) {
- RETURN_FALSE;
- }
- return_value = php_apache_request_new(sub_r);
+ if (!sub_r) {
+ RETURN_FALSE;
+ }
+ return_value = php_apache_request_new(sub_r);
}
/* }}} */
/* {{{ proto object apache_request_sub_req_lookup_file(string file)
- Returns sub-request for the specified file. You would
- need to run it yourself with run().
-*/
+ Returns sub-request for the specified file. You would need to run it yourself with run(). */
PHP_FUNCTION(apache_request_sub_req_lookup_file)
{
- zval *id;
+ zval *id;
char *file;
int file_len;
- request_rec *r, *sub_r;
+ request_rec *r, *sub_r;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
+ APREQ_GET_REQUEST(id, r);
- sub_r = ap_sub_req_lookup_file(file, r);
+ sub_r = ap_sub_req_lookup_file(file, r);
- if (!sub_r) {
- RETURN_FALSE;
- }
- return_value = php_apache_request_new(sub_r);
+ if (!sub_r) {
+ RETURN_FALSE;
+ }
+ return_value = php_apache_request_new(sub_r);
}
/* }}} */
/* {{{ proto object apache_request_sub_req_method_uri(string method, string uri)
- Returns sub-request for the specified file. You would
- need to run it yourself with run().
-*/
+ Returns sub-request for the specified file. You would need to run it yourself with run(). */
PHP_FUNCTION(apache_request_sub_req_method_uri)
{
- zval *id;
+ zval *id;
char *file, *method;
int file_len, method_len;
- request_rec *r, *sub_r;
+ request_rec *r, *sub_r;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &method, &method_len, &file, &file_len) == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
+ APREQ_GET_REQUEST(id, r);
- sub_r = ap_sub_req_method_uri(method, file, r);
+ sub_r = ap_sub_req_method_uri(method, file, r);
- if (!sub_r) {
- RETURN_FALSE;
- }
- return_value = php_apache_request_new(sub_r);
+ if (!sub_r) {
+ RETURN_FALSE;
+ }
+ return_value = php_apache_request_new(sub_r);
}
/* }}} */
/* {{{ proto long apache_request_run()
- This is a wrapper for ap_sub_run_req and ap_destory_sub_req. It takes
- sub_request, runs it, destroys it, and returns it's status.
-*/
+ This is a wrapper for ap_sub_run_req and ap_destory_sub_req. It takes sub_request, runs it, destroys it, and returns it's status. */
PHP_FUNCTION(apache_request_run)
{
- zval *id;
- request_rec *r;
- int status;
+ zval *id;
+ request_rec *r;
+ int status;
- if (zend_parse_parameters_none() == FAILURE) {
- return;
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
}
- APREQ_GET_REQUEST(id, r);
- if (!r || ap_is_initial_req(r)) {
- RETURN_FALSE;
+ APREQ_GET_REQUEST(id, r);
+ if (!r || ap_is_initial_req(r)) {
+ RETURN_FALSE;
}
- status = ap_run_sub_req(r);
- ap_destroy_sub_req(r);
- RETURN_LONG(status);
+ status = ap_run_sub_req(r);
+ ap_destroy_sub_req(r);
+ RETURN_LONG(status);
}
/* }}} */
PHP_FUNCTION(apache_request_internal_redirect)
{
- zval *id;
+ zval *id;
char *new_uri;
int new_uri_len;
- request_rec *r;
+ request_rec *r;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &new_uri, &new_uri_len) == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
+ APREQ_GET_REQUEST(id, r);
- ap_internal_redirect(new_uri, r);
+ ap_internal_redirect(new_uri, r);
}
PHP_FUNCTION(apache_request_send_header_field)
{
char *fieldname, *fieldval;
int fieldname_len, fieldval_len;
- zval *id;
- request_rec *r;
+ zval *id;
+ request_rec *r;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &fieldname, &fieldname_len, &fieldval, &fieldval_len) == FAILURE) {
return;
}
- APREQ_GET_REQUEST(id, r);
+ APREQ_GET_REQUEST(id, r);
- ap_send_header_field(r, fieldname, fieldval);
- SG(headers_sent) = 1;
- AP(headers_sent) = 1;
+ ap_send_header_field(r, fieldname, fieldval);
+ SG(headers_sent) = 1;
+ AP(headers_sent) = 1;
}
-
-
-
/* }}} */
/* {{{ php_apache_request_class_functions
*/
-const static zend_function_entry php_apache_request_class_functions[] = {
+static const zend_function_entry php_apache_request_class_functions[] = {
/* string slots */
PHP_FALIAS(args, apache_request_args, NULL)
PHP_FALIAS(boundary, apache_request_boundary, NULL)
@@ -1329,7 +1297,6 @@ const static zend_function_entry php_apache_request_class_functions[] = {
PHP_FALIAS(headers_out, apache_request_headers_out, NULL)
PHP_FALIAS(err_headers_out, apache_request_err_headers_out, NULL)
-
/* proxy functions for the ap_* functions family */
#undef auth_name
#undef auth_type
@@ -1371,24 +1338,23 @@ const static zend_function_entry php_apache_request_class_functions[] = {
PHP_FALIAS(update_mtime, apache_request_update_mtime, NULL)
PHP_FALIAS(send_http_header, apache_request_send_http_header, NULL)
PHP_FALIAS(basic_http_header, apache_request_basic_http_header, NULL)
- PHP_FALIAS(send_header_field, apache_request_send_header_field, NULL)
+ PHP_FALIAS(send_header_field, apache_request_send_header_field, NULL)
PHP_FALIAS(send_http_trace, apache_request_send_http_trace, NULL)
PHP_FALIAS(send_http_options, apache_request_send_http_trace, NULL)
PHP_FALIAS(send_error_response, apache_request_send_error_response, NULL)
- PHP_FALIAS(set_content_length, apache_request_set_content_length, NULL)
- PHP_FALIAS(set_keepalive, apache_request_set_keepalive, NULL)
- PHP_FALIAS(rputs, apache_request_rputs, NULL)
- PHP_FALIAS(log_error, apache_request_log_error, NULL)
- PHP_FALIAS(lookup_uri, apache_request_sub_req_lookup_uri, NULL)
- PHP_FALIAS(lookup_file, apache_request_sub_req_lookup_file, NULL)
- PHP_FALIAS(method_uri, apache_request_sub_req_method_uri, NULL)
- PHP_FALIAS(run, apache_request_run, NULL)
- PHP_FALIAS(internal_redirect, apache_request_internal_redirect, NULL)
+ PHP_FALIAS(set_content_length, apache_request_set_content_length, NULL)
+ PHP_FALIAS(set_keepalive, apache_request_set_keepalive, NULL)
+ PHP_FALIAS(rputs, apache_request_rputs, NULL)
+ PHP_FALIAS(log_error, apache_request_log_error, NULL)
+ PHP_FALIAS(lookup_uri, apache_request_sub_req_lookup_uri, NULL)
+ PHP_FALIAS(lookup_file, apache_request_sub_req_lookup_file, NULL)
+ PHP_FALIAS(method_uri, apache_request_sub_req_method_uri, NULL)
+ PHP_FALIAS(run, apache_request_run, NULL)
+ PHP_FALIAS(internal_redirect, apache_request_internal_redirect, NULL)
{ NULL, NULL, NULL }
};
/* }}} */
-
static PHP_MINIT_FUNCTION(apache)
{
zend_class_entry ce;
@@ -1400,7 +1366,6 @@ static PHP_MINIT_FUNCTION(apache)
#endif
REGISTER_INI_ENTRIES();
-
le_apachereq = zend_register_list_destructors_ex(php_apache_request_free, NULL, "ApacheRequest", module_number);
INIT_OVERLOADED_CLASS_ENTRY(ce, "ApacheRequest", php_apache_request_class_functions, NULL, NULL, NULL);
apacherequest_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
@@ -1414,53 +1379,53 @@ static PHP_MINIT_FUNCTION(apache)
REGISTER_LONG_CONSTANT("REDIRECT", REDIRECT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("BAD_REQUEST", BAD_REQUEST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("NOT_FOUND", NOT_FOUND, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_CONTINUE", HTTP_CONTINUE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_SWITCHING_PROTOCOLS", HTTP_SWITCHING_PROTOCOLS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PROCESSING", HTTP_PROCESSING, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_OK", HTTP_OK, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_CREATED", HTTP_CREATED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_ACCEPTED", HTTP_ACCEPTED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NON_AUTHORITATIVE", HTTP_NON_AUTHORITATIVE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NO_CONTENT", HTTP_NO_CONTENT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_RESET_CONTENT", HTTP_RESET_CONTENT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PARTIAL_CONTENT", HTTP_PARTIAL_CONTENT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_MULTI_STATUS", HTTP_MULTI_STATUS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_MULTIPLE_CHOICES", HTTP_MULTIPLE_CHOICES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_MOVED_PERMANENTLY", HTTP_MOVED_PERMANENTLY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_MOVED_TEMPORARILY", HTTP_MOVED_TEMPORARILY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_SEE_OTHER", HTTP_SEE_OTHER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_MODIFIED", HTTP_NOT_MODIFIED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_USE_PROXY", HTTP_USE_PROXY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_TEMPORARY_REDIRECT", HTTP_TEMPORARY_REDIRECT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_BAD_REQUEST", HTTP_BAD_REQUEST, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_UNAUTHORIZED", HTTP_UNAUTHORIZED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PAYMENT_REQUIRED", HTTP_PAYMENT_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_FORBIDDEN", HTTP_FORBIDDEN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_FOUND", HTTP_NOT_FOUND, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_METHOD_NOT_ALLOWED", HTTP_METHOD_NOT_ALLOWED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_ACCEPTABLE", HTTP_NOT_ACCEPTABLE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PROXY_AUTHENTICATION_REQUIRED", HTTP_PROXY_AUTHENTICATION_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_REQUEST_TIME_OUT", HTTP_REQUEST_TIME_OUT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_CONFLICT", HTTP_CONFLICT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_GONE", HTTP_GONE, CONST_CS | CONST_PERSISTENT);REGISTER_LONG_CONSTANT("HTTP_LENGTH_REQUIRED", HTTP_LENGTH_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_PRECONDITION_FAILED", HTTP_PRECONDITION_FAILED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_REQUEST_ENTITY_TOO_LARGE", HTTP_REQUEST_ENTITY_TOO_LARGE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_REQUEST_URI_TOO_LARGE", HTTP_REQUEST_URI_TOO_LARGE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_UNSUPPORTED_MEDIA_TYPE", HTTP_UNSUPPORTED_MEDIA_TYPE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_RANGE_NOT_SATISFIABLE", HTTP_RANGE_NOT_SATISFIABLE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_EXPECTATION_FAILED", HTTP_EXPECTATION_FAILED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_UNPROCESSABLE_ENTITY", HTTP_UNPROCESSABLE_ENTITY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_LOCKED", HTTP_LOCKED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_FAILED_DEPENDENCY", HTTP_FAILED_DEPENDENCY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_INTERNAL_SERVER_ERROR", HTTP_INTERNAL_SERVER_ERROR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_IMPLEMENTED", HTTP_NOT_IMPLEMENTED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_BAD_GATEWAY", HTTP_BAD_GATEWAY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_SERVICE_UNAVAILABLE", HTTP_SERVICE_UNAVAILABLE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_GATEWAY_TIME_OUT", HTTP_GATEWAY_TIME_OUT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_VERSION_NOT_SUPPORTED", HTTP_VERSION_NOT_SUPPORTED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_VARIANT_ALSO_VARIES", HTTP_VARIANT_ALSO_VARIES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_INSUFFICIENT_STORAGE", HTTP_INSUFFICIENT_STORAGE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("HTTP_NOT_EXTENDED", HTTP_NOT_EXTENDED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_CONTINUE", HTTP_CONTINUE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_SWITCHING_PROTOCOLS", HTTP_SWITCHING_PROTOCOLS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_PROCESSING", HTTP_PROCESSING, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_OK", HTTP_OK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_CREATED", HTTP_CREATED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_ACCEPTED", HTTP_ACCEPTED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_NON_AUTHORITATIVE", HTTP_NON_AUTHORITATIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_NO_CONTENT", HTTP_NO_CONTENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_RESET_CONTENT", HTTP_RESET_CONTENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_PARTIAL_CONTENT", HTTP_PARTIAL_CONTENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_MULTI_STATUS", HTTP_MULTI_STATUS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_MULTIPLE_CHOICES", HTTP_MULTIPLE_CHOICES, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_MOVED_PERMANENTLY", HTTP_MOVED_PERMANENTLY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_MOVED_TEMPORARILY", HTTP_MOVED_TEMPORARILY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_SEE_OTHER", HTTP_SEE_OTHER, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_NOT_MODIFIED", HTTP_NOT_MODIFIED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_USE_PROXY", HTTP_USE_PROXY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_TEMPORARY_REDIRECT", HTTP_TEMPORARY_REDIRECT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_BAD_REQUEST", HTTP_BAD_REQUEST, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_UNAUTHORIZED", HTTP_UNAUTHORIZED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_PAYMENT_REQUIRED", HTTP_PAYMENT_REQUIRED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_FORBIDDEN", HTTP_FORBIDDEN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_NOT_FOUND", HTTP_NOT_FOUND, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_METHOD_NOT_ALLOWED", HTTP_METHOD_NOT_ALLOWED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_NOT_ACCEPTABLE", HTTP_NOT_ACCEPTABLE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_PROXY_AUTHENTICATION_REQUIRED", HTTP_PROXY_AUTHENTICATION_REQUIRED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_REQUEST_TIME_OUT", HTTP_REQUEST_TIME_OUT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_CONFLICT", HTTP_CONFLICT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_GONE", HTTP_GONE, CONST_CS | CONST_PERSISTENT);REGISTER_LONG_CONSTANT("HTTP_LENGTH_REQUIRED", HTTP_LENGTH_REQUIRED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_PRECONDITION_FAILED", HTTP_PRECONDITION_FAILED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_REQUEST_ENTITY_TOO_LARGE", HTTP_REQUEST_ENTITY_TOO_LARGE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_REQUEST_URI_TOO_LARGE", HTTP_REQUEST_URI_TOO_LARGE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_UNSUPPORTED_MEDIA_TYPE", HTTP_UNSUPPORTED_MEDIA_TYPE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_RANGE_NOT_SATISFIABLE", HTTP_RANGE_NOT_SATISFIABLE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_EXPECTATION_FAILED", HTTP_EXPECTATION_FAILED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_UNPROCESSABLE_ENTITY", HTTP_UNPROCESSABLE_ENTITY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_LOCKED", HTTP_LOCKED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_FAILED_DEPENDENCY", HTTP_FAILED_DEPENDENCY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_INTERNAL_SERVER_ERROR", HTTP_INTERNAL_SERVER_ERROR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_NOT_IMPLEMENTED", HTTP_NOT_IMPLEMENTED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_BAD_GATEWAY", HTTP_BAD_GATEWAY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_SERVICE_UNAVAILABLE", HTTP_SERVICE_UNAVAILABLE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_GATEWAY_TIME_OUT", HTTP_GATEWAY_TIME_OUT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_VERSION_NOT_SUPPORTED", HTTP_VERSION_NOT_SUPPORTED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_VARIANT_ALSO_VARIES", HTTP_VARIANT_ALSO_VARIES, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_INSUFFICIENT_STORAGE", HTTP_INSUFFICIENT_STORAGE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("HTTP_NOT_EXTENDED", HTTP_NOT_EXTENDED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("APLOG_EMERG", APLOG_EMERG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("APLOG_ALERT", APLOG_ALERT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("APLOG_CRIT", APLOG_CRIT, CONST_CS | CONST_PERSISTENT);
@@ -1496,17 +1461,16 @@ static PHP_MINIT_FUNCTION(apache)
REGISTER_LONG_CONSTANT("REQUEST_CHUNKED_ERROR", REQUEST_CHUNKED_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("REQUEST_CHUNKED_DECHUNK", REQUEST_CHUNKED_DECHUNK, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("REQUEST_CHUNKED_PASS", REQUEST_CHUNKED_PASS, CONST_CS | CONST_PERSISTENT);
-
+
/* resolve types for remote_host() */
REGISTER_LONG_CONSTANT("REMOTE_HOST", REMOTE_HOST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("REMOTE_NAME", REMOTE_NAME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("REMOTE_NOLOOKUP", REMOTE_NOLOOKUP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("REMOTE_DOUBLE_REV", REMOTE_DOUBLE_REV, CONST_CS | CONST_PERSISTENT);
-
+
return SUCCESS;
}
-
static PHP_MSHUTDOWN_FUNCTION(apache)
{
UNREGISTER_INI_ENTRIES();
@@ -1515,13 +1479,13 @@ static PHP_MSHUTDOWN_FUNCTION(apache)
zend_module_entry apache_module_entry = {
STANDARD_MODULE_HEADER,
- "apache",
- apache_functions,
- PHP_MINIT(apache),
- PHP_MSHUTDOWN(apache),
- NULL,
- NULL,
- PHP_MINFO(apache),
+ "apache",
+ apache_functions,
+ PHP_MINIT(apache),
+ PHP_MSHUTDOWN(apache),
+ NULL,
+ NULL,
+ PHP_MINFO(apache),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
@@ -1591,7 +1555,6 @@ PHP_MINFO_FUNCTION(apache)
serv = ((request_rec *) SG(server_context))->server;
-
php_info_print_table_start();
#ifdef PHP_WIN32
@@ -1659,14 +1622,14 @@ PHP_MINFO_FUNCTION(apache)
r = ((request_rec *) SG(server_context));
arr = table_elts(r->subprocess_env);
elts = (table_entry *)arr->elts;
-
+
SECTION("Apache Environment");
- php_info_print_table_start();
+ php_info_print_table_start();
php_info_print_table_header(2, "Variable", "Value");
for (i=0; i < arr->nelts; i++) {
php_info_print_table_row(2, elts[i].key, elts[i].val);
}
- php_info_print_table_end();
+ php_info_print_table_end();
}
{
@@ -1674,7 +1637,7 @@ PHP_MINFO_FUNCTION(apache)
table_entry *env;
int i;
request_rec *r;
-
+
r = ((request_rec *) SG(server_context));
SECTION("HTTP Headers Information");
php_info_print_table_start();
@@ -1708,8 +1671,7 @@ PHP_MINFO_FUNCTION(apache)
* that you'd parse through Apache (for .phtml files, you'd probably
* want to use <?Include>. This only works when PHP is compiled
* as an Apache module, since it uses the Apache API for doing
- * sub requests.
- */
+ * sub requests. */
PHP_FUNCTION(virtual)
{
char *filename;
@@ -1722,47 +1684,50 @@ PHP_FUNCTION(virtual)
if (!(rr = sub_req_lookup_uri (filename, ((request_rec *) SG(server_context))))) {
php_error(E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
- if (rr)
+ if (rr) {
destroy_sub_req (rr);
+ }
RETURN_FALSE;
}
if (rr->status != 200) {
php_error(E_WARNING, "Unable to include '%s' - error finding URI", filename);
- if (rr)
+ if (rr) {
destroy_sub_req (rr);
+ }
RETURN_FALSE;
}
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_end_all(TSRMLS_C);
php_header(TSRMLS_C);
if (run_sub_req(rr)) {
php_error(E_WARNING, "Unable to include '%s' - request execution failed", filename);
- if (rr)
+ if (rr) {
destroy_sub_req (rr);
+ }
RETURN_FALSE;
- }
+ }
- if (rr)
+ if (rr) {
destroy_sub_req (rr);
+ }
RETURN_TRUE;
}
/* }}} */
-
/* {{{ apache_table_to_zval(table *, int safe_mode, zval *return_value)
Fetch all HTTP request headers */
static void apache_table_to_zval(table *t, int safe_mode, zval *return_value)
{
- array_header *env_arr;
- table_entry *tenv;
- int i;
-
- array_init(return_value);
- env_arr = table_elts(t);
- tenv = (table_entry *)env_arr->elts;
- for (i = 0; i < env_arr->nelts; ++i) {
+ array_header *env_arr;
+ table_entry *tenv;
+ int i;
+
+ array_init(return_value);
+ env_arr = table_elts(t);
+ tenv = (table_entry *)env_arr->elts;
+ for (i = 0; i < env_arr->nelts; ++i) {
if (!tenv[i].key ||
(safe_mode && !strncasecmp(tenv[i].key, "authorization", 13))) {
continue;
@@ -1770,12 +1735,11 @@ static void apache_table_to_zval(table *t, int safe_mode, zval *return_value)
if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) {
RETURN_FALSE;
}
- }
+ }
}
/* }}} */
-
/* {{{ proto array getallheaders(void)
*/
/* Alias for apache_request_headers() */
@@ -1786,8 +1750,8 @@ static void apache_table_to_zval(table *t, int safe_mode, zval *return_value)
PHP_FUNCTION(apache_request_headers)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
+ return;
+ }
apache_table_to_zval(((request_rec *)SG(server_context))->headers_in, PG(safe_mode), return_value);
}
@@ -1798,8 +1762,8 @@ PHP_FUNCTION(apache_request_headers)
PHP_FUNCTION(apache_response_headers)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
+ return;
+ }
apache_table_to_zval(((request_rec *) SG(server_context))->headers_out, 0, return_value);
}
@@ -1814,11 +1778,11 @@ PHP_FUNCTION(apache_setenv)
char *var = NULL, *val = NULL;
request_rec *r = (request_rec *) SG(server_context);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &var, &var_len, &val, &val_len, &top) == FAILURE) {
- RETURN_FALSE;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &var, &var_len, &val, &val_len, &top) == FAILURE) {
+ RETURN_FALSE;
}
- while(top) {
+ while (top) {
if (r->prev) {
r = r->prev;
}
@@ -1842,7 +1806,7 @@ PHP_FUNCTION(apache_lookup_uri)
return;
}
- if(!(rr = sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
+ if (!(rr = sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
php_error(E_WARNING, "URI lookup failed", filename);
RETURN_FALSE;
}
@@ -1854,16 +1818,16 @@ PHP_FUNCTION(apache_lookup_uri)
add_property_string(return_value,"the_request", rr->the_request, 1);
}
if (rr->status_line) {
- add_property_string(return_value,"status_line", (char *)rr->status_line, 1);
+ add_property_string(return_value,"status_line", (char *)rr->status_line, 1);
}
if (rr->method) {
- add_property_string(return_value,"method", (char *)rr->method, 1);
+ add_property_string(return_value,"method", (char *)rr->method, 1);
}
if (rr->content_type) {
add_property_string(return_value,"content_type", (char *)rr->content_type, 1);
}
if (rr->handler) {
- add_property_string(return_value,"handler", (char *)rr->handler, 1);
+ add_property_string(return_value,"handler", (char *)rr->handler, 1);
}
if (rr->uri) {
add_property_string(return_value,"uri", rr->uri, 1);
@@ -1892,11 +1856,11 @@ PHP_FUNCTION(apache_lookup_uri)
if (rr->unparsed_uri) {
add_property_string(return_value,"unparsed_uri", rr->unparsed_uri, 1);
}
- if(rr->mtime) {
+ if (rr->mtime) {
add_property_long(return_value,"mtime", rr->mtime);
}
#endif
- if(rr->request_time) {
+ if (rr->request_time) {
add_property_long(return_value,"request_time", rr->request_time);
}
@@ -1904,7 +1868,6 @@ PHP_FUNCTION(apache_lookup_uri)
}
/* }}} */
-
#if 0
This function is most likely a bad idea. Just playing with it for now.
@@ -1919,7 +1882,7 @@ PHP_FUNCTION(apache_exec_uri)
}
convert_to_string_ex(filename);
- if(!(rr = ap_sub_req_lookup_uri((*filename)->value.str.val, ((request_rec *) SG(server_context))))) {
+ if (!(rr = ap_sub_req_lookup_uri((*filename)->value.str.val, ((request_rec *) SG(server_context))))) {
php_error(E_WARNING, "URI lookup failed", (*filename)->value.str.val);
RETURN_FALSE;
}
@@ -1948,16 +1911,16 @@ PHP_FUNCTION(apache_get_modules)
{
int n;
char *p;
-
+
array_init(return_value);
-
+
for (n = 0; ap_loaded_modules[n]; ++n) {
char *s = (char *) ap_loaded_modules[n]->name;
if ((p = strchr(s, '.'))) {
add_next_index_stringl(return_value, s, (p - s), 1);
} else {
add_next_index_string(return_value, s, 1);
- }
+ }
}
}
/* }}} */
diff --git a/sapi/apache_hooks/sapi_apache.c b/sapi/apache_hooks/sapi_apache.c
index 5c9fbb7816..82440e4a1b 100644
--- a/sapi/apache_hooks/sapi_apache.c
+++ b/sapi/apache_hooks/sapi_apache.c
@@ -34,7 +34,7 @@ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
}
/* sending a file handle to another dll is not working
so let zend open it. */
-
+
if (display_source_mode) {
zend_syntax_highlighter_ini syntax_highlighter_ini;
@@ -53,7 +53,7 @@ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
(void) php_execute_script(&file_handle TSRMLS_CC);
}
AP(in_request) = 0;
-
+
return (OK);
}
/* }}} */
@@ -64,59 +64,58 @@ int apache_php_module_hook(request_rec *r, php_handler *handler, zval **ret TSRM
{
zend_file_handle file_handle;
zval *req;
- char *tmp;
+ char *tmp;
#if PHP_SIGCHILD
signal(SIGCHLD, sigchld_handler);
#endif
- if(AP(current_hook) == AP_RESPONSE) {
- if (php_request_startup_for_hook(TSRMLS_C) == FAILURE)
- return FAILURE;
- }
- else {
- if (php_request_startup_for_hook(TSRMLS_C) == FAILURE)
- return FAILURE;
- }
+ if (AP(current_hook) == AP_RESPONSE) {
+ if (php_request_startup_for_hook(TSRMLS_C) == FAILURE) {
+ return FAILURE;
+ }
+ } else {
+ if (php_request_startup_for_hook(TSRMLS_C) == FAILURE) {
+ return FAILURE;
+ }
+ }
req = php_apache_request_new(r);
- if(PG(register_globals)) {
- php_register_variable_ex("request", req, NULL TSRMLS_CC);
- }
- else {
- php_register_variable_ex("request", req, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
- }
- switch(handler->type) {
- case AP_HANDLER_TYPE_FILE:
- php_register_variable("PHP_SELF_HOOK", handler->name, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
- memset(&file_handle, 0, sizeof(file_handle));
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.filename = handler->name;
- (void) php_execute_simple_script(&file_handle, ret TSRMLS_CC);
- break;
- case AP_HANDLER_TYPE_METHOD:
- if( (tmp = strstr(handler->name, "::")) != NULL && *(tmp+2) != '\0' ) {
- zval *class;
- zval *method;
- *tmp = '\0';
- ALLOC_ZVAL(class);
- ZVAL_STRING(class, handler->name, 1);
- ALLOC_ZVAL(method);
- ZVAL_STRING(method, tmp +2, 1);
- *tmp = ':';
- call_user_function_ex(EG(function_table), &class, method, ret, 0, NULL, 0, NULL TSRMLS_CC);
- zval_dtor(class);
- zval_dtor(method);
- }
- else {
- php_error(E_ERROR, "Unable to call %s - not a Class::Method\n", handler->name);
- /* not a class::method */
- }
- break;
- default:
- /* not a valid type */
- assert(0);
- break;
- }
+ if (PG(register_globals)) {
+ php_register_variable_ex("request", req, NULL TSRMLS_CC);
+ } else {
+ php_register_variable_ex("request", req, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
+ }
+ switch(handler->type) {
+ case AP_HANDLER_TYPE_FILE:
+ php_register_variable("PHP_SELF_HOOK", handler->name, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
+ memset(&file_handle, 0, sizeof(file_handle));
+ file_handle.type = ZEND_HANDLE_FILENAME;
+ file_handle.filename = handler->name;
+ (void) php_execute_simple_script(&file_handle, ret TSRMLS_CC);
+ break;
+ case AP_HANDLER_TYPE_METHOD:
+ if ( (tmp = strstr(handler->name, "::")) != NULL && *(tmp+2) != '\0' ) {
+ zval *class;
+ zval *method;
+ *tmp = '\0';
+ ALLOC_ZVAL(class);
+ ZVAL_STRING(class, handler->name, 1);
+ ALLOC_ZVAL(method);
+ ZVAL_STRING(method, tmp +2, 1);
+ *tmp = ':';
+ call_user_function_ex(EG(function_table), &class, method, ret, 0, NULL, 0, NULL TSRMLS_CC);
+ zval_dtor(class);
+ zval_dtor(method);
+ } else {
+ php_error(E_ERROR, "Unable to call %s - not a Class::Method\n", handler->name);
+ /* not a class::method */
+ }
+ break;
+ default:
+ /* not a valid type */
+ assert(0);
+ break;
+ }
zval_dtor(req);
AP(in_request) = 0;