cvs: php4 /ext/standard basic_functions.c basic_functions.h /main SAPI.c SAPI.h rfc1867.c
| From: | Zeev Suraski | Date: | Fri, 08 Sep 2000 21:56:47 +0000 |
| Subject: | cvs: php4 /ext/standard basic_functions.c basic_functions.h /main SAPI.c SAPI.h rfc1867.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1639@lists.php.net to get a copy of this message | ||
zeev Fri Sep 8 14:56:47 2000 EDT
Modified files:
/php4/ext/standard basic_functions.c basic_functions.h
/php4/main SAPI.c SAPI.h rfc1867.c
Log:
- Implemented is_upload_file()
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.249 php4/ext/standard/basic_functions.c:1.250
--- php4/ext/standard/basic_functions.c:1.249 Tue Sep 5 11:33:02 2000
+++ php4/ext/standard/basic_functions.c Fri Sep 8 14:56:46 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.249 2000/09/05 18:33:02 stas Exp $ */
+/* $Id: basic_functions.c,v 1.250 2000/09/08 21:56:46 zeev Exp $ */
#include "php.h"
#include "php_main.h"
@@ -356,6 +356,8 @@
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)
@@ -2204,6 +2206,27 @@
RETURN_FALSE;
}
+
+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:
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.62 php4/ext/standard/basic_functions.h:1.63
--- php4/ext/standard/basic_functions.h:1.62 Mon Sep 4 15:21:10 2000
+++ php4/ext/standard/basic_functions.h Fri Sep 8 14:56:46 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.h,v 1.62 2000/09/04 22:21:10 sterling Exp $ */
+/* $Id: basic_functions.h,v 1.63 2000/09/08 21:56:46 zeev Exp $ */
#ifndef BASIC_FUNCTIONS_H
#define BASIC_FUNCTIONS_H
@@ -108,6 +108,8 @@
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: php4/main/SAPI.c
diff -u php4/main/SAPI.c:1.88 php4/main/SAPI.c:1.89
--- php4/main/SAPI.c:1.88 Fri Sep 8 07:43:54 2000
+++ php4/main/SAPI.c Fri Sep 8 14:56:47 2000
@@ -301,6 +301,7 @@
sapi_module.activate(SLS_C);
}
}
+ SG(rfc1867_uploaded_files) = NULL;
}
@@ -324,6 +325,10 @@
}
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: php4/main/SAPI.h
diff -u php4/main/SAPI.h:1.51 php4/main/SAPI.h:1.52
--- php4/main/SAPI.h:1.51 Fri Sep 8 07:43:54 2000
+++ php4/main/SAPI.h Fri Sep 8 14:56:47 2000
@@ -100,7 +100,7 @@
struct stat global_stat;
char *default_mimetype;
char *default_charset;
- HashTable *rfc_1867_uploaded_files;
+ HashTable *rfc1867_uploaded_files;
} sapi_globals_struct;
Index: php4/main/rfc1867.c
diff -u php4/main/rfc1867.c:1.47 php4/main/rfc1867.c:1.48
--- php4/main/rfc1867.c:1.47 Wed Sep 6 21:12:31 2000
+++ php4/main/rfc1867.c Fri Sep 8 14:56:47 2000
@@ -15,7 +15,7 @@
| Authors: Rasmus Lerdorf <rasmus@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: rfc1867.c,v 1.47 2000/09/07 04:12:31 zeev Exp $ */
+/* $Id: rfc1867.c,v 1.48 2000/09/08 21:56:47 zeev Exp $ */
#include <stdio.h>
#include "php.h"
@@ -86,7 +86,7 @@
/*
* 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 @@
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 @@
}
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 @@
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);
}
}