]> granicus.if.org Git - php/commitdiff
automatically add php input/output filters when give the standard 1.x config:
authorDoug MacEachern <dougm@php.net>
Mon, 20 Aug 2001 16:34:45 +0000 (16:34 +0000)
committerDoug MacEachern <dougm@php.net>
Mon, 20 Aug 2001 16:34:45 +0000 (16:34 +0000)
     AddType application/x-httpd-php .php
with that, no longer need "Set{In,Out}putFilter PHP" configuration for 2.0

sapi/apache2filter/sapi_apache2.c

index 89003f8a9e9f864951941e25048b2f1351962f51..63f07f69687e51252e95805f60c38f0e975fb441 100644 (file)
@@ -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);
 }