From 459768d1ac077ccfa721d1d8fc0e091e86fb8d48 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 29 Apr 2013 10:47:19 +0200 Subject: [PATCH] [-] BO : fixed error message in language form #PSCFV-8890 --- classes/Validate.php | 9 ++++++--- .../admin/AdminLanguagesController.php | 19 +++++++++---------- css/admin.css | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/classes/Validate.php b/classes/Validate.php index 84d8bc24e..6af8d92c2 100644 --- a/classes/Validate.php +++ b/classes/Validate.php @@ -1055,6 +1055,9 @@ class ValidateCore { return (bool)(is_string($name) && preg_match('/^[0-9a-zA-Z-_]*$/u', $name)); } - -} - + + public static function isPrestaShopVersion($version) + { + return (preg_match('/^[0-1]\.[0-9]{1,2}(\.[0-9]{1,2}){0,2}$/', $version) && ip2long($version)); + } +} \ No newline at end of file diff --git a/controllers/admin/AdminLanguagesController.php b/controllers/admin/AdminLanguagesController.php index 9a00c8ca0..1db3d4eeb 100644 --- a/controllers/admin/AdminLanguagesController.php +++ b/controllers/admin/AdminLanguagesController.php @@ -475,19 +475,21 @@ class AdminLanguagesControllerCore extends AdminController public function ajaxProcessCheckLangPack() { $this->json = true; - if (empty($_GET['iso_lang'])) + if (!Tools::getValue('iso_lang') || !Validate::isLanguageIsoCode(Tools::getValue('iso_lang'))) { $this->status = 'error'; - $this->errors[] = '[TECHNICAL ERROR] iso_lang not set or empty'; + $this->errors[] = $this->l('Iso code is not valid'); + return; } - if (empty($_GET['ps_version'])) + if (!Tools::getValue('ps_version') || !Validate::isPrestaShopVersion(Tools::getValue('ps_version'))) { $this->status = 'error'; - $this->errors[] = '[TECHNICAL ERROR] ps_version not set or empty'; + $this->errors[] = $this->l('Technical Error: ps_version is not valid'); + return; } // Get all iso code available - if($lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.(string)$_GET['ps_version'].'&iso_lang='.(string)$_GET['iso_lang'])) + if ($lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.Tools::getValue('ps_version').'&iso_lang='.Tools::getValue('iso_lang'))) { $result = Tools::jsonDecode($lang_packs); if ($lang_packs !== '' && $result && !isset($result->error)) @@ -498,16 +500,13 @@ class AdminLanguagesControllerCore extends AdminController else { $this->status = 'error'; - $msg = $this->l('Wrong ISO code, or the selected language pack is unavailable.'); - if ($result) - $msg = $result->msg; - $this->errors[] = $msg; + $this->errors[] = $this->l('Wrong ISO code, or the selected language pack is unavailable.'); } } else { $this->status = 'error'; - $this->errors[] = '[TECHNICAL ERROR] Server unreachable'; + $this->errors[] = $this->l('Technical Error: translation server unreachable'); } } diff --git a/css/admin.css b/css/admin.css index 4ee837e91..ec73d1414 100644 --- a/css/admin.css +++ b/css/admin.css @@ -498,7 +498,7 @@ select optgroup option { background: #FFBABA url(../img/admin/icon-cancel.png) no-repeat scroll 6px 6px; border: 1px solid #CC0000; color:#D8000C; - padding:20px; + padding:20px 40px; position:fixed; bottom:0; width:100%;