Hi all, this is a 'request_handler'-support patch for php. it applies to php-4.1.1 and it only covers sapi/apache/... 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 your /www/foo.php script AFAIC, it's currently quite limited OS wise. if it works under e.g. windows at all, one has to specify an absolute path to the request_handler-file, at least... the patch below can also be downloaded from http://www.azzit.de/patches/php-4.1.1-request_handler-20020111.diff Comments, bug reports, suggestions are welcome, regards, -lukas --- sapi/apache/mod_php4.c.orig Sun Sep 16 17:49:55 2001 +++ sapi/apache/mod_php4.c Sat Jan 12 00:12:09 2002 @@ -483,6 +483,40 @@ } /* }}} */ +/* {{{ 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 +536,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 +883,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 +942,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, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]