diff --git a/classes/Tools.php b/classes/Tools.php index d73875339..7fdd6d1b1 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1683,6 +1683,47 @@ FileETag INode MTime Size return true; } + + public static function getDefaultIndexContent() + { + return ' +* @copyright 2007-'.date('Y').' PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; +'; + + } /** * jsonDecode convert json string to php array / object diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index aa91f2172..04e727a81 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -647,6 +647,10 @@ class AdminTranslationsControllerCore extends AdminController { foreach ($files_list as $file2check) { + //don't validate index.php, will be overwrite when extract in translation directory + if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php') + continue; + if (preg_match('@^[0-9a-z-_/\\\\]+\.php$@i', $file2check['filename'])) { if (!AdminTranslationsController::checkTranslationFile(file_get_contents($sandbox.$file2check['filename']))) @@ -655,7 +659,6 @@ class AdminTranslationsControllerCore extends AdminController elseif (!preg_match('@^[0-9a-z-_/\\\\]+\.(html|tpl|txt)$@i', $file2check['filename'])) $this->errors[] = sprintf(Tools::displayError('Unidentified file found: %s'), $file2check['filename']); } - } Tools::deleteDirectory($sandbox, true); @@ -664,6 +667,10 @@ class AdminTranslationsControllerCore extends AdminController if ($gz->extract(_PS_TRANSLATIONS_DIR_.'../', false)) { + foreach ($files_list as $file2check) + if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php' && file_put_contents(_PS_TRANSLATIONS_DIR_.'../'.$file2check['filename'], Tools::getDefaultIndexContent())) + continue; + AdminTranslationsController::checkAndAddMailsFiles($iso_code, $files_list); $this->checkAndAddThemesFiles($files_list, $themes_selected); $tab_errors = AdminTranslationsController::addNewTabs($iso_code, $files_list);