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/AdminCartsController.php b/controllers/admin/AdminCartsController.php index fc0cf91ce..e8ee17cef 100755 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -209,7 +209,7 @@ class AdminCartsControllerCore extends AdminController if (!$this->context->cart->id_customer) $this->context->cart->id_customer = $id_customer; - if ($this->context->cart->OrderExists()) + if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists()) return; if (!$this->context->cart->secure_key) $this->context->cart->secure_key = $this->context->customer->secure_key; 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/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 9b360eb8b..7c4d18ce9 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -1454,6 +1454,8 @@ class AdminTranslationsControllerCore extends AdminController $path = $arr_mail_path[$group_name]; if ($module_name) $path = str_replace('{module}', $module_name, $path); + if (!file_exists($path) && !mkdir($path, 0777, true)) + throw new PrestaShopException(sprintf(Tools::displayError('Directory "%s" cannot be created'), dirname($file_path))); file_put_contents($path.$mail_name.'.'.$type_content, $content); } else @@ -2453,6 +2455,9 @@ class AdminTranslationsControllerCore extends AdminController protected function writeSubjectTranslationFile($sub, $path) { + if (!Tools::file_exists_cache(dirname(path))) + if (!mkdir(dirname(path), 0700)) + throw new PrestaShopException('Directory '.dirname(path).' cannot be created.'); if ($fd = @fopen($path, 'w')) { $tab = 'LANGMAIL'; 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%; diff --git a/modules/blockcart/blockcart-json.tpl b/modules/blockcart/blockcart-json.tpl index 6311433af..68ccf81d2 100644 --- a/modules/blockcart/blockcart-json.tpl +++ b/modules/blockcart/blockcart-json.tpl @@ -33,7 +33,7 @@ "link": "{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|addslashes|replace:'\\\'':'\''}", "quantity": {$product.cart_quantity}, "priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", - "name": "{$product.name|html_entity_decode:2:'UTF-8'|escape:'htmlall'|truncate:15:'...':true}", + "name": "{$product.name|html_entity_decode:2:'UTF-8'|truncate:15:'...':true|escape:'htmlall'}", "price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}", "price_float": "{$product.total}", "idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if}, diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index 051bcf39e..d33a601c3 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -100,7 +100,7 @@ var delete_txt = '{l s='Delete' mod='blockcart' js=1}';