summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
Diffstat (limited to 'sapi')
-rw-r--r--sapi/apache/libpre.c8
-rw-r--r--sapi/apache/mod_php5.c41
-rw-r--r--sapi/apache/php_apache.c79
-rw-r--r--sapi/apache/sapi_apache.c8
-rw-r--r--sapi/apache2handler/php_functions.c2
-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
-rw-r--r--sapi/cgi/cgi_main.c37
-rw-r--r--sapi/cli/php_cli.c8
-rw-r--r--sapi/cli/tests/007.phpt8
-rw-r--r--sapi/cli/tests/008.phpt8
-rw-r--r--sapi/cli/tests/009.phpt8
-rw-r--r--sapi/cli/tests/011.phpt4
-rw-r--r--sapi/cli/tests/012.phpt32
-rw-r--r--sapi/cli/tests/014.phpt4
-rw-r--r--sapi/milter/php_milter.c14
-rw-r--r--sapi/nsapi/nsapi.c2
18 files changed, 508 insertions, 565 deletions
diff --git a/sapi/apache/libpre.c b/sapi/apache/libpre.c
index 2b89307..ec2b57b 100644
--- a/sapi/apache/libpre.c
+++ b/sapi/apache/libpre.c
@@ -33,7 +33,7 @@
#ifdef __GNUC__
-#include <string.h> /* memset */
+#include <string.h> /* memset */
extern char _edata, _end ; /* end of DATA (start of BSS), end of BSS */
#endif
@@ -41,15 +41,15 @@ int _lib_start()
{
/* printf("Inside _lib_start\n");*/
#ifdef __GNUC__
- memset (&_edata, 0, &_end - &_edata);
+ memset (&_edata, 0, &_end - &_edata);
#endif
- return 0;
+ return 0;
}
int _lib_stop()
{
/* printf("Inside _lib_stop\n");*/
- return 0;
+ return 0;
}
#endif /* NETWARE */
diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c
index 9711e3f..815fd48 100644
--- a/sapi/apache/mod_php5.c
+++ b/sapi/apache/mod_php5.c
@@ -95,7 +95,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));
}
@@ -137,7 +137,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 */
@@ -148,7 +148,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;
}
/* }}} */
@@ -332,15 +332,15 @@ static void php_apache_request_shutdown(void *dummy)
{
TSRMLS_FETCH();
- php_output_set_status(0 TSRMLS_CC);
+ php_output_set_status(PHP_OUTPUT_DISABLED TSRMLS_CC);
if (AP(in_request)) {
AP(in_request) = 0;
php_request_shutdown(dummy);
}
- SG(server_context) = NULL;
- /*
- * The server context (request) is NOT invalid by the time
- * run_cleanups() is called
+ SG(server_context) = NULL;
+ /*
+ * The server context (request) is NOT invalid by the time
+ * run_cleanups() is called
*/
}
/* }}} */
@@ -349,7 +349,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
@@ -357,7 +357,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);
@@ -401,7 +401,7 @@ static int sapi_apache_get_fd(int *nfd TSRMLS_DC)
int fd;
fd = r->connection->client->fd;
-
+
if (fd >= 0) {
if (nfd) *nfd = fd;
return SUCCESS;
@@ -416,9 +416,9 @@ static int sapi_apache_get_fd(int *nfd TSRMLS_DC)
static int sapi_apache_force_http_10(TSRMLS_D)
{
request_rec *r = SG(server_context);
-
+
r->proto_num = HTTP_VERSION(1,0);
-
+
return SUCCESS;
}
/* }}} */
@@ -464,7 +464,7 @@ static void sapi_apache_child_terminate(TSRMLS_D)
static sapi_module_struct apache_sapi_module = {
"apache", /* name */
"Apache", /* pretty name */
-
+
php_apache_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
@@ -579,8 +579,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. */
@@ -628,7 +628,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
if (per_dir_conf) {
zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
}
-
+
/* If PHP parser engine has been turned off with an "engine off"
* directive, then decline to handle this request
*/
@@ -696,9 +696,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, "%lu", zend_memory_peak_usage(1 TSRMLS_CC)));
+
+ ap_table_setn(r->notes, "mod_php_memory_usage", ap_psprintf(r->pool, "%lu", zend_memory_peak_usage(1 TSRMLS_CC)));
return result;
}
@@ -860,7 +859,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);
}
/* }}} */
@@ -926,7 +925,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
diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c
index 8faa6f3..e2055cc 100644
--- a/sapi/apache/php_apache.c
+++ b/sapi/apache/php_apache.c
@@ -93,8 +93,6 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_apache_reset_timeout, 0)
ZEND_END_ARG_INFO()
-
-
const zend_function_entry apache_functions[] = {
PHP_FE(virtual, arginfo_apache_virtual)
PHP_FE(apache_request_headers, arginfo_apache_request_headers)
@@ -110,7 +108,6 @@ const zend_function_entry apache_functions[] = {
{NULL, NULL, NULL}
};
-
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("xbithack", "0", PHP_INI_ALL, OnUpdateLong, xbithack, php_apache_info_struct, php_apache_info)
STD_PHP_INI_ENTRY("engine", "1", PHP_INI_ALL, OnUpdateLong, engine, php_apache_info_struct, php_apache_info)
@@ -118,14 +115,11 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("child_terminate", "0", PHP_INI_ALL, OnUpdateLong, terminate_child, php_apache_info_struct, php_apache_info)
PHP_INI_END()
-
-
static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRMLS_DC)
{
apache_globals->in_request = 0;
}
-
static PHP_MINIT_FUNCTION(apache)
{
#ifdef ZTS
@@ -137,7 +131,6 @@ static PHP_MINIT_FUNCTION(apache)
return SUCCESS;
}
-
static PHP_MSHUTDOWN_FUNCTION(apache)
{
UNREGISTER_INI_ENTRIES();
@@ -146,13 +139,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
};
@@ -178,7 +171,6 @@ PHP_MINFO_FUNCTION(apache)
serv = ((request_rec *) SG(server_context))->server;
-
php_info_print_table_start();
#ifdef PHP_WIN32
@@ -196,7 +188,7 @@ PHP_MINFO_FUNCTION(apache)
if (apv && *apv) {
php_info_print_table_row(2, "Apache Version", apv);
- }
+ }
#ifdef APACHE_RELEASE
snprintf(output_buf, sizeof(output_buf), "%d", APACHE_RELEASE);
@@ -222,7 +214,7 @@ PHP_MINFO_FUNCTION(apache)
php_info_print_table_row(2, "Server Root", server_root);
strcpy(modulenames, "");
- for(modp = top_module; modp; modp = modp->next) {
+ for (modp = top_module; modp; modp = modp->next) {
strlcpy(name, modp->name, sizeof(name));
if ((p = strrchr(name, '.'))) {
*p='\0'; /* Cut off ugly .c extensions on module names */
@@ -248,14 +240,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();
}
{
@@ -263,7 +255,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();
@@ -279,7 +271,7 @@ PHP_MINFO_FUNCTION(apache)
php_info_print_table_colspan_header(2, "HTTP Response Headers");
env_arr = table_elts(r->headers_out);
env = (table_entry *)env_arr->elts;
- for(i = 0; i < env_arr->nelts; ++i) {
+ for (i = 0; i < env_arr->nelts; ++i) {
if (env[i].key) {
php_info_print_table_row(2, env[i].key, env[i].val);
}
@@ -353,34 +345,37 @@ PHP_FUNCTION(virtual)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
return;
}
-
+
if (!(rr = sub_req_lookup_uri (filename, ((request_rec *) SG(server_context))))) {
php_error_docref(NULL TSRMLS_CC, 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_docref(NULL TSRMLS_CC, 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_docref(NULL TSRMLS_CC, 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;
}
/* }}} */
@@ -409,7 +404,7 @@ PHP_FUNCTION(apache_request_headers)
if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) {
RETURN_FALSE;
}
- }
+ }
}
/* }}} */
@@ -446,8 +441,10 @@ PHP_FUNCTION(apache_setenv)
return;
}
- while(top) {
- if(r->prev) r = r->prev;
+ while (top) {
+ if (r->prev) {
+ r = r->prev;
+ }
else break;
}
@@ -480,16 +477,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);
@@ -519,11 +516,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);
}
@@ -546,7 +543,7 @@ PHP_FUNCTION(apache_exec_uri)
return;
}
- if(!(rr = ap_sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
+ if (!(rr = ap_sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "URI lookup failed", filename);
RETURN_FALSE;
}
@@ -576,16 +573,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/sapi_apache.c b/sapi/apache/sapi_apache.c
index 895463b..1d58c0b 100644
--- a/sapi/apache/sapi_apache.c
+++ b/sapi/apache/sapi_apache.c
@@ -27,7 +27,7 @@
*/
int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
{
- int retval = OK;
+ int retval = OK;
zend_file_handle file_handle;
if (php_request_startup(TSRMLS_C) == FAILURE) {
@@ -35,7 +35,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;
@@ -54,11 +54,11 @@ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
}
AP(in_request) = 0;
-
+
zend_try {
php_request_shutdown(NULL);
} zend_end_try();
-
+
return retval;
}
/* }}} */
diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c
index 32f6b57..3b275d3 100644
--- a/sapi/apache2handler/php_functions.c
+++ b/sapi/apache2handler/php_functions.c
@@ -91,7 +91,7 @@ PHP_FUNCTION(virtual)
}
/* Flush everything. */
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_end_all(TSRMLS_C);
php_header(TSRMLS_C);
/* Ensure that the ap_r* layer for the main request is flushed, to
diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php5.c
index 7b6d18d..1d8bed4 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 3e0c9f0..fe142c9 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 5c9fbb7..82440e4 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;
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 90158fb..4eeb756 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -1634,9 +1634,8 @@ int main(int argc, char *argv[])
* in case some server does something different than above */
(!CGIG(redirect_status_env) || !getenv(CGIG(redirect_status_env)))
) {
- zend_try {
- SG(sapi_headers).http_response_code = 400;
- PUTS("<b>Security Alert!</b> The PHP CGI cannot be accessed directly.\n\n\
+ SG(sapi_headers).http_response_code = 400;
+ PUTS("<b>Security Alert!</b> The PHP CGI cannot be accessed directly.\n\n\
<p>This PHP CGI binary was compiled with force-cgi-redirect enabled. This\n\
means that a page will only be served up if the REDIRECT_STATUS CGI variable is\n\
set, e.g. via an Apache Action directive.</p>\n\
@@ -1645,8 +1644,6 @@ manual page for CGI security</a>.</p>\n\
<p>For more information about changing this behaviour or re-enabling this webserver,\n\
consult the installation file that came with this distribution, or visit \n\
<a href=\"http://php.net/install.windows\">the manual page</a>.</p>\n");
- } zend_catch {
- } zend_end_try();
#if defined(ZTS) && !defined(PHP_DEBUG)
/* XXX we're crashing here in msvc6 debug builds at
* php_message_handler_for_zend:839 because
@@ -1809,11 +1806,9 @@ consult the installation file that came with this distribution, or visit \n\
case '?':
fcgi_shutdown();
no_headers = 1;
- php_output_startup();
- php_output_activate(TSRMLS_C);
SG(headers_sent) = 1;
php_cgi_usage(argv[0]);
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_end_all(TSRMLS_C);
exit_status = 0;
goto out;
}
@@ -1887,15 +1882,13 @@ consult the installation file that came with this distribution, or visit \n\
if (script_file) {
efree(script_file);
}
- php_output_startup();
- php_output_activate(TSRMLS_C);
SG(headers_sent) = 1;
php_printf("[PHP Modules]\n");
print_modules(TSRMLS_C);
php_printf("\n[Zend Modules]\n");
print_extensions(TSRMLS_C);
php_printf("\n");
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_end_all(TSRMLS_C);
exit_status = 0;
goto out;
@@ -2042,16 +2035,13 @@ consult the installation file that came with this distribution, or visit \n\
*/
if (cgi || fastcgi || SG(request_info).path_translated) {
if (php_fopen_primary_script(&file_handle TSRMLS_CC) == FAILURE) {
- zend_try {
- if (errno == EACCES) {
- SG(sapi_headers).http_response_code = 403;
- PUTS("Access denied.\n");
- } else {
- SG(sapi_headers).http_response_code = 404;
- PUTS("No input file specified.\n");
- }
- } zend_catch {
- } zend_end_try();
+ if (errno == EACCES) {
+ SG(sapi_headers).http_response_code = 403;
+ PUTS("Access denied.\n");
+ } else {
+ SG(sapi_headers).http_response_code = 404;
+ PUTS("No input file specified.\n");
+ }
/* we want to serve more requests if this is fastcgi
* so cleanup and continue, request shutdown is
* handled later */
@@ -2114,7 +2104,7 @@ consult the installation file that came with this distribution, or visit \n\
if (open_file_for_scanning(&file_handle TSRMLS_CC) == SUCCESS) {
zend_strip(TSRMLS_C);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_teardown();
}
return SUCCESS;
break;
@@ -2129,7 +2119,7 @@ consult the installation file that came with this distribution, or visit \n\
goto fastcgi_request_done;
}
zend_file_handle_dtor(&file_handle TSRMLS_CC);
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_teardown();
}
return SUCCESS;
}
@@ -2140,6 +2130,7 @@ consult the installation file that came with this distribution, or visit \n\
open_file_for_scanning(&file_handle TSRMLS_CC);
zend_indent();
zend_file_handle_dtor(&file_handle TSRMLS_CC);
+ php_output_teardown();
return SUCCESS;
break;
#endif
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 635445e..e5dcfa1 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -797,7 +797,7 @@ int main(int argc, char *argv[])
}
request_started = 1;
php_cli_usage(argv[0]);
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_end_all(TSRMLS_C);
exit_status=0;
goto out;
@@ -807,7 +807,7 @@ int main(int argc, char *argv[])
}
request_started = 1;
php_print_info(0xFFFFFFFF TSRMLS_CC);
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_end_all(TSRMLS_C);
exit_status=0;
goto out;
@@ -821,7 +821,7 @@ int main(int argc, char *argv[])
php_printf("\n[Zend Modules]\n");
print_extensions(TSRMLS_C);
php_printf("\n");
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_end_all(TSRMLS_C);
exit_status=0;
goto out;
@@ -844,7 +844,7 @@ int main(int argc, char *argv[])
#endif
get_zend_version()
);
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_end_all(TSRMLS_C);
exit_status=0;
goto out;
diff --git a/sapi/cli/tests/007.phpt b/sapi/cli/tests/007.phpt
index 12fddee..ca0200e 100644
--- a/sapi/cli/tests/007.phpt
+++ b/sapi/cli/tests/007.phpt
@@ -32,8 +32,8 @@ class test { /* {{{ */
file_put_contents($filename, $code);
-var_dump(`$php -n -w "$filename"`);
-var_dump(`$php -n -w "wrong"`);
+var_dump(`"$php" -n -w "$filename"`);
+var_dump(`"$php" -n -w "wrong"`);
var_dump(`echo "<?php /* comment */ class test {\n // comment \n function foo() {} } ?>" | $php -n -w`);
@unlink($filename);
@@ -45,8 +45,8 @@ string(81) "
<?php
class test { public $var = "test"; private $pri; function foo() { } } ?>
"
-Could not open input file: wrong
-NULL
+string(33) "Could not open input file: wrong
+"
string(43) "<?php class test { function foo() {} } ?>
"
Done
diff --git a/sapi/cli/tests/008.phpt b/sapi/cli/tests/008.phpt
index a833043..1f77a5b 100644
--- a/sapi/cli/tests/008.phpt
+++ b/sapi/cli/tests/008.phpt
@@ -26,8 +26,8 @@ var_dump(test::$pri);
file_put_contents($filename, $code);
-var_dump(`$php -n -f "$filename"`);
-var_dump(`$php -n -f "wrong"`);
+var_dump(`"$php" -n -f "$filename"`);
+var_dump(`"$php" -n -f "wrong"`);
@unlink($filename);
@@ -38,6 +38,6 @@ string(%d) "
Fatal error: Cannot access private property test::$pri in %s on line %d
"
-Could not open input file: wrong
-NULL
+string(33) "Could not open input file: wrong
+"
Done
diff --git a/sapi/cli/tests/009.phpt b/sapi/cli/tests/009.phpt
index a881a07..33f859f 100644
--- a/sapi/cli/tests/009.phpt
+++ b/sapi/cli/tests/009.phpt
@@ -13,8 +13,8 @@ var_dump(`$php -n -r "echo hello;" -a`);
echo "Done\n";
?>
--EXPECTF--
-Either execute direct code, process stdin or use a file.
-NULL
-Either execute direct code, process stdin or use a file.
-NULL
+string(57) "Either execute direct code, process stdin or use a file.
+"
+string(57) "Either execute direct code, process stdin or use a file.
+"
Done
diff --git a/sapi/cli/tests/011.phpt b/sapi/cli/tests/011.phpt
index ef49666..6154693 100644
--- a/sapi/cli/tests/011.phpt
+++ b/sapi/cli/tests/011.phpt
@@ -49,8 +49,8 @@ echo "Done\n";
--EXPECTF--
string(%d) "No syntax errors detected in %s011.test.php
"
-Could not open input file: some.unknown
-NULL
+string(40) "Could not open input file: some.unknown
+"
string(%d) "
Parse error: %s expecting %s{%s in %s on line %d
Errors parsing %s011.test.php
diff --git a/sapi/cli/tests/012.phpt b/sapi/cli/tests/012.phpt
index 137e0bd..c1e4f6a 100644
--- a/sapi/cli/tests/012.phpt
+++ b/sapi/cli/tests/012.phpt
@@ -19,20 +19,20 @@ var_dump(`"$php" -n -r '' -r ''`);
echo "Done\n";
?>
--EXPECTF--
-You can use -R or -F only once.
-NULL
-You can use -R or -F only once.
-NULL
-You can use -R or -F only once.
-NULL
-You can use -R or -F only once.
-NULL
-You can use -f only once.
-NULL
-You can use -B only once.
-NULL
-You can use -E only once.
-NULL
-You can use -r only once.
-NULL
+string(32) "You can use -R or -F only once.
+"
+string(32) "You can use -R or -F only once.
+"
+string(32) "You can use -R or -F only once.
+"
+string(32) "You can use -R or -F only once.
+"
+string(26) "You can use -f only once.
+"
+string(26) "You can use -B only once.
+"
+string(26) "You can use -E only once.
+"
+string(26) "You can use -r only once.
+"
Done
diff --git a/sapi/cli/tests/014.phpt b/sapi/cli/tests/014.phpt
index b20478a..e8c5203 100644
--- a/sapi/cli/tests/014.phpt
+++ b/sapi/cli/tests/014.phpt
@@ -39,6 +39,6 @@ string(1478) "<code><span style="color: #000000">
<br /><span style="color: #0000BB">&lt;?php<br />$test&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"var"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//var<br />/*&nbsp;test&nbsp;class&nbsp;*/<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">test&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;</span><span style="color: #0000BB">$var&nbsp;</span><span style="color: #007700">=&nbsp;array();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">(</span><span style="color: #0000BB">Test&nbsp;$arg</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"hello"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$o&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;<br /></span>
</span>
</code>"
-Could not open input file: unknown
-NULL
+string(35) "Could not open input file: unknown
+"
Done
diff --git a/sapi/milter/php_milter.c b/sapi/milter/php_milter.c
index 11724c4..b55713e 100644
--- a/sapi/milter/php_milter.c
+++ b/sapi/milter/php_milter.c
@@ -823,7 +823,7 @@ ZEND_END_ARG_INFO()
/* {{{ milter_functions[]
*/
-const static zend_function_entry milter_functions[] = {
+static const zend_function_entry milter_functions[] = {
PHP_FE(smfi_setflags, arginfo_smfi_setflags)
PHP_FE(smfi_settimeout, arginfo_smfi_settimeout)
PHP_FE(smfi_getsymval, arginfo_smfi_getsymval)
@@ -1040,11 +1040,10 @@ int main(int argc, char *argv[])
while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
switch (c) {
case '?':
- php_output_startup();
- php_output_activate(TSRMLS_C);
+ php_output_tearup();
SG(headers_sent) = 1;
php_milter_usage(argv[0]);
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_teardown();
exit(1);
break;
}
@@ -1088,11 +1087,10 @@ int main(int argc, char *argv[])
case 'h': /* help & quit */
case '?':
- php_output_startup();
- php_output_activate(TSRMLS_C);
+ php_output_tearup();
SG(headers_sent) = 1;
php_milter_usage(argv[0]);
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_teardown();
exit(1);
break;
@@ -1112,7 +1110,7 @@ int main(int argc, char *argv[])
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2010 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_teardown();
exit(1);
break;
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index 8d8363c..bf8aa0a 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -347,7 +347,7 @@ PHP_FUNCTION(nsapi_virtual)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Sub-requests do not work with zlib.output_compression", uri);
RETURN_FALSE;
} else {
- php_end_ob_buffers(1 TSRMLS_CC);
+ php_output_end_all(TSRMLS_C);
php_header(TSRMLS_C);
/* do the sub-request */