@@ -332,7 +332,7 @@
function imageLine(id, path, position, cover, shops, legend)
{
line = $("#lineType").html();
- line = line.replace(/image_id/g, legend);
+ line = line.replace(/image_id/g, id);
line = line.replace(/[a-z]{0,2}-default/g, path);
line = line.replace(/image_path/g, path);
line = line.replace(/image_position/g, position);
diff --git a/classes/Autoload.php b/classes/Autoload.php
index b9b5a394e..903484add 100644
--- a/classes/Autoload.php
+++ b/classes/Autoload.php
@@ -137,24 +137,18 @@ class Autoload
// Write classes index on disc to cache it
$filename = $this->root_dir.Autoload::INDEX_FILE;
- if ((file_exists($filename) && !is_writable($filename)) || !is_writable(dirname($filename)))
+ $filename_tmp = tempnam(dirname($filename), basename($filename.'.'));
+ if ($filename_tmp !== false && file_put_contents($filename_tmp, $content, LOCK_EX) !== false)
{
- header('HTTP/1.1 503 temporarily overloaded');
- // Cannot use PrestaShopException in this context
- die('/cache/class_index.php is not writable, please give write permissions (chmod 666) on this file.');
- }
- else
- {
- $filename_tmp = tempnam(dirname($filename), basename($filename.'.'));
- if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE)
- {
- @rename($filename_tmp, $filename);
- @chmod($filename, 0666);
- }
+ if (!rename($filename_tmp, $filename))
+ unlink($filename_tmp);
else
- // $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die.
- error_log('Cannot write temporary file '.$filename_tmp);
+ @chmod($filename, 0666);
}
+ // $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die.
+ else
+ error_log('Cannot write temporary file '.$filename_tmp);
+
$this->index = $classes;
}
diff --git a/classes/Hook.php b/classes/Hook.php
index 30efb0a76..656934e16 100644
--- a/classes/Hook.php
+++ b/classes/Hook.php
@@ -390,6 +390,10 @@ class HookCore extends ObjectModel
*/
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true)
{
+ static $disable_non_native_modules = null;
+ if ($disable_non_native_modules === null)
+ $disable_non_native_modules = (bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
+
// Check arguments validity
if (($id_module && !is_numeric($id_module)) || !Validate::isHookName($hook_name))
throw new PrestaShopException('Invalid id_module or hook_name');
@@ -419,7 +423,7 @@ class HookCore extends ObjectModel
$altern = 0;
$output = '';
- if (!isset(Hook::$native_module))
+ if ($disable_non_native_modules && !isset(Hook::$native_module))
Hook::$native_module = Module::getNativeModuleList();
foreach ($module_list as $array)
@@ -428,7 +432,7 @@ class HookCore extends ObjectModel
if ($id_module && $id_module != $array['id_module'])
continue;
- if ((bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE') && !in_array($array['module'], self::$native_module))
+ if ((bool)$disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($array['module'], self::$native_module))
continue;
if (!($moduleInstance = Module::getInstanceByName($array['module'])))
diff --git a/classes/Tools.php b/classes/Tools.php
index 1ee27abca..dc6a74cd4 100644
--- a/classes/Tools.php
+++ b/classes/Tools.php
@@ -672,10 +672,8 @@ class ToolsCore
public static function htmlentitiesUTF8($string, $type = ENT_QUOTES)
{
if (is_array($string))
- {
- $string = array_map(array('Tools', 'htmlentitiesUTF8'), $string);
- return (string)array_shift($string);
- }
+ return array_map(array('Tools', 'htmlentitiesUTF8'), $string);
+
return htmlentities((string)$string, $type, 'utf-8');
}
diff --git a/classes/Validate.php b/classes/Validate.php
index 1b4d31d03..abcd8e171 100644
--- a/classes/Validate.php
+++ b/classes/Validate.php
@@ -44,7 +44,7 @@ class ValidateCore
*/
public static function isEmail($email)
{
- return !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z0-9]+$/ui'), $email);
+ return !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z\p{L}0-9]+$/ui'), $email);
}
/**
@@ -1067,4 +1067,4 @@ class ValidateCore
{
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/classes/controller/Controller.php b/classes/controller/Controller.php
index 5309aca01..b40cf9f1e 100644
--- a/classes/controller/Controller.php
+++ b/classes/controller/Controller.php
@@ -175,8 +175,8 @@ abstract class ControllerCore
// then using displayAjax[action]
if ($this->ajax)
{
- $action = Tools::getValue('action');
- if (!empty($action) && method_exists($this, 'displayAjax'.Tools::toCamelCase($action, true)))
+ $action = Tools::toCamelCase(Tools::getValue('action'), true);
+ if (!empty($action) && method_exists($this, 'displayAjax'.$action))
$this->{'displayAjax'.$action}();
elseif (method_exists($this, 'displayAjax'))
$this->displayAjax();
diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php
index 1884cccf0..14c85c0ec 100644
--- a/classes/controller/FrontController.php
+++ b/classes/controller/FrontController.php
@@ -850,7 +850,7 @@ class FrontControllerCore extends Controller
if (!is_numeric(Tools::getValue('p', 1)) || Tools::getValue('p', 1) < 0)
Tools::redirect(self::$link->getPaginationLink(false, false, $this->n, false, 1, false));
- $current_url = tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']);
+ $current_url = Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']);
//delete parameter page
$current_url = preg_replace('/(\?)?(&)?p=\d+/', '$1', $current_url);
@@ -919,7 +919,7 @@ class FrontControllerCore extends Controller
$ips = array_map('trim', $ips);
if (is_array($ips) && count($ips))
foreach ($ips as $ip)
- if (!empty($ip) && strpos($user_ip, $ip) === 0)
+ if (!empty($ip) && preg_match('/^'.$ip.'.*/', $user_ip))
$allowed = true;
return $allowed;
}
diff --git a/classes/module/Module.php b/classes/module/Module.php
index 3318ca9e4..dea6881fc 100644
--- a/classes/module/Module.php
+++ b/classes/module/Module.php
@@ -1296,6 +1296,9 @@ abstract class ModuleCore
public static function getNativeModuleList()
{
$module_list_xml = _PS_ROOT_DIR_.self::CACHE_FILE_MODULES_LIST;
+ if (!file_exists($module_list_xml))
+ return false;
+
$native_modules = simplexml_load_file($module_list_xml);
$native_modules = $native_modules->modules;
$modules = array();
diff --git a/controllers/admin/AdminCartRulesController.php b/controllers/admin/AdminCartRulesController.php
index 9a0fddeb8..46dff7674 100644
--- a/controllers/admin/AdminCartRulesController.php
+++ b/controllers/admin/AdminCartRulesController.php
@@ -128,6 +128,8 @@ class AdminCartRulesControllerCore extends AdminController
$this->errors[] = Tools::displayError('Reduction amount cannot be lower than zero.');
if (Tools::getValue('code') && ($same_code = (int)CartRule::getIdByCode(Tools::getValue('code'))) && $same_code != Tools::getValue('id_cart_rule'))
$this->errors[] = sprintf(Tools::displayError('This cart rule code is already used (conflict with cart rule %d)'), $same_code);
+ if (Tools::getValue('apply_discount') == 'off' && !Tools::getValue('free_shipping') && !Tools::getValue('free_gift'))
+ $this->errors[] = Tools::displayError('An action is required for this cart rule.');
}
return parent::postProcess();
diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php
index cc455ef8b..9d7b2c52b 100644
--- a/controllers/admin/AdminCustomerThreadsController.php
+++ b/controllers/admin/AdminCustomerThreadsController.php
@@ -320,12 +320,15 @@ class AdminCustomerThreadsControllerCore extends AdminController
$cm = new CustomerMessage();
$cm->id_employee = (int)$this->context->employee->id;
$cm->id_customer_thread = (int)Tools::getValue('id_customer_thread');
- $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
+ $cm->ip_address = ip2long(Tools::getRemoteAddr());
$current_employee = $this->context->employee;
$id_employee = (int)Tools::getValue('id_employee_forward');
$employee = new Employee($id_employee);
$email = Tools::getValue('email');
- if ($id_employee && $employee && Validate::isLoadedObject($employee))
+ $message = Tools::getValue('message_forward');
+ if (($error = $cm->validateField('message', $message, null, array(), true)) !== true)
+ $this->errors[] = $error;
+ elseif ($id_employee && $employee && Validate::isLoadedObject($employee))
{
$params = array(
'{messages}' => Tools::nl2br(stripslashes($output)),
@@ -344,7 +347,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
null, null, _PS_MAIL_DIR_, true))
{
$cm->private = 1;
- $cm->message = $this->l('Message forwarded to').' '.$employee->firstname.' '.$employee->lastname."\n".$this->l('Comment:').' '.$_POST['message_forward'];
+ $cm->message = $this->l('Message forwarded to').' '.$employee->firstname.' '.$employee->lastname."\n".$this->l('Comment:').' '.$message;
$cm->add();
}
}
@@ -363,7 +366,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
$current_employee->email, $current_employee->firstname.' '.$current_employee->lastname,
null, null, _PS_MAIL_DIR_, true))
{
- $cm->message = $this->l('Message forwarded to').' '.$email."\n".$this->l('Comment:').' '.$_POST['message_forward'];
+ $cm->message = $this->l('Message forwarded to').' '.$email."\n".$this->l('Comment:').' '.$message;
$cm->add();
}
}
@@ -379,10 +382,11 @@ class AdminCustomerThreadsControllerCore extends AdminController
$cm = new CustomerMessage();
$cm->id_employee = (int)$this->context->employee->id;
$cm->id_customer_thread = $ct->id;
-
+ $cm->ip_address = ip2long(Tools::getRemoteAddr());
$cm->message = Tools::getValue('reply_message');
- $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
- if (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0)
+ if (($error = $cm->validateField('message', $cm->message, null, array(), true)) !== true)
+ $this->errors[] = $error;
+ elseif (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0)
$this->errors[] = Tools::displayError('An error occurred during the file upload process.');
elseif ($cm->add())
{
diff --git a/controllers/admin/AdminManufacturersController.php b/controllers/admin/AdminManufacturersController.php
index 2ec73737a..549925472 100644
--- a/controllers/admin/AdminManufacturersController.php
+++ b/controllers/admin/AdminManufacturersController.php
@@ -718,6 +718,11 @@ class AdminManufacturersControllerCore extends AdminController
(int)$image_type['height']
);
}
+
+ $current_logo_file = _PS_TMP_IMG_DIR_.'manufacturer_mini_'.$id_manufacturer.'_'.$this->context->shop->id.'.jpg';
+
+ if ($res && file_exists($current_logo_file))
+ unlink($current_logo_file);
}
if (!$res)
@@ -725,7 +730,7 @@ class AdminManufacturersControllerCore extends AdminController
return $res;
}
-
+
protected function beforeDelete($object)
{
return true;
diff --git a/controllers/admin/AdminStatusesController.php b/controllers/admin/AdminStatusesController.php
index fe4e129e0..62f4e5a1a 100644
--- a/controllers/admin/AdminStatusesController.php
+++ b/controllers/admin/AdminStatusesController.php
@@ -539,4 +539,20 @@ class AdminStatusesControllerCore extends AdminController
$this->initOrdersReturnsList();
return parent::filterToField($key, $filter);
}
+
+ protected function afterImageUpload()
+ {
+ parent::afterImageUpload();
+
+ if (($id_order_state = (int)Tools::getValue('id_order_state')) &&
+ isset($_FILES) && count($_FILES) && file_exists(_PS_ORDER_STATE_IMG_DIR_.$id_order_state.'.gif'))
+ {
+ $current_file = _PS_TMP_IMG_DIR_.'order_state_mini_'.$id_order_state.'_'.$this->context->shop->id.'.gif';
+
+ if (file_exists($current_file))
+ unlink($current_file);
+ }
+
+ return true;
+ }
}
diff --git a/controllers/admin/AdminSuppliersController.php b/controllers/admin/AdminSuppliersController.php
index d2eb52b8d..b120138f4 100644
--- a/controllers/admin/AdminSuppliersController.php
+++ b/controllers/admin/AdminSuppliersController.php
@@ -354,6 +354,11 @@ class AdminSuppliersControllerCore extends AdminController
if (!ImageManager::resize($file, _PS_SUPP_IMG_DIR_.$id_supplier.'-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], (int)$image_type['height']))
$return = false;
}
+
+ $current_logo_file = _PS_TMP_IMG_DIR_.'supplier_mini_'.$id_supplier.'_'.$this->context->shop->id.'.jpg';
+
+ if (file_exists($current_logo_file))
+ unlink($current_logo_file);
}
return $return;
}
diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php
index 8d3e5689e..c127fa46a 100644
--- a/controllers/front/ContactController.php
+++ b/controllers/front/ContactController.php
@@ -147,7 +147,7 @@ class ContactControllerCore extends FrontController
$cm->message = $message;
if (isset($fileAttachment['rename']) && !empty($fileAttachment['rename']) && rename($fileAttachment['tmp_name'], _PS_MODULE_DIR_.'../upload/'.basename($fileAttachment['rename'])))
$cm->file_name = $fileAttachment['rename'];
- $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
+ $cm->ip_address = ip2long(Tools::getRemoteAddr());
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!$cm->add())
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php
index 2b03955a6..7bde212a6 100644
--- a/controllers/front/OrderOpcController.php
+++ b/controllers/front/OrderOpcController.php
@@ -529,8 +529,8 @@ class OrderOpcControllerCore extends ParentOrderController
$minimalPurchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase)
return '
'.sprintf(
- Tools::displayError('A minimum purchase total of %s is required in order to validate your order.'),
- Tools::displayPrice($minimalPurchase, $currency)
+ Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'),
+ Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency)
).'