compatibility changes for php7.4

This commit is contained in:
shreesh arora
2021-04-28 21:00:13 +05:30
parent 86d6e1bbb6
commit 4130bdfbe8
6 changed files with 19 additions and 77 deletions

View File

@@ -377,7 +377,7 @@ class Crypt_Blowfish
for ($i = 0; $i < 18; $i++) {
$data = 0;
for ($j = 4; $j > 0; $j--) {
$data = $data << 8 | ord($key{$k});
$data = $data << 8 | ord($key[$k]);
$k = ($k + 1) % $len;
}
$this->_P[$i] ^= $data;

View File

@@ -180,7 +180,7 @@ class ConfigurationTestCore
public static function test_magicquotes()
{
return !get_magic_quotes_gpc();
return function_exists('get_magic_quotes_gpc') ? !get_magic_quotes_gpc() : true;
}
public static function test_upload()

View File

@@ -104,65 +104,7 @@ class ToolsCore
}
}
if (function_exists('mcrypt_create_iv')) {
$bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
if ($bytes !== false && strlen($bytes) === $length) {
return $bytes;
}
}
// Else try to get $length bytes of entropy.
// Thanks to Zend
$result = '';
$entropy = '';
$msec_per_round = 400;
$bits_per_round = 2;
$total = $length;
$hash_length = 20;
while (strlen($result) < $length) {
$bytes = ($total > $hash_length) ? $hash_length : $total;
$total -= $bytes;
for ($i=1; $i < 3; $i++) {
$t1 = microtime(true);
$seed = mt_rand();
for ($j=1; $j < 50; $j++) {
$seed = sha1($seed);
}
$t2 = microtime(true);
$entropy .= $t1 . $t2;
}
$div = (int) (($t2 - $t1) * 1000000);
if ($div <= 0) {
$div = 400;
}
$rounds = (int) ($msec_per_round * 50 / $div);
$iter = $bytes * (int) (ceil(8 / $bits_per_round));
for ($i = 0; $i < $iter; $i ++) {
$t1 = microtime();
$seed = sha1(mt_rand());
for ($j = 0; $j < $rounds; $j++) {
$seed = sha1($seed);
}
$t2 = microtime();
$entropy .= $t1 . $t2;
}
$result .= sha1($entropy, true);
}
return substr($result, 0, $length);
return false;
}
public static function strReplaceFirst($search, $replace, $subject, $cur = 0)
@@ -1822,10 +1764,10 @@ class ToolsCore
return Tools::strtoupper(Tools::substr($str, 0, 1)).Tools::substr($str, 1);
}
public static function ucwords($str)
public static function ucwords($str, $encoding = 'utf-8')
{
if (function_exists('mb_convert_case')) {
return mb_convert_case($str, MB_CASE_TITLE);
return mb_convert_case($str, MB_CASE_TITLE, $encoding);
}
return ucwords(Tools::strtolower($str));
}

View File

@@ -140,7 +140,7 @@ define('_PS_TMP_IMG_DIR_', _PS_IMG_DIR_.'tmp/');
define('_PS_TRANS_PATTERN_', '(.*[^\\\\])');
define('_PS_MIN_TIME_GENERATE_PASSWD_', '360');
if (!defined('_PS_MAGIC_QUOTES_GPC_')) {
define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
define('_PS_MAGIC_QUOTES_GPC_', function_exists('get_magic_quotes_gpc')? @get_magic_quotes_gpc() : false);
}
define('_CAN_LOAD_FILES_', 1);

View File

