CVS update: php3
| From: | ssb | Date: | Fri, 04 Dec 1998 16:42:37 +0000 |
| Subject: | CVS update: php3 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-2663@lists.php.net to get a copy of this message | ||
Date: Friday December 4, 1998 @ 11:42
Author: ssb
Update of /repository/php3
In directory asf:/u/temp/cvs-serv23255
Modified Files:
mod_php3.c
Log Message:
first attempt at hooking mod_php3 into mod_dav
Index: php3/mod_php3.c
diff -c php3/mod_php3.c:1.84 php3/mod_php3.c:1.85
*** php3/mod_php3.c:1.84 Mon Nov 2 10:16:56 1998
--- php3/mod_php3.c Fri Dec 4 11:42:35 1998
***************
*** 27,33 ****
| (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
+----------------------------------------------------------------------+
*/
! /* $Id: mod_php3.c,v 1.84 1998/11/02 15:16:56 rasmus Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
--- 27,33 ----
| (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
+----------------------------------------------------------------------+
*/
! /* $Id: mod_php3.c,v 1.85 1998/12/04 16:42:35 ssb Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
***************
*** 53,59 ****
--- 53,65 ----
#include "php_version.h"
#include "mod_php3.h"
+ #if HAVE_MOD_DAV
+ # include "mod_dav.h"
+ #endif
+ /* ### these should be defined in mod_php3.h or somewhere else */
+ #define USE_PATH 1
+ #define IGNORE_URL 2
module MODULE_VAR_EXPORT php3_module;
***************
*** 78,84 ****
extern php3_ini_structure php3_ini; /* active config */
extern php3_ini_structure php3_ini_master; /* master copy of config */
! extern int apache_php3_module_main(request_rec * r, int fd, int display_source_mode, int
preprocessed);
extern int php3_module_startup();
extern void php3_module_shutdown();
extern void php3_module_shutdown_for_exec();
--- 84,90 ----
extern php3_ini_structure php3_ini; /* active config */
extern php3_ini_structure php3_ini_master; /* master copy of config */
! extern int apache_php3_module_main(request_rec *, int, int, int, FILE *);
extern int php3_module_startup();
extern void php3_module_shutdown();
extern void php3_module_shutdown_for_exec();
***************
*** 160,166 ****
int fd, retval;
php3_ini_structure *conf;
! /* We don't aacept OPTIONS requests, but take everything else */
if (r->method_number == M_OPTIONS) {
r->allowed |= (1 << METHODS) - 1;
return DECLINED;
--- 166,172 ----
int fd, retval;
php3_ini_structure *conf;
! /* We don't accept OPTIONS requests, but take everything else */
if (r->method_number == M_OPTIONS) {
r->allowed |= (1 << METHODS) - 1;
return DECLINED;
***************
*** 171,182 ****
return NOT_FOUND;
/* grab configuration settings */
! conf = (php3_ini_structure *) get_module_config(r->per_dir_config, &php3_module);
! memcpy(&php3_ini,conf,sizeof(php3_ini_structure)); /* copy to active configuration */
! /*
! * If PHP parser engine has been turned off with the phpEngine off directive,
! * then decline to handle this request
*/
if (!conf->engine) {
r->content_type = "text/html";
--- 177,189 ----
return NOT_FOUND;
/* grab configuration settings */
! conf = (php3_ini_structure *) get_module_config(r->per_dir_config,
! &php3_module);
! /* copy to active configuration */
! memcpy(&php3_ini,conf,sizeof(php3_ini_structure));
! /* If PHP parser engine has been turned off with a "php3_engine off"
! * directive, then decline to handle this request
*/
if (!conf->engine) {
r->content_type = "text/html";
***************
*** 221,227 ****
chdir_file(r->filename);
add_common_vars(r);
add_cgi_vars(r);
! apache_php3_module_main(r, fd, display_source_mode, preprocessed);
/* Done, restore umask, turn off timeout, close file and return */
php3_restore_umask();
--- 228,234 ----
chdir_file(r->filename);
add_common_vars(r);
add_cgi_vars(r);
! apache_php3_module_main(r, fd, display_source_mode, preprocessed, NULL);
/* Done, restore umask, turn off timeout, close file and return */
php3_restore_umask();
***************
*** 250,255 ****
--- 257,338 ----
return send_php3(r, 1, 0);
}
+ #if HAVE_MOD_DAV
+ /* Based on the code in send_php3().
+ * Removed all the MODULE_MAGIC_NUMER checks from send_php3() since
+ * mod_dav is written for 1.3.
+ */
+ int send_dav_handling_php3(request_rec *r)
+ {
+ int retval;
+ FILE *fp;
+ /* ### this declaration should be somewhere else */
+ FILE *php3_fopen_wrapper(char *, char *, int, int *, int *);
+ php3_ini_structure *conf;
+
+ /* mod_dav has already checked that we're using a valid method,
+ * so there is no need to check it here
+ */
+
+ /* grab configuration settings */
+ conf = (php3_ini_structure *) get_module_config(r->per_dir_config,
+ &php3_module);
+ /* copy to active configuration */
+ memcpy(&php3_ini,conf,sizeof(php3_ini_structure));
+
+ /* the "php3_engine" directive is ignored for DAV requests */
+
+ /* open the handler script file */
+ if (conf->dav_handler_file) {
+ fp = php3_fopen_wrapper(conf->dav_handler_file, "r",
+ USE_PATH|IGNORE_URL, NULL, NULL);
+ } else {
+ const char *m =
+ ap_psprintf(r->pool,
+ "No DAV handler script defined! Please set one "
+ "with the php3_dav_handler_file directive.");
+ return dav_api_error_response(r, HTTP_INTERNAL_SERVER_ERROR, NULL, m);
+ }
+ if (fp == NULL) {
+ const char *m =
+ ap_psprintf(r->pool,
+ "Unable to open DAV handler script \"%s\".");
+ return dav_api_error_response(r, HTTP_INTERNAL_SERVER_ERROR, NULL, m);
+ }
+
+ if ((retval = setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
+ return retval;
+ }
+
+ if (conf->last_modified) {
+ update_mtime(r, r->finfo.st_mtime);
+ set_last_modified(r);
+ set_etag(r);
+ }
+ /* DAV response bodies are in XML by default */
+ r->content_type = "text/xml";
+
+ /* Init timeout */
+ hard_timeout("send", r);
+
+ php3_save_umask();
+ /* not doing chmod() here, the URI is not necessarily represented
+ * in the filesystem
+ */
+ add_common_vars(r);
+ add_cgi_vars(r);
+ apache_php3_module_main(r, 0, 0, 0, fp);
+
+ /* Done, restore umask, turn off timeout, close file and return */
+ php3_restore_umask();
+ kill_timeout(r);
+
+ fclose(fp);
+
+ return OK;
+ }
+ #endif /* HAVE_MOD_DAV */
+
/*
* Create the per-directory config structure with defaults from php3_ini_master
*/
***************
*** 323,328 ****
--- 406,413 ----
if (add->open_basedir != orig.open_basedir) new->open_basedir = add->open_basedir;
if (add->enable_dl != orig.enable_dl) new->enable_dl = add->enable_dl;
if (add->asp_tags != orig.asp_tags) new->asp_tags = add->asp_tags;
+ if (add->enable_dav != orig.enable_dav) new->enable_dav = add->enable_dav;
+ if (add->dav_handler_file != orig.dav_handler_file) new->dav_handler_file =
add->dav_handler_file;
return new;
}
***************
*** 382,387 ****
--- 467,475 ----
case 14:
conf->asp_tags = val;
break;
+ case 15:
+ conf->enable_dav = val;
+ break;
}
return NULL;
}
***************
*** 464,469 ****
--- 552,560 ----
case 19:
conf->upload_max_filesize = atol(arg);
break;
+ case 20:
+ conf->dav_handler_file = pstrdup(cmd->pool, arg);
+ break;
}
return NULL;
}
***************
*** 492,497 ****
--- 583,626 ----
#endif
}
+
+ #if HAVE_MOD_DAV
+ int php3_dav_method_handler(char *method,
+ table *headers_in,
+ dav_xml_doc *body)
+ {
+ return DONE;
+ }
+
+ int php3_dav_mkcol_test(request_rec *r)
+ {
+ return DONE;
+ }
+
+ int php3_dav_mkcol_create(request_rec *r)
+ {
+ return DONE;
+ }
+
+ static int php3_type_checker(request_rec *r)
+ {
+ php3_ini_structure *conf;
+
+ conf = (php3_ini_structure *)get_module_config(r->per_dir_config,
+ &php3_module);
+
+ /* If DAV support is enabled, use mod_dav's type checker. */
+ if (conf->enable_dav) {
+ dav_api_set_request_handler(r, send_dav_handling_php3);
+ dav_api_set_mkcol_handlers(r, php3_dav_mkcol_test, php3_dav_mkcol_create);
+ return dav_api_type_checker(r);
+ }
+
+ return DECLINED;
+ }
+ #endif
+
+
handler_rec php3_handlers[] =
{
{"application/x-httpd-php3", send_parsed_php3},
***************
*** 524,529 ****
--- 653,660 ----
{"php3_error_append_string", php3take1handler, (void *)17, OR_OPTIONS, TAKE1,
"String to add after an error message from PHP"},
{"php3_open_basedir", php3take1handler, (void *)18, OR_OPTIONS|RSRC_CONF, TAKE1,
"Limit opening of files to this directory"},
{"php3_upload_max_filesize", php3take1handler, (void *)19, OR_OPTIONS|RSRC_CONF, TAKE1,
"Limit uploaded files to this many bytes"},
+ {"php3_dav_handler_file", php3take1handler, (void *)20, OR_OPTIONS|RSRC_CONF, TAKE1,
+ "File that is included to set up DAV request handling."},
{"php3_track_errors", php3flaghandler, (void *)0, OR_OPTIONS, FLAG,
"on|off"},
{"php3_magic_quotes_gpc", php3flaghandler, (void *)1, OR_OPTIONS, FLAG,
"on|off"},
***************
*** 540,545 ****
--- 671,678 ----
{"php3_magic_quotes_sybase", php3flaghandler, (void *)12, OR_OPTIONS, FLAG,
"on|off"},
{"php3_enable_dl", php3flaghandler, (void *)13, RSRC_CONF|ACCESS_CONF, FLAG,
"on|off"},
{"php3_asp_tags", php3flaghandler, (void *)14, OR_OPTIONS, FLAG, "on|off"},
+ {"php3_enable_dav", php3flaghandler, (void *)15, ACCESS_CONF, FLAG,
+ "Lets PHP handle DAV requests through mod_dav. on|off"},
{NULL}
};
***************
*** 559,565 ****
--- 692,702 ----
NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
+ #if HAVE_MOD_DAV
+ php3_type_checker, /* type_checker */
+ #else
NULL, /* type_checker */
+ #endif
NULL, /* fixups */
NULL /* logger */
#if MODULE_MAGIC_NUMBER >= 19970103
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net