Fixed issue #13670: Performance optimization: change while(list() to foreach() (thank...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_formmail.php
index badd27f..ac6b8c8 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -84,7 +84,7 @@ class t3lib_formmail extends t3lib_htmlmail {
         * [from_name]:                 Sender name. If not set, [name] is used
         * [replyto_email]:             Reply-to email. If not set [from_email] is used
         * [replyto_name]:              Reply-to name. If not set [from_name] is used
-        * [organisation]:              Organisation (header)
+        * [organisation]:              Organization (header)
         * [priority]:                  Priority, 1-5, default 3
         * [html_enabled]:              If mail is sent as html
         * [use_base64]:                If set, base64 encoding will be used instead of quoted-printable
@@ -141,17 +141,16 @@ class t3lib_formmail extends t3lib_htmlmail {
 
                                // Runs through $V and generates the mail
                        if (is_array($V))       {
-                               reset($V);
-                               while (list($key,$val)=each($V))        {
+                               foreach ($V as $key => $val) {
                                        if (!t3lib_div::inList($this->reserved_names,$key))     {
-                                               $space = (strlen($val)>60)?chr(10):'';
-                                               $val = (is_array($val) ? implode($val,chr(10)) : $val);
+                                               $space = (strlen($val)>60)?LF:'';
+                                               $val = (is_array($val) ? implode($val,LF) : $val);
 
                                                        // convert form data from renderCharset to mail charset (HTML may use entities)
                                                $Plain_val = ($convCharset && strlen($val)) ? $GLOBALS['TSFE']->csConvObj->conv($val,$GLOBALS['TSFE']->renderCharset,$this->charset,0) : $val;
                                                $HTML_val = ($convCharset && strlen($val)) ? $GLOBALS['TSFE']->csConvObj->conv(htmlspecialchars($val),$GLOBALS['TSFE']->renderCharset,$this->charset,1) : htmlspecialchars($val);
 
-                                               $Plain_content.= strtoupper($key).':  '.$space.$Plain_val."\n".$space;
+                                               $Plain_content.= strtoupper($key).':  '.$space.$Plain_val.LF.$space;
                                                $HTML_content.= '<tr><td bgcolor="#eeeeee"><font face="Verdana" size="1"><b>'.strtoupper($key).'</b></font></td><td bgcolor="#eeeeee"><font face="Verdana" size="1">'.nl2br($HTML_val).'&nbsp;</font></td></tr>';
                                        }
                                }
@@ -165,10 +164,15 @@ class t3lib_formmail extends t3lib_htmlmail {
 
                        for ($a=0;$a<10;$a++)   {
                                $varname = 'attachment'.(($a)?$a:'');
-                               if (!is_uploaded_file($_FILES[$varname]['tmp_name']))   {
-                                       t3lib_div::sysLog('Possible abuse of t3lib_formmail: temporary file "'.$_FILES[$varname]['tmp_name'].'" ("'.$_FILES[$varname]['name'].'") was not an uploaded file.', 'Core', 3);
+                               if (!isset($_FILES[$varname])) {
                                        continue;
                                }
+                               if (!is_uploaded_file($_FILES[$varname]['tmp_name'])) {
+                                       t3lib_div::sysLog('Possible abuse of t3lib_formmail: temporary file "'.$_FILES[$varname]['tmp_name'].'" ("'.$_FILES[$varname]['name'].'") was not an uploaded file.', 'Core', 3);
+                               }
+                               if ($_FILES[$varname]['tmp_name']['error'] !== UPLOAD_ERR_OK) {
+                                       t3lib_div::sysLog('Error in uploaded file in t3lib_formmail: temporary file "'.$_FILES[$varname]['tmp_name'].'" ("'.$_FILES[$varname]['name'].'") Error code: '.$_FILES[$varname]['tmp_name']['error'], 'Core', 3);
+                               }
                                $theFile = t3lib_div::upload_to_tempfile($_FILES[$varname]['tmp_name']);
                                $theName = $_FILES[$varname]['name'];