]> granicus.if.org Git - php/commitdiff
@- Add $HTTP_POST_FILES[filename][tmp_name] - it was previously impossible to
authorZeev Suraski <zeev@php.net>
Sun, 2 Apr 2000 21:27:32 +0000 (21:27 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 2 Apr 2000 21:27:32 +0000 (21:27 +0000)
@  retrieve the temporary name of an uploaded file using $HTTP_POST_FILES[] (Zeev)
- Changed IMAP Win32 definitions

ext/imap/php_imap.c
main/rfc1867.c

index 839e2e2b5307d8494f5ac19079a212ea56e9eab9..4ef90a4dc7aa34943752c0e4d478514efa3c78b6 100644 (file)
@@ -41,7 +41,7 @@ ZEND_DECLARE_MODULE_GLOBALS(imap)
 #include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
-#if (WIN32|WINNT)
+#ifdef PHP_WIN32
 #include "winsock.h"
 MAILSTREAM DEFAULTPROTO;
 #endif
@@ -130,7 +130,7 @@ function_entry imap_functions[] = {
        PHP_FE(imap_alerts,                     NULL)
        PHP_FE(imap_errors,                     NULL)
        PHP_FE(imap_last_error,         NULL)
-#if !(WIN32|WINNT)
+#ifndef PHP_WIN32
        PHP_FE(imap_mail,           NULL)
 #endif
        PHP_FE(imap_search,                     NULL)
@@ -380,20 +380,20 @@ PHP_MINIT_FUNCTION(imap)
        ZEND_INIT_MODULE_GLOBALS(imap, php_imap_init_globals, NULL)
 
 
-#if !(WIN32|WINNT)
+#ifndef PHP_WIN32
        mail_link(&unixdriver);   /* link in the unix driver */
 #endif
        mail_link(&imapdriver);      /* link in the imap driver */
        mail_link(&nntpdriver);      /* link in the nntp driver */
        mail_link(&pop3driver);      /* link in the pop3 driver */
-#if !(WIN32|WINNT)
+#ifndef PHP_WIN32
        mail_link(&mhdriver);        /* link in the mh driver */
        mail_link(&mxdriver);        /* link in the mx driver */
 #endif
        mail_link(&mbxdriver);       /* link in the mbx driver */
        mail_link(&tenexdriver);     /* link in the tenex driver */
        mail_link(&mtxdriver);       /* link in the mtx driver */
-#if !(WIN32|WINNT)
+#ifndef PHP_WIN32
        mail_link(&mmdfdriver);      /* link in the mmdf driver */
        mail_link(&newsdriver);      /* link in the news driver */
        mail_link(&philedriver);     /* link in the phile driver */
@@ -3130,7 +3130,7 @@ PHP_FUNCTION(imap_mail_compose)
 }
 /* }}} */
 
-#if !(WIN32|WINNT)
+#ifndef PHP_WIN32
 int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *cc, char *bcc, char* rpath)
 {
 #ifdef PHP_WIN32
index bca099689d067d446750f4b32c1ca60ff43c602d..e43aeecc9ab64e7c41538025090cc633938da011 100644 (file)
@@ -30,6 +30,9 @@
 #define NEW_BOUNDARY_CHECK 1
 #define SAFE_RETURN { if (namebuf) efree(namebuf); if (filenamebuf) efree(filenamebuf); if (lbuf) efree(lbuf); return; }
 
+/* The longest property name we use in an uploaded file array */
+#define MAX_SIZE_OF_INDEX sizeof("[tmpname]")
+
 
 static void register_http_post_files_variable(char *strvar, char *val, zval *http_post_files ELS_DC PLS_DC)
 {
@@ -126,7 +129,7 @@ static void php_mime_split(char *buf, int cnt, char *boundary, zval *array_ptr)
                                        if (lbuf) {
                                                efree(lbuf);
                                        }
-                                       lbuf = emalloc(s-name + MAX(MAX(sizeof("[name]"),sizeof("[size]")),sizeof("[type]")));
+                                       lbuf = emalloc(s-name + MAX_SIZE_OF_INDEX);
                                        state = 2;
                                        loc2 = memchr(loc + 1, '\n', rem);
                                        rem -= (loc2 - ptr) + 1;
@@ -267,6 +270,10 @@ static void php_mime_split(char *buf, int cnt, char *boundary, zval *array_ptr)
                                        }
                                }
                                php_register_variable(namebuf, fn, NULL ELS_CC PLS_CC);
+
+                               /* Add $foo[tmp_name] */
+                               sprintf(lbuf, "%s[tmp_name]", namebuf);
+                               register_http_post_files_variable(lbuf, fn, http_post_files ELS_CC PLS_CC);
                                {
                                        zval file_size;