[-] BO : fixed error message in language form #PSCFV-8890

This commit is contained in:
Damien Metzger
2013-04-29 10:47:19 +02:00
parent 626009d157
commit 459768d1ac
3 changed files with 16 additions and 14 deletions
+6 -3
View File
@@ -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));
}
}
+9 -10
View File
@@ -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');
}
}
+1 -1
View File
@@ -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%;