2000-10-29 17:43:23 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| PHP version 4.0 |
|
|
|
|
+----------------------------------------------------------------------+
|
2001-02-26 06:11:02 +00:00
|
|
|
| Copyright (c) 1997-2001 The PHP Group |
|
2000-10-29 17:43:23 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 2.02 of the PHP license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available at through the world-wide-web at |
|
|
|
|
| http://www.php.net/license/2_02.txt. |
|
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Sascha Schumann <sascha@schumann.cx> |
|
|
|
|
| Parts based on Apache 1.3 SAPI module by |
|
|
|
|
| Rasmus Lerdorf and Zeev Suraski |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2000-10-26 17:55:05 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include "php.h"
|
|
|
|
#include "php_main.h"
|
|
|
|
#include "php_ini.h"
|
|
|
|
#include "php_variables.h"
|
|
|
|
#include "SAPI.h"
|
|
|
|
|
|
|
|
#include "ext/standard/php_smart_str.h"
|
|
|
|
|
|
|
|
#include "apr_strings.h"
|
|
|
|
#include "ap_config.h"
|
|
|
|
#include "util_filter.h"
|
|
|
|
#include "httpd.h"
|
|
|
|
#include "http_config.h"
|
|
|
|
#include "http_request.h"
|
|
|
|
#include "http_core.h"
|
|
|
|
#include "http_protocol.h"
|
|
|
|
#include "http_log.h"
|
|
|
|
#include "http_main.h"
|
|
|
|
#include "util_script.h"
|
|
|
|
#include "http_core.h"
|
|
|
|
|
|
|
|
#include "php_apache.h"
|
|
|
|
|
|
|
|
static int
|
2001-08-05 15:29:47 +00:00
|
|
|
php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
|
2000-10-26 17:55:05 +00:00
|
|
|
{
|
2001-02-28 14:03:58 +00:00
|
|
|
apr_bucket *b;
|
|
|
|
apr_bucket_brigade *bb;
|
2000-10-26 17:55:05 +00:00
|
|
|
php_struct *ctx;
|
2000-10-27 13:30:41 +00:00
|
|
|
uint now;
|
2000-10-26 17:55:05 +00:00
|
|
|
|
|
|
|
ctx = SG(server_context);
|
|
|
|
|
2001-02-28 14:19:15 +00:00
|
|
|
if (str_length == 0) return 0;
|
2000-11-11 18:24:27 +00:00
|
|
|
|
2001-02-28 14:03:58 +00:00
|
|
|
bb = apr_brigade_create(ctx->f->r->pool);
|
2000-10-27 13:30:41 +00:00
|
|
|
while (str_length > 0) {
|
|
|
|
now = MIN(str_length, 4096);
|
2001-02-28 14:03:58 +00:00
|
|
|
b = apr_bucket_transient_create(str, now);
|
2001-02-28 14:11:34 +00:00
|
|
|
APR_BRIGADE_INSERT_TAIL(bb, b);
|
2000-10-27 13:30:41 +00:00
|
|
|
str += now;
|
|
|
|
str_length -= now;
|
|
|
|
}
|
2000-10-29 15:10:49 +00:00
|
|
|
if (ap_pass_brigade(ctx->f->next, bb) != APR_SUCCESS) {
|
2000-10-29 16:01:02 +00:00
|
|
|
php_handle_aborted_connection();
|
2000-10-29 15:10:49 +00:00
|
|
|
}
|
2000-10-26 17:55:05 +00:00
|
|
|
|
|
|
|
return str_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-28 11:36:37 +00:00
|
|
|
php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC)
|
2000-10-26 17:55:05 +00:00
|
|
|
{
|
|
|
|
php_struct *ctx = SG(server_context);
|
|
|
|
char *val;
|
|
|
|
|
|
|
|
val = strchr(sapi_header->header, ':');
|
|
|
|
|
|
|
|
if (!val) return 0;
|
|
|
|
|
|
|
|
*val = '\0';
|
|
|
|
|
|
|
|
do {
|
|
|
|
val++;
|
|
|
|
} while (*val == ' ');
|
|
|
|
|
|
|
|
if (!strcasecmp(sapi_header->header, "content-type"))
|
|
|
|
ctx->f->r->content_type = apr_pstrdup(ctx->f->r->pool, val);
|
|
|
|
else if (sapi_header->replace)
|
|
|
|
apr_table_set(ctx->f->r->headers_out, sapi_header->header, val);
|
|
|
|
else
|
|
|
|
apr_table_add(ctx->f->r->headers_out, sapi_header->header, val);
|
|
|
|
|
|
|
|
sapi_free_header(sapi_header);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-28 11:36:37 +00:00
|
|
|
php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
|
2000-10-26 17:55:05 +00:00
|
|
|
{
|
|
|
|
php_struct *ctx = SG(server_context);
|
|
|
|
|
|
|
|
ctx->f->r->status = SG(sapi_headers).http_response_code;
|
|
|
|
|
|
|
|
return SAPI_HEADER_SENT_SUCCESSFULLY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-07-28 11:36:37 +00:00
|
|
|
php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
|
2000-10-26 17:55:05 +00:00
|
|
|
{
|
2000-10-29 14:52:15 +00:00
|
|
|
int n;
|
|
|
|
int to_read;
|
2000-10-27 23:02:20 +00:00
|
|
|
php_struct *ctx = SG(server_context);
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2000-10-29 14:52:15 +00:00
|
|
|
to_read = ctx->post_len - ctx->post_idx;
|
|
|
|
n = MIN(to_read, count_bytes);
|
|
|
|
|
|
|
|
if (n > 0) {
|
|
|
|
memcpy(buf, ctx->post_data + ctx->post_idx, n);
|
|
|
|
ctx->post_idx += n;
|
|
|
|
} else {
|
|
|
|
if (ctx->post_data) free(ctx->post_data);
|
|
|
|
ctx->post_data = NULL;
|
2000-10-27 23:02:20 +00:00
|
|
|
}
|
|
|
|
|
2000-10-29 14:52:15 +00:00
|
|
|
return n;
|
2000-10-26 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2001-07-28 11:36:37 +00:00
|
|
|
php_apache_sapi_read_cookies(TSRMLS_D)
|
2000-10-26 17:55:05 +00:00
|
|
|
{
|
2000-10-27 10:19:40 +00:00
|
|
|
php_struct *ctx = SG(server_context);
|
|
|
|
const char *http_cookie;
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2000-10-27 10:19:40 +00:00
|
|
|
http_cookie = apr_table_get(ctx->f->r->headers_in, "cookie");
|
|
|
|
|
2000-10-27 13:19:23 +00:00
|
|
|
/* The SAPI interface should use 'const char *' */
|
2000-10-27 10:19:40 +00:00
|
|
|
return (char *) http_cookie;
|
2000-10-26 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-08-02 15:14:30 +00:00
|
|
|
php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC)
|
2000-10-26 17:55:05 +00:00
|
|
|
{
|
|
|
|
php_struct *ctx = SG(server_context);
|
|
|
|
apr_array_header_t *arr = apr_table_elts(ctx->f->r->subprocess_env);
|
2000-11-11 18:24:27 +00:00
|
|
|
char *key, *val;
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2000-11-11 18:24:27 +00:00
|
|
|
APR_ARRAY_FOREACH_OPEN(arr, key, val)
|
|
|
|
if (!val) val = empty_string;
|
2001-07-28 11:36:37 +00:00
|
|
|
php_register_variable(key, val, track_vars_array TSRMLS_CC);
|
2000-11-11 18:24:27 +00:00
|
|
|
APR_ARRAY_FOREACH_CLOSE()
|
|
|
|
|
2001-07-28 11:36:37 +00:00
|
|
|
php_register_variable("PHP_SELF", ctx->f->r->uri, track_vars_array TSRMLS_CC);
|
2000-10-26 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
php_apache_sapi_flush(void *server_context)
|
|
|
|
{
|
|
|
|
php_struct *ctx = server_context;
|
2001-02-28 14:03:58 +00:00
|
|
|
apr_bucket_brigade *bb;
|
|
|
|
apr_bucket *b;
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2000-10-27 13:19:23 +00:00
|
|
|
/* Send a flush bucket down the filter chain. The current default
|
|
|
|
* handler seems to act on the first flush bucket, but ignores
|
|
|
|
* all further flush buckets.
|
|
|
|
*/
|
|
|
|
|
2001-02-28 14:03:58 +00:00
|
|
|
bb = apr_brigade_create(ctx->f->r->pool);
|
|
|
|
b = apr_bucket_flush_create();
|
2001-02-28 14:11:34 +00:00
|
|
|
APR_BRIGADE_INSERT_TAIL(bb, b);
|
2000-10-29 15:10:49 +00:00
|
|
|
if (ap_pass_brigade(ctx->f->next, bb) != APR_SUCCESS) {
|
2000-10-29 16:01:02 +00:00
|
|
|
php_handle_aborted_connection();
|
2000-10-29 15:10:49 +00:00
|
|
|
}
|
2000-10-27 13:19:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void php_apache_sapi_log_message(char *msg)
|
|
|
|
{
|
|
|
|
php_struct *ctx;
|
2001-07-28 11:36:37 +00:00
|
|
|
TSRMLS_FETCH();
|
2000-10-27 13:19:23 +00:00
|
|
|
|
|
|
|
ctx = SG(server_context);
|
2001-08-16 06:05:57 +00:00
|
|
|
|
|
|
|
/* We use APLOG_STARTUP because it keeps us from printing the
|
|
|
|
* data and time information at the beginning of the error log
|
|
|
|
* line. Not sure if this is correct, but it mirrors what happens
|
|
|
|
* with Apache 1.3 -- rbb
|
|
|
|
*/
|
|
|
|
ap_log_error(NULL, APLOG_ERR | APLOG_NOERRNO | APLOG_STARTUP, 0, ctx->f->r->server, "%s", msg);
|
2000-10-26 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2001-01-02 22:49:31 +00:00
|
|
|
static sapi_module_struct apache2_sapi_module = {
|
2000-10-26 17:55:05 +00:00
|
|
|
"apache2filter",
|
|
|
|
"Apache 2.0 Filter",
|
|
|
|
|
2001-08-03 05:05:47 +00:00
|
|
|
php_module_startup, /* startup */
|
2000-10-26 17:55:05 +00:00
|
|
|
php_module_shutdown_wrapper, /* shutdown */
|
|
|
|
|
2001-08-03 05:05:47 +00:00
|
|
|
NULL, /* activate */
|
|
|
|
NULL, /* deactivate */
|
2000-10-26 17:55:05 +00:00
|
|
|
|
|
|
|
php_apache_sapi_ub_write, /* unbuffered write */
|
2001-08-03 05:05:47 +00:00
|
|
|
php_apache_sapi_flush, /* flush */
|
|
|
|
NULL, /* get uid */
|
|
|
|
NULL, /* getenv */
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2001-08-03 05:05:47 +00:00
|
|
|
php_error, /* error handler */
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2001-08-03 05:05:47 +00:00
|
|
|
php_apache_sapi_header_handler, /* header handler */
|
|
|
|
php_apache_sapi_send_headers, /* send headers handler */
|
|
|
|
NULL, /* send header handler */
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2001-08-03 05:05:47 +00:00
|
|
|
php_apache_sapi_read_post, /* read POST data */
|
|
|
|
php_apache_sapi_read_cookies, /* read Cookies */
|
2000-10-26 17:55:05 +00:00
|
|
|
|
|
|
|
php_apache_sapi_register_variables,
|
2000-10-27 13:19:23 +00:00
|
|
|
php_apache_sapi_log_message, /* Log message */
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2001-08-03 05:05:47 +00:00
|
|
|
NULL, /* Block interruptions */
|
|
|
|
NULL, /* Unblock interruptions */
|
2000-10-26 17:55:05 +00:00
|
|
|
|
|
|
|
STANDARD_SAPI_MODULE_PROPERTIES
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-02-28 14:03:58 +00:00
|
|
|
AP_MODULE_DECLARE_DATA module php4_module;
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2000-10-29 14:52:15 +00:00
|
|
|
#define INIT_CTX \
|
|
|
|
if (ctx == NULL) { \
|
|
|
|
/* Initialize filter context */ \
|
2000-11-01 19:26:57 +00:00
|
|
|
SG(server_context) = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx)); \
|
2001-02-28 14:03:58 +00:00
|
|
|
ctx->bb = apr_brigade_create(f->c->pool); \
|
2000-10-29 14:52:15 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 14:03:58 +00:00
|
|
|
static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
|
2001-04-24 12:57:34 +00:00
|
|
|
ap_input_mode_t mode, apr_size_t *readbytes)
|
2000-10-29 14:52:15 +00:00
|
|
|
{
|
|
|
|
php_struct *ctx;
|
|
|
|
long old_index;
|
2001-02-28 14:03:58 +00:00
|
|
|
apr_bucket *b;
|
2000-10-29 14:52:15 +00:00
|
|
|
const char *str;
|
|
|
|
apr_ssize_t n;
|
2000-11-01 19:19:46 +00:00
|
|
|
apr_status_t rv;
|
2001-07-28 11:36:37 +00:00
|
|
|
TSRMLS_FETCH();
|
2000-10-29 14:52:15 +00:00
|
|
|
|
|
|
|
ctx = SG(server_context);
|
|
|
|
|
|
|
|
INIT_CTX;
|
|
|
|
|
2001-04-24 12:57:34 +00:00
|
|
|
if ((rv = ap_get_brigade(f->next, bb, mode, readbytes)) != APR_SUCCESS) {
|
2000-11-01 19:19:46 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-02-28 14:03:58 +00:00
|
|
|
APR_BRIGADE_FOREACH(b, bb) {
|
|
|
|
apr_bucket_read(b, &str, &n, 1);
|
2000-10-29 14:52:15 +00:00
|
|
|
if (n > 0) {
|
|
|
|
old_index = ctx->post_len;
|
|
|
|
ctx->post_len += n;
|
|
|
|
ctx->post_data = realloc(ctx->post_data, ctx->post_len + 1);
|
|
|
|
memcpy(ctx->post_data + old_index, str, n);
|
|
|
|
}
|
|
|
|
}
|
2000-11-01 19:19:46 +00:00
|
|
|
return APR_SUCCESS;
|
2000-10-29 14:52:15 +00:00
|
|
|
}
|
|
|
|
|
2001-07-28 11:36:37 +00:00
|
|
|
static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx TSRMLS_DC)
|
2000-11-11 18:24:27 +00:00
|
|
|
{
|
|
|
|
char *content_type;
|
|
|
|
const char *auth;
|
|
|
|
|
|
|
|
PG(during_request_startup) = 0;
|
|
|
|
SG(sapi_headers).http_response_code = 200;
|
|
|
|
SG(request_info).content_type = apr_table_get(f->r->headers_in, "Content-Type");
|
|
|
|
#undef safe_strdup
|
|
|
|
#define safe_strdup(x) ((x)?strdup((x)):NULL)
|
|
|
|
SG(request_info).query_string = safe_strdup(f->r->args);
|
|
|
|
SG(request_info).request_method = f->r->method;
|
|
|
|
SG(request_info).request_uri = safe_strdup(f->r->uri);
|
|
|
|
f->r->no_local_copy = 1;
|
2001-07-28 11:36:37 +00:00
|
|
|
content_type = sapi_get_default_content_type(TSRMLS_C);
|
2000-11-11 18:24:27 +00:00
|
|
|
f->r->content_type = apr_pstrdup(f->r->pool, content_type);
|
|
|
|
SG(request_info).post_data = ctx->post_data;
|
|
|
|
SG(request_info).post_data_length = ctx->post_len;
|
|
|
|
efree(content_type);
|
|
|
|
apr_table_unset(f->r->headers_out, "Content-Length");
|
|
|
|
apr_table_unset(f->r->headers_out, "Last-Modified");
|
|
|
|
apr_table_unset(f->r->headers_out, "Expires");
|
|
|
|
apr_table_unset(f->r->headers_out, "ETag");
|
|
|
|
apr_table_unset(f->r->headers_in, "Connection");
|
|
|
|
auth = apr_table_get(f->r->headers_in, "Authorization");
|
2001-07-28 11:36:37 +00:00
|
|
|
php_handle_auth_data(auth TSRMLS_CC);
|
2000-11-11 18:24:27 +00:00
|
|
|
|
2001-07-28 11:36:37 +00:00
|
|
|
php_request_startup(TSRMLS_C);
|
2000-11-11 18:24:27 +00:00
|
|
|
}
|
|
|
|
|
2001-07-28 11:36:37 +00:00
|
|
|
static void php_apache_request_dtor(ap_filter_t *f TSRMLS_DC)
|
2000-11-11 18:24:27 +00:00
|
|
|
{
|
|
|
|
php_request_shutdown(NULL);
|
|
|
|
|
|
|
|
#undef safe_free
|
|
|
|
#define safe_free(x) ((x)?free((x)):0)
|
|
|
|
safe_free(SG(request_info).query_string);
|
|
|
|
safe_free(SG(request_info).request_uri);
|
|
|
|
}
|
|
|
|
|
2001-02-28 14:03:58 +00:00
|
|
|
static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
|
2000-10-26 17:55:05 +00:00
|
|
|
{
|
2000-10-29 14:52:15 +00:00
|
|
|
php_struct *ctx;
|
2001-02-28 14:03:58 +00:00
|
|
|
apr_bucket *b;
|
2000-10-29 14:52:15 +00:00
|
|
|
void *conf = ap_get_module_config(f->r->per_dir_config, &php4_module);
|
2001-07-28 11:36:37 +00:00
|
|
|
TSRMLS_FETCH();
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2000-10-29 14:52:15 +00:00
|
|
|
ctx = SG(server_context);
|
|
|
|
INIT_CTX;
|
2000-10-26 17:55:05 +00:00
|
|
|
|
|
|
|
ctx->f = f;
|
2000-10-27 10:41:24 +00:00
|
|
|
|
|
|
|
/* states:
|
|
|
|
* 0: request startup
|
|
|
|
* 1: collecting data
|
|
|
|
* 2: script execution and request shutdown
|
|
|
|
*/
|
2000-10-26 17:55:05 +00:00
|
|
|
if (ctx->state == 0) {
|
|
|
|
|
|
|
|
apply_config(conf);
|
|
|
|
|
|
|
|
ctx->state++;
|
|
|
|
|
2001-07-28 11:36:37 +00:00
|
|
|
php_apache_request_ctor(f, ctx TSRMLS_CC);
|
2000-10-26 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2000-10-27 10:41:24 +00:00
|
|
|
/* moves all buckets from bb to ctx->bb */
|
2001-06-22 23:20:49 +00:00
|
|
|
ap_save_brigade(f, &ctx->bb, &bb, f->r->pool);
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2000-10-27 10:41:24 +00:00
|
|
|
/* If we have received all data from the previous filters,
|
|
|
|
* we "flatten" the buckets by creating a single string buffer.
|
|
|
|
*/
|
2001-02-28 14:11:34 +00:00
|
|
|
if (ctx->state == 1 && APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(ctx->bb))) {
|
2000-10-26 17:55:05 +00:00
|
|
|
zend_file_handle zfd;
|
2001-02-28 14:03:58 +00:00
|
|
|
apr_bucket *eos;
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2000-10-27 10:41:24 +00:00
|
|
|
/* We want to execute only one script per request.
|
|
|
|
* A bug in Apache or other filters could cause us
|
|
|
|
* to reenter php_filter during script execution, so
|
|
|
|
* we protect ourselves here.
|
|
|
|
*/
|
2000-10-26 17:55:05 +00:00
|
|
|
ctx->state = 2;
|
2000-10-26 21:23:20 +00:00
|
|
|
|
2000-10-27 10:41:24 +00:00
|
|
|
/* Handle phpinfo/phpcredits/built-in images */
|
2001-07-28 11:36:37 +00:00
|
|
|
if (!php_handle_special_queries(TSRMLS_C)) {
|
2001-07-23 04:50:13 +00:00
|
|
|
|
|
|
|
b = APR_BRIGADE_FIRST(ctx->bb);
|
|
|
|
|
|
|
|
if (APR_BUCKET_IS_FILE(b)) {
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
apr_file_name_get(&path, ((apr_bucket_file *) b->data)->fd);
|
|
|
|
|
|
|
|
zfd.type = ZEND_HANDLE_FILENAME;
|
|
|
|
zfd.filename = (char *) path;
|
|
|
|
zfd.free_filename = 0;
|
|
|
|
zfd.opened_path = NULL;
|
|
|
|
|
2001-07-28 11:36:37 +00:00
|
|
|
php_execute_script(&zfd TSRMLS_CC);
|
2001-07-23 04:50:13 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
#define NO_DATA "The PHP Filter did not receive suitable input data"
|
|
|
|
|
|
|
|
eos = apr_bucket_transient_create(NO_DATA, sizeof(NO_DATA)-1);
|
|
|
|
APR_BRIGADE_INSERT_HEAD(bb, eos);
|
|
|
|
}
|
2000-10-26 17:55:05 +00:00
|
|
|
}
|
2000-10-27 10:41:24 +00:00
|
|
|
|
2001-07-28 11:36:37 +00:00
|
|
|
php_apache_request_dtor(f TSRMLS_CC);
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2000-10-29 14:52:15 +00:00
|
|
|
SG(server_context) = 0;
|
2000-10-27 10:41:24 +00:00
|
|
|
/* Pass EOS bucket to next filter to signal end of request */
|
2001-02-28 14:03:58 +00:00
|
|
|
eos = apr_bucket_eos_create();
|
2001-02-28 14:11:34 +00:00
|
|
|
APR_BRIGADE_INSERT_TAIL(bb, eos);
|
2000-10-29 14:52:15 +00:00
|
|
|
|
|
|
|
return ap_pass_brigade(f->next, bb);
|
2000-10-27 13:30:41 +00:00
|
|
|
} else
|
2001-02-28 14:11:34 +00:00
|
|
|
apr_brigade_destroy(bb);
|
2000-10-26 17:55:05 +00:00
|
|
|
|
|
|
|
return APR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static apr_status_t
|
|
|
|
php_apache_server_shutdown(void *tmp)
|
|
|
|
{
|
2001-01-02 22:49:31 +00:00
|
|
|
apache2_sapi_module.shutdown(&apache2_sapi_module);
|
2000-10-26 17:55:05 +00:00
|
|
|
sapi_shutdown();
|
|
|
|
tsrm_shutdown();
|
|
|
|
return APR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
php_apache_server_startup(apr_pool_t *pchild, server_rec *s)
|
|
|
|
{
|
2000-11-18 02:44:04 +00:00
|
|
|
tsrm_startup(1, 1, 0, NULL);
|
2001-01-08 23:18:47 +00:00
|
|
|
sapi_startup(&apache2_sapi_module);
|
2001-01-02 22:49:31 +00:00
|
|
|
apache2_sapi_module.startup(&apache2_sapi_module);
|
2001-02-28 14:11:34 +00:00
|
|
|
apr_pool_cleanup_register(pchild, NULL, php_apache_server_shutdown, NULL);
|
2000-11-11 18:24:27 +00:00
|
|
|
php_apache_register_module();
|
2000-10-26 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 14:03:58 +00:00
|
|
|
static void php_register_hook(apr_pool_t *p)
|
2000-10-26 17:55:05 +00:00
|
|
|
{
|
2001-02-28 14:03:58 +00:00
|
|
|
ap_hook_child_init(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);
|
2000-11-01 19:19:46 +00:00
|
|
|
ap_register_output_filter("PHP", php_output_filter, AP_FTYPE_CONTENT);
|
|
|
|
ap_register_input_filter("PHP", php_input_filter, AP_FTYPE_CONTENT);
|
2000-10-26 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 14:03:58 +00:00
|
|
|
AP_MODULE_DECLARE_DATA module php4_module = {
|
2000-10-26 17:55:05 +00:00
|
|
|
STANDARD20_MODULE_STUFF,
|
|
|
|
create_php_config, /* create per-directory config structure */
|
2001-08-03 05:05:47 +00:00
|
|
|
merge_php_config, /* merge per-directory config structures */
|
|
|
|
NULL, /* create per-server config structure */
|
|
|
|
NULL, /* merge per-server config structures */
|
|
|
|
php_dir_cmds, /* command apr_table_t */
|
|
|
|
php_register_hook /* register hooks */
|
2000-10-26 17:55:05 +00:00
|
|
|
};
|