summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug MacEachern <dougm@php.net>2001-08-20 16:34:45 +0000
committerDoug MacEachern <dougm@php.net>2001-08-20 16:34:45 +0000
commit9b137805c8014b80425ed695095b07e5edb5836b (patch)
tree064f636622edd346028b0394e5f22764b449cfe4
parent01672af8f03ff7a301cf95b2903de42220805dcb (diff)
downloadphp-git-9b137805c8014b80425ed695095b07e5edb5836b.tar.gz
automatically add php input/output filters when give the standard 1.x config:
AddType application/x-httpd-php .php with that, no longer need "Set{In,Out}putFilter PHP" configuration for 2.0
-rw-r--r--sapi/apache2filter/sapi_apache2.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c
index 89003f8a9e..63f07f6968 100644
--- a/sapi/apache2filter/sapi_apache2.c
+++ b/sapi/apache2filter/sapi_apache2.c
@@ -417,9 +417,43 @@ php_apache_server_startup(apr_pool_t *pchild, server_rec *s)
php_apache_register_module();
}
+static void php_add_filter(request_rec *r, ap_filter_t *f)
+{
+ int output = (f == r->output_filters);
+
+ /* for those who still have Set*Filter PHP configured */
+ while (f) {
+ if (strcmp(f->frec->name, "PHP") == 0) {
+ ap_log_error(APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO,
+ 0, r->server,
+ "\"Set%sFilter PHP\" already configured for %s",
+ output ? "Output" : "Input", r->uri);
+ return;
+ }
+ f = f->next;
+ }
+
+ if (output) {
+ ap_add_output_filter("PHP", NULL, r, r->connection);
+ }
+ else {
+ ap_add_input_filter("PHP", NULL, r, r->connection);
+ }
+}
+
+static void php_insert_filter(request_rec *r)
+{
+ if (r->content_type &&
+ strcmp(r->content_type, "application/x-httpd-php") == 0) {
+ php_add_filter(r, r->output_filters);
+ php_add_filter(r, r->input_filters);
+ }
+}
+
static void php_register_hook(apr_pool_t *p)
{
ap_hook_child_init(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_insert_filter(php_insert_filter, NULL, NULL, APR_HOOK_MIDDLE);
ap_register_output_filter("PHP", php_output_filter, AP_FTYPE_CONTENT);
ap_register_input_filter("PHP", php_input_filter, AP_FTYPE_CONTENT);
}