Hi, (resubmitting. i submitted this on Jan 12 before, but did not get any response.)
this is a 'request_handler'-support patch for php. it applies to php-4.1.1. it only covers sapi/apache/... diffstat says mod_php4.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 57 insertions(+), 1 deletion(-) with this patch applied you can use the following to register a request_handler: php_value request_handler /www/foo.php every request going to a virtualhost / directory / location that a request_handler is registered for will be passed to that /www/foo.php script the attached patch can also be downloaded from http://www.azzit.de/patches/php4/ [it's the *request_handler* file there. duh. ;-)] Comments, bug reports, suggestions are welcome, regards, -lukas
--- php-4.1.1/sapi/apache/mod_php4.c.orig Tue Feb 12 00:05:35 2002 +++ php-4.1.1/sapi/apache/mod_php4.c Wed Feb 13 02:57:13 2002 @@ -483,6 +483,39 @@ } /* }}} */ +/* {{{ php_get_request_handler + */ +static int php_get_request_handler(request_rec *r, char **target) +{ + HashTable *per_dir_conf; + php_per_dir_entry *per_dir_entry; + char *filename; + + if (!(per_dir_conf = get_module_config(r->per_dir_config, &php4_module))) + return 0; + + if (zend_hash_find(per_dir_conf, "request_handler", +sizeof("request_handler")-1, + (void **)&per_dir_entry) == SUCCESS) { + + if (!ap_os_is_path_absolute(per_dir_entry->value)) { + char *dirnam = ap_pstrdup(r->pool, r->filename); + char *x = strrchr(dirnam, '/'); + + if (x != NULL) + *x = 0; + filename = ap_make_full_path(r->pool, dirnam, +per_dir_entry->value); + } + else + filename = ap_pstrdup(r->pool, per_dir_entry->value); + + *target = filename; + return 1; + } + + return 0; +} +/* }}} */ + /* {{{ send_php */ static int send_php(request_rec *r, int display_source_mode, char *filename) @@ -502,6 +535,9 @@ return OK; } + if (php_get_request_handler(r, &filename)) + r->filename = filename; + zend_first_try { /* We don't accept OPTIONS requests, but take everything else */ if (r->method_number == M_OPTIONS) { @@ -846,6 +882,26 @@ } /* }}} */ +/* {{{ php_type_checker + */ +static int php_type_checker(request_rec *r) +{ + char *filename; + + /* if a request_handler has been registered, the type checker tells + * apache to invoke our send_php handler; otherwise we deny responsibility + * for this request + */ + + if (php_get_request_handler(r, &filename)) { + r->handler = "application/x-httpd-php"; + return OK; + } + + return DECLINED; +} +/* }}} */ + /* {{{ handler_rec php_handlers[] */ handler_rec php_handlers[] = @@ -885,7 +941,7 @@ NULL, /* check_user_id */ NULL, /* check auth */ NULL, /* check access */ - NULL, /* type_checker */ + php_type_checker, /* type_checker */ NULL, /* fixups */ NULL /* logger */ #if MODULE_MAGIC_NUMBER >= 19970103
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php