Here are the diffs Rasmus asked for on the three internal files that the internals group would be concerned about (main/php.h, main/main.c, main/rfc1867.c). These diffs were done on 4.3.2 code. If you all feel this is worthy of inclusion, I can construct a CVS diff as directed by README.SUBMITTING_PATCH as well as submit the five associated functions as a PEAR module to the PEAR group.
There seems to be quite a bit of demand for this functionality. When I first researched this functionality, there were numerous discussions in PHP forums with many people wanting a file upload status bar. I have also received several emails from people who saw my post and are dying to a source patch, but I couldn't give them one because I didn't have it working with 4.3.2 yet. So it seems to me that there is quite a bit of demand to add this feature. Here are some questions I have: 1. Will you want to use #ifdef with this additional code? 2. Is there a security risk since I am taking the value of the uploaded hidden ID and appending it as part of a filename? If so, what do you recommend I do to fix that problem? 3. Are there any other changes you would like me to make? I can give a working URL that demonstrates this process to those who email me and ask. I just don't want to broadcast it to the public list. :-) --David On Tue, 20 May 2003, Rasmus Lerdorf wrote: > > We're not interested in the Javascript or HTML parts of this > stuff, but if > you could post a diff of the changes you made to the core > file upload code > to implement the status functions we can take a look. The > Javascript and > HTML that makes use of these hooks fit better as a PEAR module. > > -Rasmus > -----=+=----- David Enderson Programmer Digital IMS 402.437.0137 [EMAIL PROTECTED]
--- php-4.3.2/main/php.h Sat Apr 19 13:35:51 2003 +++ php-4.3.2-status/main/php.h Wed Jul 16 12:37:43 2003 @@ -411,6 +411,16 @@ #endif #endif /* !XtOffsetOf */ +/* file upload status global structure definition */ +typedef struct _fus_globals_struct { + char *temp_file_dir; + char *temp_file_prefix; + char *hidden_variable_name; +} fus_globals_struct; +fus_globals_struct fus_globals; +/* FUSG stands for: File Upload Status Globals. */ +#define FUSG(v) (fus_globals.v) + #endif /* --- php-4.3.2/main/main.c Wed May 21 17:54:38 2003 +++ php-4.3.2-status/main/main.c Wed Jul 16 12:26:07 2003 @@ -368,6 +368,11 @@ 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) + /* file upload status settings */ + STD_PHP_INI_ENTRY("file_upload_status.temp_file_dir", "/tmp", PHP_INI_ALL, OnUpdateString, temp_file_dir, fus_globals_struct, fus_globals) + STD_PHP_INI_ENTRY("file_upload_status.temp_file_prefix", "file_upload_status_", PHP_INI_ALL, OnUpdateString, temp_file_prefix, fus_globals_struct, fus_globals) + STD_PHP_INI_ENTRY("file_upload_status.hidden_variable_name", "file_upload_status_uniqueid", PHP_INI_ALL, OnUpdateString, hidden_variable_name, fus_globals_struct, fus_globals) + PHP_INI_END() /* }}} */ --- php-4.3.2/main/rfc1867.c Fri May 23 16:37:16 2003 +++ php-4.3.2-status/main/rfc1867.c Wed Jul 16 11:44:31 2003 @@ -693,6 +693,10 @@ zval *array_ptr = (zval *) arg; FILE *fp; zend_llist header; + /* file upload status variables */ + zend_bool file_upload_status = 0; + char *file_upload_status_filename = NULL; + FILE *file_upload_status_fp; if (SG(request_info).content_length > SG(post_max_size)) { sapi_module.sapi_error(E_WARNING, "POST Content-Length of %d bytes exceeds the limit of %d bytes", SG(request_info).content_length, SG(post_max_size)); @@ -794,7 +798,6 @@ /* Normal form variable, safe to read all data into memory */ if (!filename && param) { - char *value = multipart_buffer_read_body(mbuff TSRMLS_CC); if (!value) { @@ -805,6 +808,13 @@ if (!strcasecmp(param, "MAX_FILE_SIZE")) { max_file_size = atol(value); } + + /* Check for upload status hidden variable */ + if (strcasecmp(param, FUSG(hidden_variable_name)) == 0) { + file_upload_status = 1; + file_upload_status_filename = emalloc(strlen(FUSG(temp_file_dir)) + strlen(FUSG(temp_file_prefix)) + strlen(value) + 2); + sprintf(file_upload_status_filename, "%s/%s%s", FUSG(temp_file_dir), FUSG(temp_file_prefix), value); + } efree(param); efree(value); @@ -873,8 +883,22 @@ total_bytes += wlen; } } + + /* Write file upload status to file */ + if (file_upload_status) { + file_upload_status_fp = fopen(file_upload_status_filename, "w"); + fprintf(file_upload_status_fp, "%li %li", SG(read_post_bytes), SG(request_info).content_length); + fclose(file_upload_status_fp); + } } fclose(fp); + + /* Write file upload "complete" status to file */ + if (file_upload_status) { + file_upload_status_fp = fopen(file_upload_status_filename, "w"); + fprintf(file_upload_status_fp, "-2 -2"); + fclose(file_upload_status_fp); + } #ifdef DEBUG_FILE_UPLOAD if(strlen(filename) > 0 && total_bytes == 0) {
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php