mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
- Implemented is_upload_file()
This commit is contained in:
parent
9a4c654606
commit
75086e3088
5 changed files with 41 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue