Fix a problem of the EM: "No file uploaded!" when retrying install after a failed...
authorMartin Kutschker <martin.t.kutschker@blackbox.net>
Wed, 31 May 2006 15:33:28 +0000 (15:33 +0000)
committerMartin Kutschker <martin.t.kutschker@blackbox.net>
Wed, 31 May 2006 15:33:28 +0000 (15:33 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@1491 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/mod/tools/em/class.em_index.php

index 20ddd14..f6cef2e 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
 
-2006-05-22  Martin Kutschker  <martin.t.kutschker@blackbox.net>
+2006-05-22 Bernhard Kraft  <kraftb@kraftb.at>
 
-       * Added class "checkbox" to "Expand all" checkbox (removes border in IE)
+       * Fix a problem of the EM: "No file uploaded!" when retrying install after a failed dependency check
 
 2006-05-22  Martin Kutschker  <martin.t.kutschker@blackbox.net>
 
index b00f264..9556d02 100644 (file)
@@ -1623,16 +1623,27 @@ EXTENSION KEYS:
         */
        function importExtFromRep($extKey,$version,$loc,$uploadFlag=0,$dontDelete=0,$directInput='')    {
 
+               $uploadSucceed = false;
+               $uploadedTempFile = '';
                if (is_array($directInput))     {
                        $fetchData = array($directInput,'');
                        $loc = ($loc==='G'||$loc==='S') ? $loc : 'L';
                } elseif ($uploadFlag)  {
-                       if ($_FILES['upload_ext_file']['tmp_name'])     {
+                       if (($uploadedTempFile = $this->CMD['alreadyUploaded']) || $_FILES['upload_ext_file']['tmp_name'])      {
 
                                        // Read uploaded file:
-                               $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']);
+                               if (!$uploadedTempFile) {
+                                       if (!is_uploaded_file($_FILES['upload_ext_file']['tmp_name'])) {
+                                               t3lib_div::sysLog('Possible file upload attack: '.$_FILES['upload_ext_file']['tmp_name'], 'Extension Manager', 3);
+
+                                               return 'File was not uploaded?!?';
+                                       }
+
+                                       $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']);
+                               }
                                $fileContent = t3lib_div::getUrl($uploadedTempFile);
-                               t3lib_div::unlink_tempfile($uploadedTempFile);
+
+                               if (!$fileContent)      return 'File is empty!';
 
                                        // Decode file data:
                                $fetchData = $this->terConnection->decodeExchangeData($fileContent);
@@ -1674,6 +1685,9 @@ EXTENSION KEYS:
                                                $depStatus = $this->checkDependencies($extKey, $EM_CONF, $instExtInfo);
                                                if(t3lib_extMgm::isLoaded($extKey) && !$depStatus['returnCode']) {
                                                        $this->content .= $depStatus['html'];
+                                                       if ($uploadedTempFile)  {
+                                                               $this->content .= '<input type="hidden" name="CMD[alreadyUploaded]" value="'.$uploadedTempFile.'" />';
+                                                       }
                                                } else {
                                                        $res = $this->clearAndMakeExtensionDir($fetchData[0],$loc,$dontDelete);
                                                        if (is_array($res))     {
@@ -1703,6 +1717,8 @@ EXTENSION KEYS:
                                                                                if (!$content)  {
                                                                                        $content='SUCCESS: '.$extDirPath.'<br />';
 
+                                                                                       $uploadSucceed = true;
+
                                                                                                // Fix TYPO3_MOD_PATH for backend modules in extension:
                                                                                        $modules = t3lib_div::trimExplode(',',$EM_CONF['module'],1);
                                                                                        if (count($modules))    {
@@ -1758,6 +1774,10 @@ EXTENSION KEYS:
 
                $this->content.=$this->doc->section('Extension import results',$content,0,1);
 
+               if ($uploadSucceed && $uploadedTempFile)        {
+                       t3lib_div::unlink_tempfile($uploadedTempFile);
+               }
+
                return false;
        }
 
@@ -5019,4 +5039,4 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/t
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/tools/em/index.php']);
 }
 
-?>
+?>
\ No newline at end of file