@@ -36,7 +36,7 @@ class AdminShopControllerCore extends AdminController
$this->table = 'shop';
$this->className = 'Shop';
$this->multishop_context = Shop::CONTEXT_ALL;
$this->id_shop_group = (int)Tools::getValue('id_shop_group');
/* if $_GET['id_shop'] is transmitted, virtual url can be loaded in config.php, so we wether transmit shop_id in herfs */
@@ -250,7 +250,7 @@ class AdminShopControllerCore extends AdminController
elseif (Shop::getTotalShops() == 1)
$this->errors[] = Tools::displayError('You cannot disable the last shop.');
}*/
if (Tools::isSubmit('submitAddshopAndStay') || Tools::isSubmit('submitAddshop')) {
$shop_group = new ShopGroup((int)Tools::getValue('id_shop_group'));
if ($shop_group->shopNameExists(Tools::getValue('name'), (int)Tools::getValue('id_shop'))) {
@@ -475,7 +475,7 @@ class AdminShopControllerCore extends AdminController
$root_category = new Category($root_categories[0]['id_category']);
$children = $root_category->getAllChildren($this->context->language->id);
$selected_cat[] = $root_categories[0]['id_category'];
foreach ($children as $child) {
$selected_cat[] = $child->id;
}
@@ -576,7 +576,7 @@ class AdminShopControllerCore extends AdminController
'zone' => $this->l('Zones'),
'cart_rule' => $this->l('Cart rules'),
);
// Hook for duplication of shop data
$modules_list = Hook::getHookModuleExecList('actionShopDataDuplication');
if (is_array($modules_list) && count($modules_list) > 0) {
@@ -586,7 +586,7 @@ class AdminShopControllerCore extends AdminController
}
asort($import_data);
if (!$this->object->id) {
$this->fields_import_form = array(
'radio' => array(
@@ -615,9 +615,9 @@ class AdminShopControllerCore extends AdminController
$this->fields_value = array(
'id_shop_group' => (Tools::getValue('id_shop_group') ? Tools::getValue('id_shop_group') :
(isset($obj->id_shop_group)) ? $obj->id_shop_group : Shop::getContextShopGroupID()),
((isset($obj->id_shop_group)) ? $obj->id_shop_group : Shop::getContextShopGroupID())),
'id_category' => (Tools::getValue('id_category') ? Tools::getValue('id_category') :
(isset($obj->id_category)) ? $obj->id_category : (int)Configuration::get('PS_HOME_CATEGORY')),
((isset($obj->id_category)) ? $obj->id_category : (int)Configuration::get('PS_HOME_CATEGORY'))),
'id_theme_checked' => (isset($obj->id_theme) ? $obj->id_theme : $id_theme)
);
@@ -653,7 +653,7 @@ class AdminShopControllerCore extends AdminController
if (Tools::isSubmit('id_category_default')) {
$_POST['id_category'] = (int)Tools::getValue('id_category_default');
}
/* Checking fields validity */
$this->validateRules();
@@ -711,13 +711,13 @@ class AdminShopControllerCore extends AdminController
if (!array_key_exists('Edit', self::$cache_lang)) {
self::$cache_lang['Edit'] = $this->l('Edit', 'Helper');
}
$tpl->assign(array(
'href' => $this->context->link->getAdminLink('AdminShop').'&shop_id='.(int)$id.'&update'.$this->table,
'action' => self::$cache_lang['Edit'],
'id' => $id
));
return $tpl->fetch();
} else {
return;
@@ -738,7 +738,7 @@ class AdminShopControllerCore extends AdminController
$root_category = new Category($root_categories[0]['id_category']);
$children = $root_category->getAllChildren($this->context->language->id);
$selected_cat[] = $root_categories[0]['id_category'];
foreach ($children as $child) {
$selected_cat[] = $child->id;
}

View File

@@ -1019,7 +1019,7 @@ class AdminTranslationsControllerCore extends AdminController
$arr_good_ext = array('.tpl', '.php');
foreach ($files as $key => $file) {
if ($file{0} === '.' || in_array(substr($file, 0, strrpos($file, '.')), $this->all_iso_lang)) {
if ($file[0] === '.' || in_array(substr($file, 0, strrpos($file, '.')), $this->all_iso_lang)) {
unset($files[$key]);
} elseif ($type_clear === 'file' && !in_array(substr($file, strrpos($file, '.')), $arr_good_ext)) {
unset($files[$key]);
@@ -2872,7 +2872,7 @@ class AdminTranslationsControllerCore extends AdminController
$initial_root_dir = $root_dir;
foreach ($modules as $module) {
$root_dir = $initial_root_dir;
if ($module{0} == '.') {
if ($module[0] == '.') {
continue;
}