CVS update: php3/functions

From: Date: Sun, 07 Mar 1999 15:49:21 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-4510@lists.php.net to get a copy of this message
Date: Sunday March 7, 1999 @ 10:49 Author: rasmus Update of /repository/php3/functions In directory asf:/home/rasmus/php3/functions Modified Files: head.c post.c post.h Log Message: PUT method patch Index: php3/functions/head.c diff -c php3/functions/head.c:1.112 php3/functions/head.c:1.113 *** php3/functions/head.c:1.112 Mon Jan 4 09:25:20 1999 --- php3/functions/head.c Sun Mar 7 10:49:20 1999 *************** *** 26,32 **** | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: head.c,v 1.112 1999/01/04 14:25:20 jah Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif --- 26,32 ---- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: head.c,v 1.113 1999/03/07 15:49:20 rasmus Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif *************** *** 255,262 **** return 1; } if ((GLOBAL(php3_PrintHeader) && !GLOBAL(php3_HeaderPrinted)) || (GLOBAL(php3_PrintHeader) && GLOBAL(php3_HeaderPrinted) == 2)) { ! if (!(GLOBAL(initialized) & INIT_ENVIRONMENT) && GLOBAL(request_info).request_method && !strcasecmp(GLOBAL(request_info).request_method, "post")) { ! php3_treat_data(PARSE_POST, NULL); /* POST Data */ } cookie = php3_PopCookieList(); while (cookie) { --- 255,267 ---- return 1; } if ((GLOBAL(php3_PrintHeader) && !GLOBAL(php3_HeaderPrinted)) || (GLOBAL(php3_PrintHeader) && GLOBAL(php3_HeaderPrinted) == 2)) { ! if (!(GLOBAL(initialized) & INIT_ENVIRONMENT) && GLOBAL(request_info).request_method) { ! if(!strcasecmp(GLOBAL(request_info).request_method, "post")) ! php3_treat_data(PARSE_POST, NULL); /* POST Data */ ! else { ! if(!strcasecmp(GLOBAL(request_info).request_method, "put")) ! php3_treat_data(PARSE_PUT, NULL); /* PUT Data */ ! } } cookie = php3_PopCookieList(); while (cookie) { *************** *** 335,342 **** } #else if (GLOBAL(php3_PrintHeader) && !GLOBAL(php3_HeaderPrinted)) { ! if (!(GLOBAL(initialized) & INIT_ENVIRONMENT) && GLOBAL(request_info).request_method && !strcasecmp(GLOBAL(request_info).request_method, "post")) { ! php3_treat_data(PARSE_POST, NULL); /* POST Data */ } if (!GLOBAL(cont_type)) { #if USE_SAPI --- 340,352 ---- } #else if (GLOBAL(php3_PrintHeader) && !GLOBAL(php3_HeaderPrinted)) { ! if (!(GLOBAL(initialized) & INIT_ENVIRONMENT) && GLOBAL(request_info).request_method) { ! if(!strcasecmp(GLOBAL(request_info).request_method, "post") ! php3_treat_data(PARSE_POST, NULL); /* POST Data */ ! else { ! if(!strcasecmp(GLOBAL(request_info).request_method, "put")) ! php3_treat_data(PARSE_PUT, NULL); /* PUT Data */ ! } } if (!GLOBAL(cont_type)) { #if USE_SAPI Index: php3/functions/post.c diff -c php3/functions/post.c:1.114 php3/functions/post.c:1.115 *** php3/functions/post.c:1.114 Mon Jan 4 09:25:21 1999 --- php3/functions/post.c Sun Mar 7 10:49:21 1999 *************** *** 41,49 **** --- 41,135 ---- #ifndef THREAD_SAFE int php3_track_vars; + int le_uploads; + extern HashTable list; #endif /* + * php3_getput() + * + * This copies the uploaded file to a temporary file. + */ + static void php3_getput() + { + #if MODULE_MAGIC_NUMBER > 19961007 + char upload_buffer[BUFSIZ]; + #else + int bytes; + #endif + char *fn; + FILE *fp; + int length, cnt; + long bytes; + + length = GLOBAL(request_info).content_length; + if (length > php3_ini.upload_max_filesize) { + php3_error(E_WARNING, "Max file size of %ld bytes exceeded - temporary file not saved", php3_ini.upload_max_filesize); + SET_VAR_STRING("PHP_UPLOADED_FILE_NAME", estrdup("none")); + return; + } + fn = tempnam(php3_ini.upload_tmp_dir, "php"); + fp = fopen(fn, "w"); + if (!fp) { + php3_error(E_WARNING, "File Upload Error - Unable to open temporary file [%s]", fn); + return; + } + cnt = length; + #if FHTTPD + bytes = fwrite(req->databuffer, 1, length, fp); + #else + #if MODULE_MAGIC_NUMBER > 19961007 + if (should_client_block(GLOBAL(php3_rqst))) { + void (*handler) (int); + int dbsize, len_read, dbpos = 0; + + hard_timeout("copy script args", GLOBAL(php3_rqst)); /* start timeout timer */ + handler = signal(SIGPIPE, SIG_IGN); /* Ignore sigpipes for now */ + while ((len_read = get_client_block(GLOBAL(php3_rqst), upload_buffer, BUFSIZ)) > 0) { + if ((dbpos + len_read) > length) + dbsize = length - dbpos; + else + dbsize = len_read; + reset_timeout(GLOBAL(php3_rqst)); /* Make sure we don't timeout */ + if((bytes=fwrite(upload_buffer, 1, dbsize, fp))<dbsize) + { + bytes+=dbpos; + break; + } + dbpos += dbsize; + bytes=dbpos; + } + signal(SIGPIPE, handler); /* restore normal sigpipe handling */ + kill_timeout(GLOBAL(php3_rqst)); /* stop timeout timer */ + } + #else + cnt = 0; + do { + #if APACHE + char upload_buffer[BUFSIZ]; + + bytes = read_client_block(php3_rqst, buf + cnt, min(length - cnt,BUFSIZ)); + #endif + #if CGI_BINARY + bytes = fread(buf + cnt, 1, min(length - cnt,BUFSIZ), stdin); + #endif + #if USE_SAPI + bytes = GLOBAL(sapi_rqst)->readclient(GLOBAL(sapi_rqst)->scid,buf + cnt, 1, min(length - cnt,BUFSIZ)); + #endif + cnt += bytes; + } while (bytes && cnt < length); + #endif + #endif + fclose(fp); + if (bytes < length) { + php3_error(E_WARNING, "Only %d bytes were written, expected to write %ld", bytes, length); + } + SET_VAR_STRING("PHP_UPLOADED_FILE_NAME", estrdup(fn)); + php3_list_do_insert(&GLOBAL(list),fn,GLOBAL(le_uploads)); /* Tell PHP about the file so the destructor can unlink it later */ + } + + + /* * php3_getpost() * * This reads the post form data into a string. *************** *** 340,345 **** --- 426,434 ---- } } else if (arg == PARSE_STRING) { /* String data */ res = str; + } else if (arg == PARSE_PUT) { /* Put data */ + php3_getput(); + return; } if (!res) { return; Index: php3/functions/post.h diff -c php3/functions/post.h:1.21 php3/functions/post.h:1.22 *** php3/functions/post.h:1.21 Fri Jan 1 12:59:17 1999 --- php3/functions/post.h Sun Mar 7 10:49:21 1999 *************** *** 26,32 **** | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: post.h,v 1.21 1999/01/01 17:59:17 zeev Exp $ */ #ifndef _POST_H #define _POST_H --- 26,32 ---- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: post.h,v 1.22 1999/03/07 15:49:21 rasmus Exp $ */ #ifndef _POST_H #define _POST_H *************** *** 35,40 **** --- 35,41 ---- #define PARSE_GET 1 #define PARSE_COOKIE 2 #define PARSE_STRING 3 + #define PARSE_PUT 4 extern void php3_treat_data(int arg, char *str); extern void php3_TreatHeaders(void); -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#4510) next »