]> granicus.if.org Git - php/commitdiff
- Implemented is_upload_file()
authorZeev Suraski <zeev@php.net>
Fri, 8 Sep 2000 21:56:47 +0000 (21:56 +0000)
committerZeev Suraski <zeev@php.net>
Fri, 8 Sep 2000 21:56:47 +0000 (21:56 +0000)
ext/standard/basic_functions.c
ext/standard/basic_functions.h
main/SAPI.c
main/SAPI.h
main/rfc1867.c

index 02101d60f7efc175bd4bad7a9797c674892e51ea..77374bdeed5f8233730ff7eaeaab254336e372d1 100644 (file)
@@ -356,6 +356,8 @@ function_entry basic_functions[] = {
 
        PHP_FE(parse_ini_file,                          NULL)
 
+       PHP_FE(is_upload_file,                          NULL)
+
        /* functions from reg.c */
        PHP_FE(ereg,                                                                    third_argument_force_ref)
        PHP_FE(ereg_replace,                                                    NULL)
@@ -2205,6 +2207,27 @@ PHPAPI PHP_FUNCTION(warn_not_available)
 }
 
 
+PHP_FUNCTION(is_upload_file)
+{
+       zval **path;
+       SLS_FETCH();
+
+       if (!SG(rfc1867_uploaded_files)) {
+               RETURN_FALSE;
+       }
+
+       if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &path)!=SUCCESS) {
+               ZEND_WRONG_PARAM_COUNT();
+       }
+       convert_to_string_ex(path);
+
+       if (zend_hash_exists(SG(rfc1867_uploaded_files), Z_STRVAL_PP(path), Z_STRLEN_PP(path)+1)) {
+               RETURN_TRUE;
+       } else {
+               RETURN_FALSE;
+       }
+}
+
 /*
  * Local variables:
  * tab-width: 4
index bf9e1b8dcd9d749ea544370c769b166896ccfa76..e705a6de2a254fa8e4cbe4d47f61b38c10118759 100644 (file)
@@ -109,6 +109,8 @@ PHP_FUNCTION(get_extension_funcs);
 PHP_FUNCTION(register_tick_function);
 PHP_FUNCTION(unregister_tick_function);
 
+PHP_FUNCTION(is_upload_file);
+
 /* From the INI parser */
 PHP_FUNCTION(parse_ini_file);
 
index 8e838c526e350ef10928b5ecdd2e9923b7067b8d..cee1f77876fafd74e6a9f043486889762f0bb2b3 100644 (file)
@@ -301,6 +301,7 @@ SAPI_API void sapi_activate(SLS_D)
                        sapi_module.activate(SLS_C);
                }
        }
+       SG(rfc1867_uploaded_files) = NULL;
 }
 
 
@@ -325,6 +326,10 @@ SAPI_API void sapi_deactivate(SLS_D)
        if (sapi_module.deactivate) {
                sapi_module.deactivate(SLS_C);
        }
+       if (SG(rfc1867_uploaded_files)) {
+               zend_hash_destroy(SG(rfc1867_uploaded_files));
+               FREE_HASHTABLE(SG(rfc1867_uploaded_files));
+       }
 }
 
 
index 18fcbbff66b128dec0f1431673df58373b22e5fd..d1cef23f7b00304683e8b2867bc5347384a6406a 100644 (file)
@@ -100,7 +100,7 @@ typedef struct {
        struct stat global_stat;
        char *default_mimetype;
        char *default_charset;
-       HashTable *rfc_1867_uploaded_files;
+       HashTable *rfc1867_uploaded_files;
 } sapi_globals_struct;
 
 
index bdff72a2b6082f9f704790ed06f9d940416f5daa..68af24557c3d2da2b4827c1f1b6ad62c9e3b301d 100644 (file)
@@ -86,7 +86,7 @@ static void register_http_post_files_variable_ex(char *var, zval *val, zval *htt
 /*
  * Split raw mime stream up into appropriate components
  */
-static void php_mime_split(char *buf, int cnt, char *boundary, zval *array_ptr)
+static void php_mime_split(char *buf, int cnt, char *boundary, zval *array_ptr SLS_DC)
 {
        char *ptr, *loc, *loc2, *loc3, *s, *name, *filename, *u, *fn;
        int len, state = 0, Done = 0, rem, urem;
@@ -102,6 +102,9 @@ static void php_mime_split(char *buf, int cnt, char *boundary, zval *array_ptr)
 
        zend_hash_init(&PG(rfc1867_protected_variables), 5, NULL, NULL, 0);
 
+       ALLOC_HASHTABLE(SG(rfc1867_uploaded_files));
+       zend_hash_init(SG(rfc1867_uploaded_files), 5, NULL, NULL, 0);
+
        ALLOC_ZVAL(http_post_files);
        array_init(http_post_files);
        INIT_PZVAL(http_post_files);
@@ -348,6 +351,11 @@ static void php_mime_split(char *buf, int cnt, char *boundary, zval *array_ptr)
                                }
                                add_protected_variable(namebuf PLS_CC);
                                safe_php_register_variable(namebuf, fn, NULL, 1 ELS_CC PLS_CC);
+                               {
+                                       int dummy=1;
+
+                                       zend_hash_add(SG(rfc1867_uploaded_files), namebuf, strlen(namebuf)+1, &dummy, sizeof(int), NULL);
+                               }
 
                                /* Add $foo[tmp_name] */
                                if(is_arr_upload) {
@@ -404,7 +412,7 @@ SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
        boundary_len = strlen(boundary);
 
        if (SG(request_info).post_data) {
-               php_mime_split(SG(request_info).post_data, SG(request_info).post_data_length, boundary, array_ptr);
+               php_mime_split(SG(request_info).post_data, SG(request_info).post_data_length, boundary, array_ptr SLS_CC);
        }
 }