// Improve performance and bug fixes

This commit is contained in:
rGaillard
2012-06-06 16:22:48 +00:00
parent e636665621
commit 99b22fbbb8
32 changed files with 97 additions and 66 deletions
+2 -2
View File
@@ -851,7 +851,7 @@ abstract class AdminTabCore
{
$type = (array_key_exists('filter_type', $field) ? $field['filter_type'] : (array_key_exists('type', $field) ? $field['type'] : false));
if (($type == 'date' || $type == 'datetime') && is_string($value))
$value = unserialize($value);
$value = Tools::unSerialize($value);
$key = isset($tmpTab[1]) ? $tmpTab[0].'.`'.bqSQL($tmpTab[1]).'`' : '`'.bqSQL($tmpTab[0]).'`';
if (array_key_exists('tmpTableFilter', $field))
$sqlFilter = & $this->_tmpTableFilter;
@@ -1511,7 +1511,7 @@ abstract class AdminTabCore
case 'date':
case 'datetime':
if (is_string($value))
$value = unserialize($value);
$value = Tools::unSerialize($value);
if (!Validate::isCleanHtml($value[0]) || !Validate::isCleanHtml($value[1]))
$value = '';
$name = $this->table.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
+1 -1
View File
@@ -2190,7 +2190,7 @@ class CartCore extends ObjectModel
// The delivery option was selected
if (isset($this->delivery_option) && $this->delivery_option != '')
{
$delivery_option = unserialize($this->delivery_option);
$delivery_option = Tools::unSerialize($this->delivery_option);
$validated = true;
foreach ($delivery_option as $id_address => $key)
if (!isset($delivery_option_list[$id_address][$key]))
+2 -2
View File
@@ -108,8 +108,8 @@ class SpecificPriceRuleCore extends ObjectModel
$result = Db::getInstance()->insert('specific_price_rule_condition', array(
'id_specific_price_rule_condition' => '',
'id_specific_price_rule_condition_group' => (int)$id_specific_price_rule_condition_group,
'type' => $condition['type'],
'value' => $condition['value'],
'type' => pSQL($condition['type']),
'value' => (float)$condition['value'],
));
if (!$result)
return false;
+1 -1
View File
@@ -122,7 +122,7 @@ class StoreCore extends ObjectModel
public function getWsHours()
{
return implode(';', unserialize($this->hours));
return implode(';', Tools::unSerialize($this->hours));
}
public function setWsHours($hours)
+8
View File
@@ -2125,6 +2125,14 @@ FileETag INode MTime Size
{
return Tools::apacheModExists('mod_rewrite');
}
public static function unSerialize($serialized, $object = false)
{
if (is_string($serialized) && ((strpos($serialized, 'O:') !== false && !preg_match('/(^|;|{|})O:[0-9]+:"/', $serialized) && !$object) || $object))
return @unserialize($serialized);
return false;
}
}
/**
+1 -1
View File
@@ -164,7 +164,7 @@ class UpgraderCore
*/
public function loadFromConfig()
{
$last_version_check = @unserialize(Configuration::get('PS_LAST_VERSION'));
$last_version_check = Tools::unSerialize(Configuration::get('PS_LAST_VERSION'));
if($last_version_check)
{
if (isset($last_version_check['name']))
+8 -8
View File
@@ -377,14 +377,14 @@ class ValidateCore
*/
public static function isCleanHtml($html)
{
$events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange
|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend
|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove
|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel
|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart
|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange
|onselectstart|onstart|onstop';
return (!preg_match('/<[ \t\n]*script/i', $html) && !preg_match('/<?.*('.$events.')[ \t\n]*=/i', $html) && !preg_match('/.*script\:/i', $html));
$events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
$events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
$events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove';
$events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel';
$events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
$events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
$events .= '|onselectstart|onstart|onstop';
return (!preg_match('/<[ \t\n]*script/ims', $html) && !preg_match('/<?.*('.$events.')[ \t\n]*=/ims', $html) && !preg_match('/.*script\:/ims', $html) && !preg_match('/<[ \t\n]*i?frame/ims', $html));
}
/**
+1 -1
View File
@@ -418,7 +418,7 @@ class AdminControllerCore extends Controller
if ($field = $this->filterToField($key, $filter))
{
$type = (array_key_exists('filter_type', $field) ? $field['filter_type'] : (array_key_exists('type', $field) ? $field['type'] : false)); if (($type == 'date' || $type == 'datetime') && is_string($value))
$value = unserialize($value);
$value = Tools::unSerialize($value);
$key = isset($tmp_tab[1]) ? $tmp_tab[0].'.`'.$tmp_tab[1].'`' : '`'.$tmp_tab[0].'`';
// Assignement by reference
+4 -2
View File
@@ -260,7 +260,9 @@ class FrontControllerCore extends Controller
/* get page name to display it in body id */
// Are we in a payment module
$module_name = Tools::getValue('module');
$module_name = '';
if (Validate::isModuleName(Tools::getValue('module')))
$module_name = Tools::getValue('module');
if (!empty($this->page_name))
$page_name = $this->page_name;
elseif (!empty($this->php_self))
@@ -601,7 +603,7 @@ class FrontControllerCore extends Controller
$params = array();
$excluded_key = array('isolang', 'id_lang', 'controller', 'fc');
foreach ($_GET as $key => $value)
if (!in_array($key, $excluded_key))
if (!in_array($key, $excluded_key) && Validate::isUrl($key) && Validate::isUrl($value))
$params[$key] = $value;
$str_params = '';
+1 -1
View File
@@ -550,7 +550,7 @@ class HelperListCore extends Helper
case 'date':
case 'datetime':
if (is_string($value))
$value = unserialize($value);
$value = Tools::unSerialize($value);
if (!Validate::isCleanHtml($value[0]) || !Validate::isCleanHtml($value[1]))
$value = '';
$name = $this->table.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
+2
View File
@@ -837,6 +837,8 @@ abstract class ModuleCore
*/
public static function getInstanceByName($module_name)
{
if (!Validate::isModuleName($module_name))
die(Tools::displayErrors());
if (!isset(self::$_INSTANCE[$module_name]))
{
if (Tools::file_exists_cache(_PS_MODULE_DIR_.$module_name.'/'.$module_name.'.php'))
+8
View File
@@ -770,6 +770,14 @@ class ShopCore extends ObjectModel
{
return self::$context_id_shop_group;
}
public static function getContextShopGroup()
{
static $context_shop_group = null;
if ($context_shop_group === null)
$context_shop_group = new ShopGroup((int)self::$context_id_shop_group);
return $context_shop_group;
}
/**
* Add an sql restriction for shops fields
+1 -1
View File
@@ -561,7 +561,7 @@ class StockAvailableCore extends ObjectModel
$id_shop = $context->shop->id;
// if we are in $shop_group context
$shop_group = new ShopGroup((int)Shop::getContextShopGroupID());
$shop_group = Shop::getContextShopGroup();
// if quantities are shared between shops of the group
if ($shop_group->share_stock)