Skip to content

Commit

Permalink
Merge pull request Qloapps#32 from shreesh-webkul/qlo-fix-install
Browse files Browse the repository at this point in the history
Fixed QloApps install issues
  • Loading branch information
shreesh-webkul authored Feb 4, 2022
2 parents 74b1479 + 7a1da36 commit b20b79a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
8 changes: 7 additions & 1 deletion classes/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ public function __construct($name, $path = '', $expire = null, $shared_urls = nu
$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();
Expand Down
2 changes: 1 addition & 1 deletion classes/ImageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static function getFormatedName($name)
$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;
Expand Down
1 change: 0 additions & 1 deletion config/defines_uri.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@
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');
8 changes: 4 additions & 4 deletions controllers/admin/AdminModulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -166,11 +164,13 @@ public function setMedia()

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';
Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/AdminThemesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,7 @@ private function getNativeModule($type = 0)
{
$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;
}
}
Expand Down
9 changes: 3 additions & 6 deletions install/models/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -69,6 +70,7 @@ public function generateSettingsFile($database_server, $database_login, $databas
$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(
Expand All @@ -82,17 +84,12 @@ public function generateSettingsFile($database_server, $database_login, $databas
'_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 = "<?php\n";

foreach ($settings_constants as $constant => $value) {
Expand Down
4 changes: 2 additions & 2 deletions modules/dashavailability/dashavailability.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function hookDashboardData($params)
"key" => $this->l("Availabilities"),
"border_color" => "#11f0fc",
"color" => "#72C3F0",
),
)
);
$data[] = $availability_data;

Expand All @@ -110,7 +110,7 @@ public function hookDashboardData($params)
"key" => $this->l("Availabilities"),
"border_color" => "#11f0fc",
"color" => "#72C3F0",
),
)
);
$data[] = $availability_data;
}
Expand Down

0 comments on commit b20b79a

Please sign in to comment.