cvs: php4 /sapi/apache2filter sapi_apache2.c
| From: | Doug MacEachern | Date: | Mon, 20 Aug 2001 16:34:46 +0000 |
| Subject: | cvs: php4 /sapi/apache2filter sapi_apache2.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6983@lists.php.net to get a copy of this message | ||
dougm Mon Aug 20 12:34:46 2001 EDT
Modified files:
/php4/sapi/apache2filter sapi_apache2.c
Log:
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
Index: php4/sapi/apache2filter/sapi_apache2.c
diff -u php4/sapi/apache2filter/sapi_apache2.c:1.48 php4/sapi/apache2filter/sapi_apache2.c:1.49
--- php4/sapi/apache2filter/sapi_apache2.c:1.48 Sun Aug 19 17:07:50 2001
+++ php4/sapi/apache2filter/sapi_apache2.c Mon Aug 20 12:34:45 2001
@@ -417,9 +417,43 @@
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);
}