diff --git a/admin-dev/tabs/AdminPerformance.php b/admin-dev/tabs/AdminPerformance.php deleted file mode 100644 index e9a8f5ad0..000000000 --- a/admin-dev/tabs/AdminPerformance.php +++ /dev/null @@ -1,525 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class AdminPerformance extends AdminTab -{ - public function postProcess() - { - if (Tools::isSubmit('submitCaching')) - { - if ($this->tabAccess['edit'] === '1') - { - $settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php'); - if (!Tools::getValue('active')) - $cache_active = 0; - else - $cache_active = 1; - if (!$caching_system = Tools::getValue('caching_system')) - $this->_errors[] = Tools::displayError('Caching system is missing'); - else - $settings = preg_replace('/define\(\'_PS_CACHING_SYSTEM_\', \'([a-z0-9=\/+-_]+)\'\);/Ui', 'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');', $settings); - if ($cache_active && $caching_system == 'CacheMemcache' && !extension_loaded('memcache')) - $this->_errors[] = Tools::displayError('To use Memcached, you must install the Memcache PECL extension on your server.').' http://www.php.net/manual/en/memcache.installation.php'; - else if ($cache_active && $caching_system == 'CacheApc' && !extension_loaded('apc')) - $this->_errors[] = Tools::displayError('To use APC cache, you must install the APC PECL extension on your server.').' http://fr.php.net/manual/fr/apc.installation.php'; - else if ($cache_active && $caching_system == 'CacheXcache' && !extension_loaded('xcache')) - $this->_errors[] = Tools::displayError('To use Xcache, you must install the Xcache extension on your server.').' http://xcache.lighttpd.net'; - else if ($cache_active && $caching_system == 'CacheFs' && !is_writable(_PS_CACHEFS_DIRECTORY_)) - $this->_errors[] = Tools::displayError('To use CacheFS the directory').' '.realpath(_PS_CACHEFS_DIRECTORY_).' '.Tools::displayError('must be writable'); - - if ($caching_system == 'CacheFs') - { - if (!($depth = Tools::getValue('ps_cache_fs_directory_depth'))) - $this->_errors[] = Tools::displayError('Please set a directory depth'); - if (!sizeof($this->_errors)) - { - CacheFs::deleteCacheDirectory(); - CacheFs::createCacheDirectories((int)$depth); - Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int)$depth); - } - } - if (!sizeof($this->_errors)) - { - $settings = preg_replace('/define\(\'_PS_CACHE_ENABLED_\', \'([0-9])\'\);/Ui', 'define(\'_PS_CACHE_ENABLED_\', \''.(int)$cache_active.'\');', $settings); - if (file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $settings)) - Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); - else - $this->_errors[] = Tools::displayError('Cannot overwrite settings file.'); - } - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - if (Tools::isSubmit('submitAddServer')) - { - if ($this->tabAccess['add'] === '1') - { - if (!Tools::getValue('memcachedIp')) - $this->_errors[] = Tools::displayError('Memcached IP is missing'); - if (!Tools::getValue('memcachedPort')) - $this->_errors[] = Tools::displayError('Memcached port is missing'); - if (!Tools::getValue('memcachedWeight')) - $this->_errors[] = Tools::displayError('Memcached weight is missing'); - if (!sizeof($this->_errors)) - { - if (CacheMemcache::addServer(pSQL(Tools::getValue('memcachedIp')), (int)Tools::getValue('memcachedPort'), (int)Tools::getValue('memcachedWeight'))) - Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); - else - $this->_errors[] = Tools::displayError('Cannot add Memcached server'); - } - } - else - $this->_errors[] = Tools::displayError('You do not have permission to add here.'); - } - if (Tools::getValue('deleteMemcachedServer')) - { - if ($this->tabAccess['add'] === '1') - { - if (CacheMemcache::deleteServer((int)Tools::getValue('deleteMemcachedServer'))) - Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); - else - $this->_errors[] = Tools::displayError('Error in deleting Memcached server'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); - } - - if (Tools::isSubmit('submitCiphering') AND Configuration::get('PS_CIPHER_ALGORITHM') != (int)Tools::getValue('PS_CIPHER_ALGORITHM')) - { - if ($this->tabAccess['edit'] === '1') - { - $algo = (int)Tools::getValue('PS_CIPHER_ALGORITHM'); - $settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php'); - if ($algo) - { - if (!function_exists('mcrypt_encrypt')) - $this->_errors[] = Tools::displayError('Mcrypt is not activated on this server.'); - else - { - if (!strstr($settings, '_RIJNDAEL_KEY_')) - { - $key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); - $key = Tools::passwdGen($key_size); - $settings = preg_replace('/define\(\'_COOKIE_KEY_\', \'([a-z0-9=\/+-_]+)\'\);/i', 'define(\'_COOKIE_KEY_\', \'\1\');'."\n".'define(\'_RIJNDAEL_KEY_\', \''.$key.'\');', $settings); - } - if (!strstr($settings, '_RIJNDAEL_IV_')) - { - $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); - $iv = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND)); - $settings = preg_replace('/define\(\'_COOKIE_IV_\', \'([a-z0-9=\/+-_]+)\'\);/i', 'define(\'_COOKIE_IV_\', \'\1\');'."\n".'define(\'_RIJNDAEL_IV_\', \''.$iv.'\');', $settings); - } - } - } - if (!count($this->_errors)) - { - if (file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $settings)) - { - Configuration::updateValue('PS_CIPHER_ALGORITHM', $algo); - Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); - } - else - $this->_errors[] = Tools::displayError('Cannot overwrite settings file.'); - } - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - - if (Tools::isSubmit('submitCCC')) - { - if ($this->tabAccess['edit'] === '1') - { - if ( - !Configuration::updateValue('PS_CSS_THEME_CACHE', (int)Tools::getValue('PS_CSS_THEME_CACHE')) OR - !Configuration::updateValue('PS_JS_THEME_CACHE', (int)Tools::getValue('PS_JS_THEME_CACHE')) OR - !Configuration::updateValue('PS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HTML_THEME_COMPRESSION')) OR - !Configuration::updateValue('PS_JS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_JS_HTML_THEME_COMPRESSION')) OR - !Configuration::updateValue('PS_HIGH_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HIGH_HTML_THEME_COMPRESSION')) - ) - $this->_errors[] = Tools::displayError('Unknown error.'); - else - Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - if (Tools::isSubmit('submitMediaServers')) - { - if ($this->tabAccess['edit'] === '1') - { - if (Tools::getValue('_MEDIA_SERVER_1_') != NULL AND !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_1_'))) - $this->_errors[] = Tools::displayError('Media server #1 is invalid'); - if (Tools::getValue('_MEDIA_SERVER_2_') != NULL AND !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_2_'))) - $this->_errors[] = Tools::displayError('Media server #2 is invalid'); - if (Tools::getValue('_MEDIA_SERVER_3_') != NULL AND !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_3_'))) - $this->_errors[] = Tools::displayError('Media server #3 is invalid'); - if (!sizeof($this->_errors)) - { - $baseUrls = array(); - $baseUrls['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_'); - $baseUrls['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_'); - $baseUrls['_MEDIA_SERVER_3_'] = Tools::getValue('_MEDIA_SERVER_3_'); - rewriteSettingsFile($baseUrls, NULL, NULL); - unset($this->_fieldsGeneral['_MEDIA_SERVER_1_']); - unset($this->_fieldsGeneral['_MEDIA_SERVER_2_']); - unset($this->_fieldsGeneral['_MEDIA_SERVER_3_']); - Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); - } - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - if (Tools::isSubmit('submitSmartyConfig')) - { - if ($this->tabAccess['edit'] === '1') - { - Configuration::updateValue('PS_SMARTY_FORCE_COMPILE', Tools::getValue('smarty_force_compile', _PS_SMARTY_NO_COMPILE_)); - Configuration::updateValue('PS_SMARTY_CACHE', Tools::getValue('smarty_cache', 0)); - Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - if (Tools::isSubmit('submitFeaturesDetachables')) - { - if ($this->tabAccess['edit'] === '1') - { - if (!Combination::isCurrentlyUsed()) - Configuration::updateValue('PS_COMBINATION_FEATURE_ACTIVE', Tools::getValue('combination')); - Configuration::updateValue('PS_FEATURE_FEATURE_ACTIVE', Tools::getValue('feature')); - Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4'); - } - else - $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); - } - return parent::postProcess(); - } - - public function display() - { - $warnings = array(); - if (!extension_loaded('memcache')) - $warnings[] = $this->l('To use Memcached, you must install the Memcache PECL extension on your server.').' http://www.php.net/manual/en/memcache.installation.php'; - if (!extension_loaded('apc')) - $warnings[] = $this->l('To use APC, you must install the APC PECL extension on your server.').' http://fr.php.net/manual/fr/apc.installation.php'; - if (!extension_loaded('xcache')) - $warnings[] = $this->l('To use Xcache, you must install the Xcache extension on your server.').' http://xcache.lighttpd.net'; - - if(!is_writable(_PS_CACHEFS_DIRECTORY_)) - $warnings[] = $this->l('To use CacheFS the directory').' '.realpath(_PS_CACHEFS_DIRECTORY_).' '.$this->l('must be writable'); - - if ($warnings) - $this->displayWarning($warnings); - - echo ' - '; - - echo ' -
'; - - echo ' - '; - - echo ' - '; - - echo ''; - - echo ' - - '; - - $depth = Configuration::get('PS_CACHEFS_DIRECTORY_DEPTH'); - echo ''; - } -} - - diff --git a/admin-dev/themes/template/helper/form/form.tpl b/admin-dev/themes/template/helper/form/form.tpl index f0e98d29e..7f36532b9 100644 --- a/admin-dev/themes/template/helper/form/form.tpl +++ b/admin-dev/themes/template/helper/form/form.tpl @@ -24,6 +24,7 @@ * International Registered Trademark & Property of PrestaShop SA *} +{if !$firstCall}