本文整理汇总了PHP中Validate::isFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isFileName方法的具体用法?PHP Validate::isFileName怎么用?PHP Validate::isFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitLocalizationPack')) {
$version = str_replace('.', '', _PS_VERSION_);
$version = substr($version, 0, 2);
if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) {
$pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml');
if (!$pack && !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
$this->errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")');
}
if (!($selection = Tools::getValue('selection'))) {
$this->errors[] = Tools::displayError('Please select at least one item to import.');
} else {
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
$this->errors[] = Tools::displayError('Invalid selection');
return;
}
}
$localization_pack = new LocalizationPack();
if (!$localization_pack->loadLocalisationPack($pack, $selection)) {
$this->errors = array_merge($this->errors, $localization_pack->getErrors());
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
}
}
}
}
parent::postProcess();
}
示例2: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitLocalizationPack')) {
$version = str_replace('.', '', _PS_VERSION_);
$version = substr($version, 0, 2);
if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) {
$pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml');
if (!$pack && !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
$this->errors[] = Tools::displayError('Cannot load the localization pack.');
}
if (!($selection = Tools::getValue('selection'))) {
$this->errors[] = Tools::displayError('Please select at least one item to import.');
} else {
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
$this->errors[] = Tools::displayError('Invalid selection');
return;
}
}
$localization_pack = new LocalizationPack();
if (!$localization_pack->loadLocalisationPack($pack, $selection)) {
$this->errors = array_merge($this->errors, $localization_pack->getErrors());
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
}
}
}
}
// Remove the module list cache if the default country changed
if (Tools::isSubmit('submitOptionsconfiguration') && file_exists(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) {
@unlink(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
}
parent::postProcess();
}
示例3: postProcess
public function postProcess()
{
if (_PS_MODE_DEMO_) {
$this->errors[] = $this->trans('This functionality has been disabled.', array(), 'Admin.Notifications.Error');
return;
}
if (!extension_loaded('openssl')) {
$this->displayWarning($this->l('Importing a new language may fail without the OpenSSL module. Please enable "openssl.so" on your server configuration.'));
}
if (Tools::isSubmit('submitLocalizationPack')) {
$version = str_replace('.', '', _PS_VERSION_);
$version = substr($version, 0, 2);
if (($iso_localization_pack = Tools::getValue('iso_localization_pack')) && Validate::isFileName($iso_localization_pack)) {
if (Tools::getValue('download_updated_pack') == '1' || defined('_PS_HOST_MODE_')) {
$pack = @Tools::file_get_contents(_PS_API_URL_ . '/localization/' . $version . '/' . $iso_localization_pack . '.xml');
} else {
$pack = false;
}
if (defined('_PS_HOST_MODE_')) {
$path = _PS_CORE_DIR_ . '/localization/' . $iso_localization_pack . '.xml';
} else {
$path = _PS_ROOT_DIR_ . '/localization/' . $iso_localization_pack . '.xml';
}
if (!$pack && !($pack = @Tools::file_get_contents($path))) {
$this->errors[] = $this->trans('Cannot load the localization pack.', array(), 'Admin.International.Notification');
}
if (!($selection = Tools::getValue('selection'))) {
$this->errors[] = $this->trans('Please select at least one item to import.', array(), 'Admin.International.Notification');
} else {
foreach ($selection as $selected) {
if (!Validate::isLocalizationPackSelection($selected)) {
$this->errors[] = $this->trans('Invalid selection', array(), 'Admin.Notifications.Error');
return;
}
}
$localization_pack = new LocalizationPack();
if (!$localization_pack->loadLocalisationPack($pack, $selection, false, $iso_localization_pack)) {
$this->errors = array_merge($this->errors, $localization_pack->getErrors());
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
}
}
}
}
// Remove the module list cache if the default country changed
if (Tools::isSubmit('submitOptionsconfiguration') && file_exists(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) {
@unlink(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
}
parent::postProcess();
}
示例4: postProcess
public function postProcess()
{
// Getting key value for display
if (Tools::getValue('show_modules') && strval(Tools::getValue('show_modules')) != 'all') {
$this->display_key = (int) Tools::getValue('show_modules');
}
// Change position in hook
if (array_key_exists('changePosition', $_GET)) {
if ($this->tabAccess['edit'] === '1') {
$id_module = (int) Tools::getValue('id_module');
$id_hook = (int) Tools::getValue('id_hook');
$module = Module::getInstanceById($id_module);
if (Validate::isLoadedObject($module)) {
$module->updatePosition($id_hook, (int) Tools::getValue('direction'));
Tools::redirectAdmin(self::$currentIndex . ($this->display_key ? '&show_modules=' . $this->display_key : '') . '&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('This module cannot be loaded');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitAddToHook')) {
if ($this->tabAccess['add'] === '1') {
// Getting vars...
$id_module = (int) Tools::getValue('id_module');
$module = Module::getInstanceById($id_module);
$id_hook = (int) Tools::getValue('id_hook');
$hook = new Hook($id_hook);
if (!$id_module || !Validate::isLoadedObject($module)) {
$this->errors[] = Tools::displayError('This module cannot be loaded');
} elseif (!$id_hook || !Validate::isLoadedObject($hook)) {
$this->errors[] = Tools::displayError('Hook cannot be loaded.');
} elseif (Hook::getModulesFromHook($id_hook, $id_module)) {
$this->errors[] = Tools::displayError('This module has already been transplanted to this hook');
} elseif (!$module->isHookableOn($hook->name)) {
$this->errors[] = Tools::displayError('This module cannot be transplanted to this hook.');
} else {
if (!$module->registerHook($hook->name, Shop::getContextListShopID())) {
$this->errors[] = Tools::displayError('An error occurred while transplanting the module to its hook.');
} else {
$exceptions = Tools::getValue('exceptions');
$exceptions = isset($exceptions[0]) ? $exceptions[0] : array();
$exceptions = explode(',', str_replace(' ', '', $exceptions));
foreach ($exceptions as $key => $except) {
if (empty($except)) {
unset($exceptions[$key]);
} else {
if (!Validate::isFileName($except)) {
$this->errors[] = Tools::displayError('No valid value for field exceptions has been defined.');
}
}
}
if (!$this->errors && !$module->registerExceptions($id_hook, $exceptions, Shop::getContextListShopID())) {
$this->errors[] = Tools::displayError('An error occurred while transplanting the module to its hook.');
}
}
if (!$this->errors) {
Tools::redirectAdmin(self::$currentIndex . '&conf=16' . ($this->display_key ? '&show_modules=' . $this->display_key : '') . '&token=' . $this->token);
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to add this.');
}
} elseif (Tools::isSubmit('submitEditGraft')) {
if ($this->tabAccess['add'] === '1') {
// Getting vars...
$id_module = (int) Tools::getValue('id_module');
$module = Module::getInstanceById($id_module);
$id_hook = (int) Tools::getValue('id_hook');
$hook = new Hook($id_hook);
if (!$id_module || !Validate::isLoadedObject($module)) {
$this->errors[] = Tools::displayError('This module cannot be loaded');
} elseif (!$id_hook || !Validate::isLoadedObject($hook)) {
$this->errors[] = Tools::displayError('Hook cannot be loaded.');
} else {
$exceptions = Tools::getValue('exceptions');
if (is_array($exceptions)) {
foreach ($exceptions as $id => $exception) {
$exception = explode(',', str_replace(' ', '', $exception));
// Check files name
foreach ($exception as $except) {
if (!Validate::isFileName($except)) {
$this->errors[] = Tools::displayError('No valid value for field exceptions has been defined.');
}
}
$exceptions[$id] = $exception;
}
// Add files exceptions
if (!$module->editExceptions($id_hook, $exceptions)) {
$this->errors[] = Tools::displayError('An error occurred while transplanting the module to its hook.');
}
if (!$this->errors) {
Tools::redirectAdmin(self::$currentIndex . '&conf=16' . ($this->display_key ? '&show_modules=' . $this->display_key : '') . '&token=' . $this->token);
}
} else {
$exceptions = explode(',', str_replace(' ', '', $exceptions));
// Check files name
foreach ($exceptions as $except) {
if (!Validate::isFileName($except)) {
$this->errors[] = Tools::displayError('No valid value for field exceptions has been defined.');
//.........这里部分代码省略.........
示例5: init
public function init()
{
if (isset($this->context->employee) && $this->context->employee->isLoggedBack() && Tools::getValue('file')) {
// Admin can directly access to file
$filename = Tools::getValue('file');
if (!Validate::isSha1($filename)) {
die(Tools::displayError());
}
$file = _PS_DOWNLOAD_DIR_ . strval(preg_replace('/\\.{2,}/', '.', $filename));
$filename = ProductDownload::getFilenameFromFilename(Tools::getValue('file'));
if (empty($filename)) {
$newFileName = Tools::getValue('filename');
if (!empty($newFileName)) {
$filename = Tools::getValue('filename');
} else {
$filename = 'file';
}
}
if (!file_exists($file)) {
Tools::redirect('index.php');
}
} else {
if (!($key = Tools::getValue('key'))) {
$this->displayCustomError('Invalid key.');
}
Tools::setCookieLanguage();
if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key') && !Tools::getValue('id_order')) {
Tools::redirect('index.php?controller=authentication&back=get-file.php&key=' . $key);
} else {
if (!$this->context->customer->isLogged() && Tools::getValue('secure_key') && Tools::getValue('id_order')) {
$order = new Order((int) Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
$this->displayCustomError('Invalid key.');
}
if ($order->secure_key != Tools::getValue('secure_key')) {
$this->displayCustomError('Invalid key.');
}
}
}
/* Key format: <sha1-filename>-<hashOrder> */
$tmp = explode('-', $key);
if (count($tmp) != 2) {
$this->displayCustomError('Invalid key.');
}
$filename = $tmp[0];
$hash = $tmp[1];
if (!($info = OrderDetail::getDownloadFromHash($hash))) {
$this->displayCustomError('This product does not exist in our store.');
}
/* Product no more present in catalog */
if (!isset($info['id_product_download']) || empty($info['id_product_download'])) {
$this->displayCustomError('This product has been deleted.');
}
if (!Validate::isFileName($info['filename']) || !file_exists(_PS_DOWNLOAD_DIR_ . $info['filename'])) {
$this->displayCustomError('This file no longer exists.');
}
if (isset($info['product_quantity_refunded']) && isset($info['product_quantity_return']) && ($info['product_quantity_refunded'] > 0 || $info['product_quantity_return'] > 0)) {
$this->displayCustomError('This product has been refunded.');
}
$now = time();
$product_deadline = strtotime($info['download_deadline']);
if ($now > $product_deadline && $info['download_deadline'] != '0000-00-00 00:00:00') {
$this->displayCustomError('The product deadline is in the past.');
}
$customer_deadline = strtotime($info['date_expiration']);
if ($now > $customer_deadline && $info['date_expiration'] != '0000-00-00 00:00:00') {
$this->displayCustomError('Expiration date has passed, you cannot download this product');
}
if ($info['download_nb'] >= $info['nb_downloadable'] && $info['nb_downloadable']) {
$this->displayCustomError('You have reached the maximum number of allowed downloads.');
}
/* Access is authorized -> increment download value for the customer */
OrderDetail::incrementDownload($info['id_order_detail']);
$file = _PS_DOWNLOAD_DIR_ . $info['filename'];
$filename = $info['display_filename'];
}
/* Detect mime content type */
$mimeType = false;
if (function_exists('finfo_open')) {
$finfo = @finfo_open(FILEINFO_MIME);
$mimeType = @finfo_file($finfo, $file);
@finfo_close($finfo);
} else {
if (function_exists('mime_content_type')) {
$mimeType = @mime_content_type($file);
} else {
if (function_exists('exec')) {
$mimeType = trim(@exec('file -b --mime-type ' . escapeshellarg($file)));
if (!$mimeType) {
$mimeType = trim(@exec('file --mime ' . escapeshellarg($file)));
}
if (!$mimeType) {
$mimeType = trim(@exec('file -bi ' . escapeshellarg($file)));
}
}
}
}
if (empty($mimeType)) {
$bName = basename($filename);
$bName = explode('.', $bName);
//.........这里部分代码省略.........
示例6: isAllowedExt
public static function isAllowedExt($file, $allowedExts)
{
if (!Validate::isFileName($file) or !is_array($allowedExts)) {
return false;
}
$extension = pathinfo($file, PATHINFO_EXTENSION);
return $extension;
if (in_array($extension, $allowedExts)) {
return true;
}
return false;
}
示例7: processUploadFile
public function processUploadFile($dest)
{
switch ($_FILES['themearchive']['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$this->errors[] = $this->trans('The uploaded file is too large.', array(), 'Admin.Design.Notification');
return false;
default:
$this->errors[] = $this->trans('Unknown error.', array(), 'Admin.Notifications.Error');
return false;
}
$finfo = new finfo(FILEINFO_MIME_TYPE);
$ext = array_search($finfo->file($_FILES['themearchive']['tmp_name']), array('zip' => 'application/zip'), true);
if ($ext === false) {
$this->errors[] = $this->trans('Invalid file format.', array(), 'Admin.Design.Notification');
return false;
}
$name = $_FILES['themearchive']['name'];
if (!Validate::isFileName($name)) {
$name = sha1_file($name) . $ext;
}
if (!move_uploaded_file($_FILES['themearchive']['tmp_name'], _PS_ALL_THEMES_DIR_ . $name)) {
$this->errors[] = $this->trans('Failed to move uploaded file.', array(), 'Admin.Design.Notification');
return false;
}
return true;
}
示例8: openUploadedFile
protected function openUploadedFile()
{
$filename = $_GET['filename'];
$extensions = array('.txt' => 'text/plain', '.rtf' => 'application/rtf', '.doc' => 'application/msword', '.docx' => 'application/msword', '.pdf' => 'application/pdf', '.zip' => 'multipart/x-zip', '.png' => 'image/png', '.jpeg' => 'image/jpeg', '.gif' => 'image/gif', '.jpg' => 'image/jpeg');
$extension = false;
foreach ($extensions as $key => $val) {
if (substr(Tools::strtolower($filename), -4) == $key || substr(Tools::strtolower($filename), -5) == $key) {
$extension = $val;
break;
}
}
if (!$extension || !Validate::isFileName($filename)) {
die(Tools::displayError());
}
if (ob_get_level() && ob_get_length() > 0) {
ob_end_clean();
}
header('Content-Type: ' . $extension);
header('Content-Disposition:attachment;filename="' . $filename . '"');
readfile(_PS_UPLOAD_DIR_ . $filename);
die;
}
示例9: postProcess
//.........这里部分代码省略.........
Tools::redirectAdmin($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 (MCached::deleteServer((int) Tools::getValue('deleteMemcachedServer'))) {
Tools::redirectAdmin($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($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($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($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', 0));
Configuration::updateValue('PS_SMARTY_CACHE', Tools::getValue('smarty_cache', 0));
Tools::redirectAdmin($currentIndex . '&token=' . Tools::getValue('token') . '&conf=4');
} else {
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
}
return parent::postProcess();
}
示例10: postProcess
public function postProcess()
{
global $currentIndex;
// Getting key value for display
if (Tools::getValue('show_modules') and strval(Tools::getValue('show_modules')) != 'all') {
$this->displayKey = (int) Tools::getValue('show_modules');
}
// Change position in hook
if (array_key_exists('changePosition', $_GET)) {
if ($this->tabAccess['edit'] === '1') {
$id_module = (int) Tools::getValue('id_module');
$id_hook = (int) Tools::getValue('id_hook');
$module = Module::getInstanceById($id_module);
if (Validate::isLoadedObject($module)) {
$module->updatePosition($id_hook, (int) Tools::getValue('direction'));
Tools::redirectAdmin($currentIndex . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token);
} else {
$this->_errors[] = Tools::displayError('module cannot be loaded');
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
} elseif (Tools::isSubmit('submitAddToHook')) {
if ($this->tabAccess['add'] === '1') {
// Getting vars...
$id_module = (int) Tools::getValue('id_module');
$module = Module::getInstanceById($id_module);
$id_hook = (int) Tools::getValue('id_hook');
$hook = new Hook($id_hook);
$excepts = explode(',', str_replace(' ', '', Tools::getValue('exceptions')));
// Checking vars...
foreach ($excepts as $except) {
if (!Validate::isFileName($except)) {
$this->_errors[] = Tools::displayError('No valid value for field exceptions');
}
}
if (!$id_module or !Validate::isLoadedObject($module)) {
$this->_errors[] = Tools::displayError('module cannot be loaded');
} elseif (!$id_hook or !Validate::isLoadedObject($hook)) {
$this->_errors[] = Tools::displayError('Hook cannot be loaded.');
} elseif (Hook::getModuleFromHook($id_hook, $id_module)) {
$this->_errors[] = Tools::displayError('This module is already transplanted to this hook.');
} elseif (!$module->isHookableOn($hook->name)) {
$this->_errors[] = Tools::displayError('This module cannot be transplanted to this hook.');
} elseif (!$module->registerHook($hook->name)) {
$this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
} elseif (!$module->registerExceptions($id_hook, $excepts)) {
$this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
} else {
Tools::redirectAdmin($currentIndex . '&conf=16' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token);
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
} elseif (Tools::isSubmit('submitEditGraft')) {
if ($this->tabAccess['add'] === '1') {
// Getting vars...
$id_module = (int) Tools::getValue('id_module');
$module = Module::getInstanceById($id_module);
$id_hook = (int) Tools::getValue('id_hook');
$hook = new Hook($id_hook);
$excepts = explode(',', str_replace(' ', '', Tools::getValue('exceptions')));
// Checking vars...
foreach ($excepts as $except) {
if (!Validate::isFileName($except)) {
$this->_errors[] = Tools::displayError('No valid value for field exceptions');
}
}
if (!$id_module or !Validate::isLoadedObject($module)) {
$this->_errors[] = Tools::displayError('module cannot be loaded');
} elseif (!$id_hook or !Validate::isLoadedObject($hook)) {
$this->_errors[] = Tools::displayError('Hook cannot be loaded.');
}
// Adding vars...
if (!$module->editExceptions($id_hook, $excepts)) {
$this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
} else {
Tools::redirectAdmin($currentIndex . '&conf=16' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token);
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
} elseif (array_key_exists('deleteGraft', $_GET)) {
if ($this->tabAccess['delete'] === '1') {
$id_module = (int) Tools::getValue('id_module');
$module = Module::getInstanceById($id_module);
$id_hook = (int) Tools::getValue('id_hook');
$hook = new Hook($id_hook);
if (!Validate::isLoadedObject($module)) {
$this->_errors[] = Tools::displayError('module cannot be loaded');
} elseif (!$id_hook or !Validate::isLoadedObject($hook)) {
$this->_errors[] = Tools::displayError('Hook cannot be loaded.');
} else {
$position = Db::getInstance()->getValue('SELECT `position` FROM `' . _DB_PREFIX_ . 'hook_module` hm WHERE hm.`id_hook` = ' . $id_hook . ' AND hm.`id_module` = ' . $id_module);
if (!$module->unregisterHook($id_hook) or !$module->unregisterExceptions($id_hook)) {
$this->_errors[] = Tools::displayError('An error occurred while deleting module from hook.');
} else {
$this->placeCorrectlyOtherModules($id_hook, $position);
Tools::redirectAdmin($currentIndex . '&conf=17' . ($this->displayKey ? '&show_modules=' . $this->displayKey : '') . '&token=' . $this->token);
}
//.........这里部分代码省略.........
示例11: header
$ctype = "image/jpg";
break;
default:
$ctype = "application/force-download";
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: {$ctype}");
header("Content-Disposition: attachment; filename=\"" . $filename . "_" . time() . ".mtpl\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($path));
readfile("{$path}");
exit;
}
$key = Tools::getValue('key', false);
$file = Tools::getValue('template', false);
if (!$key) {
die('Invalid token.');
} elseif (!Validate::isMd5($key) || !$key == md5(_COOKIE_KEY_)) {
die('Hack attempt.');
} elseif (!$file) {
die('Please specify file');
} elseif (!Validate::isFileName($file)) {
die('This isn\'t a valid file');
} elseif (!file_exists(dirname(__FILE__) . '/templates/' . $file . '.mtpl')) {
die('File does not exist.');
} else {
ForceDownload($file);
}
示例12: postProcess
//.........这里部分代码省略.........
$version = (int) Configuration::get('PS_CCCCSS_VERSION');
if (Configuration::get('PS_CSS_THEME_CACHE') != $tmp) {
Configuration::updateValue('PS_CCCCSS_VERSION', ++$version);
}
}
if ($tmp = (int) Tools::getValue('PS_JS_THEME_CACHE')) {
$version = (int) Configuration::get('PS_CCCJS_VERSION');
if (Configuration::get('PS_JS_THEME_CACHE') != $tmp) {
Configuration::updateValue('PS_CCCJS_VERSION', ++$version);
}
}
if (!Configuration::updateValue('PS_CSS_THEME_CACHE', (int) Tools::getValue('PS_CSS_THEME_CACHE')) || !Configuration::updateValue('PS_JS_THEME_CACHE', (int) Tools::getValue('PS_JS_THEME_CACHE')) || !Configuration::updateValue('PS_HTML_THEME_COMPRESSION', (int) Tools::getValue('PS_HTML_THEME_COMPRESSION')) || !Configuration::updateValue('PS_JS_HTML_THEME_COMPRESSION', (int) Tools::getValue('PS_JS_HTML_THEME_COMPRESSION')) || !Configuration::updateValue('PS_JS_DEFER', (int) Tools::getValue('PS_JS_DEFER')) || !Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int) Tools::getValue('PS_HTACCESS_CACHE_CONTROL'))) {
$this->errors[] = $this->trans('Unknown error.', array(), 'Admin.Notifications.Error');
} else {
$redirectAdmin = true;
if (Configuration::get('PS_HTACCESS_CACHE_CONTROL')) {
if (is_writable(_PS_ROOT_DIR_ . '/.htaccess')) {
Tools::generateHtaccess();
} else {
$message = $this->l('Before being able to use this tool, you need to:');
$message .= '<br />- ' . $this->l('Create a blank .htaccess in your root directory.');
$message .= '<br />- ' . $this->l('Give it write permissions (CHMOD 666 on Unix system).');
$this->errors[] = Tools::displayError($message, false);
Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', false);
}
}
}
} else {
$this->errors[] = $this->trans('You do not have permission to edit this.', array(), 'Admin.Notifications.Error');
}
}
if ((bool) Tools::getValue('media_server_up') && !defined('_PS_HOST_MODE_')) {
if ($this->access('edit')) {
if (Tools::getValue('_MEDIA_SERVER_1_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_1_'))) {
$this->errors[] = $this->trans('Media server #1 is invalid', array(), 'Admin.Parameters.Notification');
}
if (Tools::getValue('_MEDIA_SERVER_2_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_2_'))) {
$this->errors[] = $this->trans('Media server #2 is invalid', array(), 'Admin.Parameters.Notification');
}
if (Tools::getValue('_MEDIA_SERVER_3_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_3_'))) {
$this->errors[] = $this->trans('Media server #3 is invalid', array(), 'Admin.Parameters.Notification');
}
if (!count($this->errors)) {
$base_urls = array();
$base_urls['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_');
$base_urls['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_');
$base_urls['_MEDIA_SERVER_3_'] = Tools::getValue('_MEDIA_SERVER_3_');
if ($base_urls['_MEDIA_SERVER_1_'] || $base_urls['_MEDIA_SERVER_2_'] || $base_urls['_MEDIA_SERVER_3_']) {
Configuration::updateValue('PS_MEDIA_SERVERS', 1);
} else {
Configuration::updateValue('PS_MEDIA_SERVERS', 0);
}
rewriteSettingsFile($base_urls, null, null);
Configuration::updateValue('PS_MEDIA_SERVER_1', Tools::getValue('_MEDIA_SERVER_1_'));
Configuration::updateValue('PS_MEDIA_SERVER_2', Tools::getValue('_MEDIA_SERVER_2_'));
Configuration::updateValue('PS_MEDIA_SERVER_3', Tools::getValue('_MEDIA_SERVER_3_'));
Tools::clearSmartyCache();
Media::clearCache();
if (is_writable(_PS_ROOT_DIR_ . '/.htaccess')) {
Tools::generateHtaccess(null, null, null, '', null, array($base_urls['_MEDIA_SERVER_1_'], $base_urls['_MEDIA_SERVER_2_'], $base_urls['_MEDIA_SERVER_3_']));
unset($this->_fieldsGeneral['_MEDIA_SERVER_1_']);
unset($this->_fieldsGeneral['_MEDIA_SERVER_2_']);
unset($this->_fieldsGeneral['_MEDIA_SERVER_3_']);
$redirectAdmin = true;
} else {
$message = $this->l('Before being able to use this tool, you need to:');
示例13: createLabels
public static function createLabels($label_data, $tipo)
{
try {
if (Validate::isFileName($label_data['pedido'])) {
$label_name = $label_data['pedido'];
} else {
$module_instance = Module::getInstanceByName('seur');
return SeurLib::displayErrors($label_data['pedido'] . ' ' . $module_instance->l('could not be used as file name', 'Label'));
}
$sc_options = array('connection_timeout' => 30);
$soap_client = new SoapClient((string) Configuration::get('SEUR_URLWS_ET'), $sc_options);
$merchant_data = SeurLib::getMerchantData();
$notification = SeurLib::getConfigurationField('notification_advice_radio');
$advice_checkbox = SeurLib::getConfigurationField('advice_checkbox');
$distribution_checkbox = SeurLib::getConfigurationField('distribution_checkbox');
$servicio = 31;
$producto = 2;
$mercancia = false;
$claveReembolso = '';
$valorReembolso = '';
if (SeurLib::getConfigurationField('international_orders') == 1 && ($label_data['iso'] != 'ES' && $label_data['iso'] != 'PT' && $label_data['iso'] != 'AD')) {
$servicio = 77;
$producto = 70;
$mercancia = true;
$label_data['total_bultos'] = 1;
}
if (isset($label_data['reembolso']) && ($label_data['iso'] == 'ES' || $label_data['iso'] == 'PT' || $label_data['iso'] == 'AD')) {
$claveReembolso = 'f';
$valorReembolso = (double) $label_data['reembolso'];
}
if (isset($label_data['cod_centro']) && ($label_data['iso'] == 'ES' || $label_data['iso'] == 'PT' || $label_data['iso'] == 'AD')) {
$servicio = 1;
$producto = 48;
}
$total_weight = $label_data['total_kilos'];
$total_packages = $label_data['total_bultos'];
$pesoBulto = $total_weight / $total_packages;
if ($pesoBulto < 1) {
$pesoBulto = 1;
$total_weight = $total_packages;
}
$cont = 0;
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?><root><exp>';
for ($i = 0; $i <= (double) $total_packages - 1; $i++) {
$cont++;
$xml .= '<bulto>
<ci>' . (int) $merchant_data['cit'] . '</ci>
<nif>' . pSQL($merchant_data['nif_dni']) . '</nif>
<ccc>' . (int) $merchant_data['ccc'] . '</ccc>
<servicio>' . pSQL($servicio) . '</servicio>
<producto>' . pSQL($producto) . '</producto>';
if ($mercancia) {
$xml .= '<id_mercancia>382</id_mercancia>';
}
$xml .= '<cod_centro></cod_centro>
<total_bultos>' . pSQL($total_packages) . '</total_bultos>
<total_kilos>' . pSQL($total_weight) . '</total_kilos>
<pesoBulto>' . pSQL($pesoBulto) . '</pesoBulto>
<observaciones>' . pSQL($label_data['info_adicional']) . '</observaciones>
<referencia_expedicion>' . pSQL($label_data['pedido']) . '</referencia_expedicion>
<ref_bulto>' . pSQL($label_data['pedido'] . sprintf('%03d', (int) $i + 1)) . '</ref_bulto>
<clavePortes>F</clavePortes>
<clavePod></clavePod>
<claveReembolso>' . pSQL($claveReembolso) . '</claveReembolso>
<valorReembolso>' . pSQL($valorReembolso) . '</valorReembolso>
<libroControl></libroControl>
<nombre_consignatario>' . pSQL($label_data['name']) . '</nombre_consignatario>
<direccion_consignatario>' . pSQL($label_data['direccion_consignatario']) . '</direccion_consignatario>
<tipoVia_consignatario>CL</tipoVia_consignatario>
<tNumVia_consignatario>N</tNumVia_consignatario>
<numVia_consignatario>.</numVia_consignatario>
<escalera_consignatario>.</escalera_consignatario>
<piso_consignatario>.</piso_consignatario>
<puerta_consignatario>.</puerta_consignatario>
<poblacion_consignatario>' . pSQL($label_data['consignee_town']) . '</poblacion_consignatario>';
if (!empty($label_data['codPostal_consignatario'])) {
$xml .= '<codPostal_consignatario>' . pSQL($label_data['codPostal_consignatario']) . '</codPostal_consignatario>';
}
$xml .= ' <pais_consignatario>' . pSQL($label_data['iso']) . '</pais_consignatario>
<codigo_pais_origen>' . pSQL($label_data['iso_merchant']) . '</codigo_pais_origen>
<email_consignatario>' . pSQL($label_data['email_consignatario']) . '</email_consignatario>
<sms_consignatario>' . ((int) $notification ? pSQL($label_data['movil']) : '') . '</sms_consignatario>
<test_sms>' . ((int) $notification ? 'S' : 'N') . '</test_sms>
<test_preaviso>' . ((int) $advice_checkbox ? 'S' : 'N') . '</test_preaviso>
<test_reparto>' . ((int) $distribution_checkbox ? 'S' : 'N') . '</test_reparto>
<test_email>' . ((int) $notification ? 'N' : 'S') . '</test_email>
<eci>N</eci>
<et>N</et>
<telefono_consignatario>' . pSQL($label_data['telefono_consignatario']) . '</telefono_consignatario>
<atencion_de>' . pSQL($label_data['companyia']) . '</atencion_de>
</bulto>
';
}
$xml .= '</exp></root>';
$xml_name = (int) $merchant_data['franchise'] . '_' . (int) $merchant_data['cit'] . '_' . date('dmYHi') . '.xml';
$make_pickup = false;
$auto = false;
$pickup_data = Pickup::getLastPickup();
if (!empty($pickup_data)) {
$datepickup = explode(' ', $pickup_data['date']);
//.........这里部分代码省略.........
示例14: postProcess
public function postProcess()
{
/* PrestaShop demo mode */
if (_PS_MODE_DEMO_) {
$this->errors[] = Tools::displayError('This functionality has been disabled.');
return;
}
Hook::exec('action' . get_class($this) . ucfirst($this->action) . 'Before', array('controller' => $this));
if (Tools::isSubmit('submitAddServer')) {
if ($this->tabAccess['add'] === '1') {
if (!Tools::getValue('memcachedIp')) {
$this->errors[] = Tools::displayError('The Memcached IP is missing.');
}
if (!Tools::getValue('memcachedPort')) {
$this->errors[] = Tools::displayError('The Memcached port is missing.');
}
if (!Tools::getValue('memcachedWeight')) {
$this->errors[] = Tools::displayError('The Memcached weight is missing.');
}
if (!count($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('The Memcached server cannot be added.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to add this.');
}
}
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('There was an error when attempting to delete the Memcached server.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
}
$redirectAdmin = false;
if ((bool) Tools::getValue('smarty_up')) {
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));
Configuration::updateValue('PS_SMARTY_CONSOLE', Tools::getValue('smarty_console', 0));
Configuration::updateValue('PS_SMARTY_CONSOLE_KEY', Tools::getValue('smarty_console_key', 'SMARTY_DEBUG'));
$redirecAdmin = true;
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
if ((bool) Tools::getValue('features_detachables_up')) {
if ($this->tabAccess['edit'] === '1') {
if (Tools::getValue('combination') || !Combination::isCurrentlyUsed()) {
Configuration::updateValue('PS_COMBINATION_FEATURE_ACTIVE', Tools::getValue('combination'));
}
if (Tools::getValue('customer_group') && !Group::isCurrentlyUsed()) {
Configuration::updateValue('PS_GROUP_FEATURE_ACTIVE', Tools::getValue('customer_group'));
}
Configuration::updateValue('PS_FEATURE_FEATURE_ACTIVE', Tools::getValue('feature'));
$redirectAdmin = true;
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
if ((bool) Tools::getValue('ccc_up')) {
if ($this->tabAccess['edit'] === '1') {
$theme_cache_directory = _PS_ALL_THEMES_DIR_ . $this->context->shop->theme_directory . '/cache/';
if (((bool) Tools::getValue('PS_CSS_THEME_CACHE') || (bool) Tools::getValue('PS_JS_THEME_CACHE')) && !is_writable($theme_cache_directory)) {
$this->errors[] = Tools::displayError(sprintf($this->l('To use Smart Cache directory %s must be writable.'), realpath($theme_cache_directory)));
}
if (!Configuration::updateValue('PS_CSS_THEME_CACHE', (int) Tools::getValue('PS_CSS_THEME_CACHE')) || !Configuration::updateValue('PS_JS_THEME_CACHE', (int) Tools::getValue('PS_JS_THEME_CACHE')) || !Configuration::updateValue('PS_HTML_THEME_COMPRESSION', (int) Tools::getValue('PS_HTML_THEME_COMPRESSION')) || !Configuration::updateValue('PS_JS_HTML_THEME_COMPRESSION', (int) Tools::getValue('PS_JS_HTML_THEME_COMPRESSION')) || !Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int) Tools::getValue('PS_HTACCESS_CACHE_CONTROL'))) {
$this->errors[] = Tools::displayError('Unknown error.');
} else {
$redirectAdmin = true;
if (Configuration::get('PS_HTACCESS_CACHE_CONTROL')) {
Tools::generateHtaccess();
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
if ((bool) Tools::getValue('media_server_up')) {
if ($this->tabAccess['edit'] === '1') {
if (Tools::getValue('_MEDIA_SERVER_1_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_1_'))) {
$this->errors[] = Tools::displayError('Media server #1 is invalid');
}
if (Tools::getValue('_MEDIA_SERVER_2_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_2_'))) {
$this->errors[] = Tools::displayError('Media server #2 is invalid');
}
if (Tools::getValue('_MEDIA_SERVER_3_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_3_'))) {
$this->errors[] = Tools::displayError('Media server #3 is invalid');
}
if (!count($this->errors)) {
$base_urls = array();
$base_urls['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_');
$base_urls['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_');
//.........这里部分代码省略.........
示例15: postProcess
public function postProcess()
{
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 (!count($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.');
}
}
$redirecAdmin = false;
if ((bool) Tools::getValue('smarty_up')) {
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));
Configuration::updateValue('PS_SMARTY_CONSOLE', Tools::getValue('smarty_console', 0));
$redirecAdmin = true;
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
}
if ((bool) Tools::getValue('features_detachables_up')) {
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'));
$redirecAdmin = true;
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
}
if ((bool) Tools::getValue('ccc_up')) {
if ($this->tabAccess['edit'] === '1') {
if (!Configuration::updateValue('PS_CSS_THEME_CACHE', (int) Tools::getValue('PS_CSS_THEME_CACHE')) || !Configuration::updateValue('PS_JS_THEME_CACHE', (int) Tools::getValue('PS_JS_THEME_CACHE')) || !Configuration::updateValue('PS_HTML_THEME_COMPRESSION', (int) Tools::getValue('PS_HTML_THEME_COMPRESSION')) || !Configuration::updateValue('PS_JS_HTML_THEME_COMPRESSION', (int) Tools::getValue('PS_JS_HTML_THEME_COMPRESSION')) || !Configuration::updateValue('PS_HIGH_HTML_THEME_COMPRESSION', (int) Tools::getValue('PS_HIGH_HTML_THEME_COMPRESSION')) || !Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int) Tools::getValue('PS_HTACCESS_CACHE_CONTROL'))) {
$this->errors[] = Tools::displayError('Unknown error.');
} else {
$redirecAdmin = true;
if (Configuration::get('PS_HTACCESS_CACHE_CONTROL')) {
Tools::generateHtaccess();
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
}
if ((bool) Tools::getValue('media_server_up')) {
if ($this->tabAccess['edit'] === '1') {
if (Tools::getValue('_MEDIA_SERVER_1_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_1_'))) {
$this->errors[] = Tools::displayError('Media server #1 is invalid');
}
if (Tools::getValue('_MEDIA_SERVER_2_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_2_'))) {
$this->errors[] = Tools::displayError('Media server #2 is invalid');
}
if (Tools::getValue('_MEDIA_SERVER_3_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_3_'))) {
$this->errors[] = Tools::displayError('Media server #3 is invalid');
}
if (!count($this->errors)) {
$base_urls = array();
$base_urls['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_');
$base_urls['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_');
$base_urls['_MEDIA_SERVER_3_'] = Tools::getValue('_MEDIA_SERVER_3_');
rewriteSettingsFile($base_urls, null, null);
unset($this->_fieldsGeneral['_MEDIA_SERVER_1_']);
unset($this->_fieldsGeneral['_MEDIA_SERVER_2_']);
unset($this->_fieldsGeneral['_MEDIA_SERVER_3_']);
$redirecAdmin = true;
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
}
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');
//.........这里部分代码省略.........