/** * Imports an extensions from the online repository * NOTICE: in version 4.0 this changed from "importExtFromRep_old($extRepUid,$loc,$uploadFlag=0,$directInput='',$recentTranslations=0,$incManual=0,$dontDelete=0)" * * @param string Extension key * @param string Version * @param string Install scope: "L" or "G" or "S" * @param boolean If true, extension is uploaded as file * @param boolean If true, extension directory+files will not be deleted before writing the new ones. That way custom files stored in the extension folder will be kept. * @param array Direct input array (like from kickstarter) * @return string Return false on success, returns error message if error. */ 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 (($uploadedTempFile = $this->CMD['alreadyUploaded']) || $_FILES['upload_ext_file']['tmp_name']) { // Read uploaded file: 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); $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_file_not_uploaded'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']); } $fileContent = t3lib_div::getUrl($uploadedTempFile); if (!$fileContent) { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_file_empty'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } // Decode file data: $fetchData = $this->terConnection->decodeExchangeData($fileContent); if (is_array($fetchData)) { $extKey = $fetchData[0]['extKey']; if ($extKey) { if (!$this->CMD['uploadOverwrite']) { $loc = $loc === 'G' || $loc === 'S' ? $loc : 'L'; $comingExtPath = tx_em_Tools::typePath($loc) . $extKey . '/'; if (@is_dir($comingExtPath)) { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_ext_present_no_overwrite'), $comingExtPath) . '<br />' . $GLOBALS['LANG']->getLL('ext_import_ext_present_nothing_done'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } // ... else go on, install... } // ... else go on, install... } else { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_no_key'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } } else { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } } else { $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_no_file'), '', t3lib_FlashMessage::ERROR); return $flashMessage->render(); } } else { $this->xmlHandler->searchExtensionsXMLExact($extKey, '', '', true, true); // Fetch extension from TER: if (!strlen($version)) { $versions = array_keys($this->xmlHandler->extensionsXML[$extKey]['versions']); $version = end($versions); } $fetchData = $this->terConnection->fetchExtension($extKey, $version, $this->xmlHandler->extensionsXML[$extKey]['versions'][$version]['t3xfilemd5'], $this->getMirrorURL()); } // At this point the extension data should be present; so we want to write it to disc: $content = $this->install->installExtension($fetchData, $loc, $version, $uploadedTempFile, $dontDelete); $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_results'), $content, 0, 1); if ($uploadSucceed && $uploadedTempFile) { t3lib_div::unlink_tempfile($uploadedTempFile); } return false; }