From 7a1da36f8f17d3440ec18fcce000fd6604445613 Mon Sep 17 00:00:00 2001 From: shreesh arora Date: Fri, 4 Feb 2022 13:08:49 +0530 Subject: [PATCH] Fixed QloApps install issues --- classes/Cookie.php | 8 +++++++- classes/ImageType.php | 2 +- config/defines_uri.inc.php | 1 - controllers/admin/AdminModulesController.php | 8 ++++---- controllers/admin/AdminThemesController.php | 2 +- install/models/install.php | 9 +++------ modules/dashavailability/dashavailability.php | 4 ++-- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/classes/Cookie.php b/classes/Cookie.php index 77115986a..920415da6 100644 --- a/classes/Cookie.php +++ b/classes/Cookie.php @@ -76,7 +76,13 @@ class CookieCore $this->_name = 'PrestaShop-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain); $this->_allow_writing = true; $this->_salt = $this->_standalone ? str_pad('', 8, md5('ps'.__FILE__)) : _COOKIE_IV_; - $this->_cipherTool = new PhpEncryption(_NEW_COOKIE_KEY_); + if ($this->_standalone) { + $asciiSafeString = \Defuse\Crypto\Encoding::saveBytesToChecksummedAsciiSafeString(Key::KEY_CURRENT_VERSION, str_pad($name, Key::KEY_BYTE_SIZE, md5(__FILE__))); + $this->_cipherTool = new PhpEncryption($asciiSafeString); + } else { + $this->_cipherTool = new PhpEncryption(_NEW_COOKIE_KEY_); + } + $this->_secure = (bool)$secure; $this->update(); diff --git a/classes/ImageType.php b/classes/ImageType.php index 9df4f02c8..df48d21da 100644 --- a/classes/ImageType.php +++ b/classes/ImageType.php @@ -169,7 +169,7 @@ class ImageTypeCore extends ObjectModel $name_without_theme_name = str_replace(array('_'.$theme_name, $theme_name.'_'), '', $name); //check if the theme name is already in $name if yes only return $name - if (strstr($name, $theme_name) && self::getByNameNType($name)) { + if ($theme_name !== null && strstr($name, $theme_name) && self::getByNameNType($name)) { return $name; } elseif (self::getByNameNType($name_without_theme_name.'_'.$theme_name)) { return $name_without_theme_name.'_'.$theme_name; diff --git a/config/defines_uri.inc.php b/config/defines_uri.inc.php index 8e5970337..a8ad26666 100644 --- a/config/defines_uri.inc.php +++ b/config/defines_uri.inc.php @@ -86,4 +86,3 @@ Tools::safeDefine('_PS_CURRENCY_FEED_URL_', _PS_API_URL_.'/xml/curren Tools::safeDefine('_QLO_API_DOMAIN_', 'api.qloapps.com'); Tools::safeDefine('_QLO_API_URL_', 'http://'._QLO_API_DOMAIN_); Tools::safeDefine('_QLO_TAB_MODULE_LIST_URL_', _QLO_API_URL_.'/xml/tab_modules_list.xml'); -Tools::safeDefine('_QLO_NATIVE_MODULES_LIST_',_QLO_API_DOMAIN_.'/xml/'.str_replace('.', '', _QLOAPPS_VERSION_).'.xml'); diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index 44e60ce86..2e9a2e165 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -60,8 +60,6 @@ class AdminModulesControllerCore extends AdminController protected $iso_default_country; protected $filter_configuration = array(); - protected $xml_modules_list = _QLO_NATIVE_MODULES_LIST_; - /** * Admin Modules Controller Constructor * Init list modules categories @@ -166,11 +164,13 @@ class AdminModulesControllerCore extends AdminController public function ajaxProcessRefreshModuleList($force_reload_cache = false) { + $xml_modules_list = _QLO_API_DOMAIN_.'/xml/'.str_replace('.', '', _QLOAPPS_VERSION_).'.xml'; + // Refresh modules_list.xml every week if (!$this->isFresh(Module::CACHE_FILE_MODULES_LIST, 86400) || $force_reload_cache) { - if ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'https://'.$this->xml_modules_list)) { + if ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'https://'.$xml_modules_list)) { $this->status = 'refresh'; - } elseif ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'http://'.$this->xml_modules_list)) { + } elseif ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'http://'.$xml_modules_list)) { $this->status = 'refresh'; } else { $this->status = 'error'; diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index cb7f742dc..2b9f6d16b 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -2041,7 +2041,7 @@ class AdminThemesControllerCore extends AdminController { $protocols = array('https://', 'http://'); foreach ($protocols as $protocol) { - if($xml = @simplexml_load_string(Tools::file_get_contents($protocol._QLO_NATIVE_MODULES_LIST_))) { + if($xml = @simplexml_load_string(Tools::file_get_contents($protocol._QLO_API_DOMAIN_.'/xml/'.str_replace('.', '', _QLOAPPS_VERSION_).'.xml'))) { break; } } diff --git a/install/models/install.php b/install/models/install.php index 169273b17..a50b62ac6 100644 --- a/install/models/install.php +++ b/install/models/install.php @@ -23,6 +23,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ +require_once (_PS_TOOL_DIR_.'defuse/php-encryption/defuse-crypto.phar'); class InstallModelInstall extends InstallAbstractModel { @@ -69,6 +70,7 @@ class InstallModelInstall extends InstallAbstractModel $this->setError($this->language->l('%s folder is not writable (check permissions)', dirname(self::SETTINGS_FILE))); return false; } + $key = \Defuse\Crypto\Key::createNewRandomKey(); // Generate settings content and write file $settings_constants = array( @@ -82,17 +84,12 @@ class InstallModelInstall extends InstallAbstractModel '_PS_CACHE_ENABLED_' => '0', '_COOKIE_KEY_' => Tools::passwdGen(56), '_COOKIE_IV_' => Tools::passwdGen(8), + '_NEW_COOKIE_KEY_' => $key->saveToAsciiSafeString(), '_PS_CREATION_DATE_' => date('Y-m-d'), '_PS_VERSION_' => _PS_INSTALL_VERSION_, '_QLOAPPS_VERSION_' => _QLO_INSTALL_VERSION_, ); - // If mcrypt is activated, add Rijndael 128 configuration - if (function_exists('mcrypt_encrypt')) { - $settings_constants['_RIJNDAEL_KEY_'] = Tools::passwdGen(mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); - $settings_constants['_RIJNDAEL_IV_'] = base64_encode(mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND)); - } - $settings_content = " $value) { diff --git a/modules/dashavailability/dashavailability.php b/modules/dashavailability/dashavailability.php index f5ddb5f6b..35a3a2fd9 100644 --- a/modules/dashavailability/dashavailability.php +++ b/modules/dashavailability/dashavailability.php @@ -94,7 +94,7 @@ class DashAvailability extends Module "key" => $this->l("Availabilities"), "border_color" => "#11f0fc", "color" => "#72C3F0", - ), + ) ); $data[] = $availability_data; @@ -110,7 +110,7 @@ class DashAvailability extends Module "key" => $this->l("Availabilities"), "border_color" => "#11f0fc", "color" => "#72C3F0", - ), + ) ); $data[] = $availability_data; }