]> granicus.if.org Git - php/commitdiff
@ - Added php.ini option "allow_webdav_methods" to allow handling of
authorChristian Stocker <chregu@php.net>
Thu, 22 Aug 2002 07:48:23 +0000 (07:48 +0000)
committerChristian Stocker <chregu@php.net>
Thu, 22 Aug 2002 07:48:23 +0000 (07:48 +0000)
@   WebDAV http requests within PHP scripts. (chregu)
# More methods (for DeltaV) will follow.

main/SAPI.c
main/main.c
main/php_globals.h
sapi/apache/mod_php4.c

index 054d35dce242e58b70177dcc50425958d1a8c447..ab83ca0079c1eeb9b482a9f294f4f7ee4f6305d0 100644 (file)
@@ -306,8 +306,16 @@ SAPI_API void sapi_activate(TSRMLS_D)
        SG(rfc1867_uploaded_files) = NULL;
 
        if (SG(server_context)) {
-               if (SG(request_info).request_method 
-                       && !strcmp(SG(request_info).request_method, "POST")) {
+               if ( SG(request_info).request_method 
+                       &&  (!strcmp(SG(request_info).request_method, "POST")
+                               || (PG(allow_webdav_methods) 
+                                       && (!strcmp(SG(request_info).request_method, "PROPFIND")
+                                       || !strcmp(SG(request_info).request_method, "PROPPATCH")                                
+                                       || !strcmp(SG(request_info).request_method, "PUT")
+                                       || !strcmp(SG(request_info).request_method, "MOVE")
+                                       || !strcmp(SG(request_info).request_method, "POST")
+                                       || !strcmp(SG(request_info).request_method, "COPY")
+                                       || !strcmp(SG(request_info).request_method, "LOCK"))))) {
                        if (!SG(request_info).content_type) {
                                SG(request_info).content_type_dup = NULL;
                                if(PG(always_populate_raw_post_data)) {
index 311b7ba1a5b7353cff04570ef2c7a4e7d09694f1..446e94786a372f713f12100caa707467da2deeb3 100644 (file)
@@ -326,6 +326,7 @@ PHP_INI_BEGIN()
 
        STD_PHP_INI_BOOLEAN("allow_url_fopen",          "1",            PHP_INI_ALL,            OnUpdateBool,                   allow_url_fopen,                        php_core_globals,       core_globals)
        STD_PHP_INI_BOOLEAN("always_populate_raw_post_data",            "0",            PHP_INI_SYSTEM|PHP_INI_PERDIR,          OnUpdateBool,                   always_populate_raw_post_data,                  php_core_globals,       core_globals)
+       STD_PHP_INI_BOOLEAN("allow_webdav_methods",             "0",                            PHP_INI_SYSTEM|PHP_INI_PERDIR,          OnUpdateBool,                   allow_webdav_methods,                   php_core_globals,       core_globals)
 
 PHP_INI_END()
 /* }}} */
index 10639de0a1644cee9f6fc097f2b6a2531a8d3dfe..4f8755aa4b0d5f8940e7e211bdee28914dcb0968 100644 (file)
@@ -139,7 +139,8 @@ struct _php_core_globals {
        zend_bool allow_url_fopen;
 
        zend_bool always_populate_raw_post_data;
-
+       
+       zend_bool allow_webdav_methods;
 };
 
 
index dc0500da586761919f043d7a0e359b1e97e81c9e..26573a6065741dc96c824f25b15f4ba5bb6ba9d0 100644 (file)
@@ -488,11 +488,6 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
        }
 
        zend_first_try {
-               /* We don't accept OPTIONS requests, but take everything else */
-               if (r->method_number == M_OPTIONS) {
-                       r->allowed |= (1 << METHODS) - 1;
-                       return DECLINED;
-               }
 
                /* Make sure file exists */
                if (filename == NULL && r->finfo.st_mode == 0) {
@@ -503,6 +498,14 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
                if (per_dir_conf) {
                        zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
                }
+               
+               /* We don't accept OPTIONS requests, but take everything else */
+               if (!PG(allow_webdav_methods)) {
+                               if (r->method_number == M_OPTIONS) {
+                                       r->allowed |= (1 << METHODS) - 1;
+                               return DECLINED;
+                       }
+               }
 
                /* If PHP parser engine has been turned off with an "engine off"
                 * directive, then decline to handle this request