From 6d665618659f8ca94a8758dc191349e669c9471d Mon Sep 17 00:00:00 2001 From: shreesh arora Date: Sun, 2 May 2021 17:31:17 +0530 Subject: [PATCH] remove cypher configuration from performance controller --- .../admin/AdminPerformanceController.php | 89 ------------------- 1 file changed, 89 deletions(-) diff --git a/controllers/admin/AdminPerformanceController.php b/controllers/admin/AdminPerformanceController.php index 5f2e4f9b7..3bd340a1b 100644 --- a/controllers/admin/AdminPerformanceController.php +++ b/controllers/admin/AdminPerformanceController.php @@ -460,49 +460,6 @@ class AdminPerformanceControllerCore extends AdminController $this->fields_value['_MEDIA_SERVER_3_'] = Configuration::get('PS_MEDIA_SERVER_3'); } - public function initFieldsetCiphering() - { - $phpdoc_langs = array('en', 'zh', 'fr', 'de', 'ja', 'pl', 'ro', 'ru', 'fa', 'es', 'tr'); - $php_lang = in_array($this->context->language->iso_code, $phpdoc_langs) ? $this->context->language->iso_code : 'en'; - - $warning_mcrypt = ' '.$this->l('(you must install the [a]Mcrypt extension[/a])'); - $warning_mcrypt = str_replace('[a]', '', $warning_mcrypt); - $warning_mcrypt = str_replace('[/a]', '', $warning_mcrypt); - - if (defined('_RIJNDAEL_KEY_') && defined('_RIJNDAEL_IV_')) { - $this->fields_form[5]['form'] = array( - - 'legend' => array( - 'title' => $this->l('Ciphering'), - 'icon' => 'icon-desktop' - ), - 'input' => array( - array( - 'type' => 'hidden', - 'name' => 'ciphering_up' - ), - array( - 'type' => 'radio', - 'label' => $this->l('Algorithm'), - 'name' => 'PS_CIPHER_ALGORITHM', - 'values' => array( - array( - 'id' => 'PS_CIPHER_ALGORITHM_1', - 'value' => 1, - 'label' => $this->l('Use Rijndael with mcrypt lib.').(function_exists('mcrypt_encrypt') ? '' : $warning_mcrypt) - ), - ) - ) - ), - 'submit' => array( - 'title' => $this->l('Save') - ) - ); - } - - $this->fields_value['PS_CIPHER_ALGORITHM'] = Configuration::get('PS_CIPHER_ALGORITHM'); - } - public function initFieldsetCaching() { $phpdoc_langs = array('en', 'zh', 'fr', 'de', 'ja', 'pl', 'ro', 'ru', 'fa', 'es', 'tr'); @@ -618,7 +575,6 @@ class AdminPerformanceControllerCore extends AdminController if (!defined('_PS_HOST_MODE_')) { $this->initFieldsetMediaServer(); - $this->initFieldsetCiphering(); $this->initFieldsetCaching(); } @@ -840,51 +796,6 @@ class AdminPerformanceControllerCore extends AdminController $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } - if ((bool)Tools::getValue('ciphering_up') && Configuration::get('PS_CIPHER_ALGORITHM') != (int)Tools::getValue('PS_CIPHER_ALGORITHM')) { - if ($this->tabAccess['edit'] === '1') { - $algo = (int)Tools::getValue('PS_CIPHER_ALGORITHM'); - $prev_settings = file_get_contents(_PS_ROOT_DIR_.'/config/settings.inc.php'); - $new_settings = $prev_settings; - if ($algo) { - if (!function_exists('mcrypt_encrypt')) { - $this->errors[] = Tools::displayError('The "Mcrypt" PHP extension is not activated on this server.'); - } else { - if (!strstr($new_settings, '_RIJNDAEL_KEY_')) { - $key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); - $key = Tools::passwdGen($key_size); - $new_settings = preg_replace( - '/define\(\'_COOKIE_KEY_\', \'([a-z0-9=\/+-_]+)\'\);/i', - 'define(\'_COOKIE_KEY_\', \'\1\');'."\n".'define(\'_RIJNDAEL_KEY_\', \''.$key.'\');', - $new_settings - ); - } - if (!strstr($new_settings, '_RIJNDAEL_IV_')) { - $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); - $iv = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND)); - $new_settings = preg_replace( - '/define\(\'_COOKIE_IV_\', \'([a-z0-9=\/+-_]+)\'\);/i', - 'define(\'_COOKIE_IV_\', \'\1\');'."\n".'define(\'_RIJNDAEL_IV_\', \''.$iv.'\');', - $new_settings - ); - } - } - } - if (!count($this->errors)) { - // If there is not settings file modification or if the backup and replacement of the settings file worked - if ($new_settings == $prev_settings || ( - copy(_PS_ROOT_DIR_.'/config/settings.inc.php', _PS_ROOT_DIR_.'/config/settings.old.php') - && (bool)file_put_contents(_PS_ROOT_DIR_.'/config/settings.inc.php', $new_settings) - )) { - Configuration::updateValue('PS_CIPHER_ALGORITHM', $algo); - $redirectAdmin = true; - } else { - $this->errors[] = Tools::displayError('The settings file cannot be overwritten.'); - } - } - } else { - $this->errors[] = Tools::displayError('You do not have permission to edit this.'); - } - } if ((bool)Tools::getValue('cache_up')) { if ($this->tabAccess['edit'] === '1') {