当前位置: 首页>>代码示例>>PHP>>正文


PHP rewriteSettingsFile函数代码示例

本文整理汇总了PHP中rewriteSettingsFile函数的典型用法代码示例。如果您正苦于以下问题:PHP rewriteSettingsFile函数的具体用法?PHP rewriteSettingsFile怎么用?PHP rewriteSettingsFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rewriteSettingsFile函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 public function postProcess()
 {
     global $currentIndex;
     if (isset($_POST['submitDatabase' . $this->table])) {
         if ($this->tabAccess['edit'] === '1') {
             foreach ($this->_fieldsDatabase as $field => $values) {
                 if (isset($values['required']) and $values['required']) {
                     if (($value = Tools::getValue($field)) == false and (string) $value != '0') {
                         $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required');
                     }
                 }
             }
             if (!sizeof($this->_errors)) {
                 /* Datas are not saved in database but in config/settings.inc.php */
                 $settings = array();
                 foreach ($_POST as $k => $value) {
                     if ($value) {
                         $settings['_' . Tools::strtoupper($k) . '_'] = $value;
                     }
                 }
                 rewriteSettingsFile(NULL, NULL, $settings);
                 Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
         }
     }
 }
开发者ID:sealence,项目名称:local,代码行数:28,代码来源:AdminDb.php

示例2: postProcess

 public function postProcess()
 {
     global $currentIndex;
     if (isset($_POST['submitDatabase' . $this->table])) {
         if ($this->tabAccess['edit'] === '1') {
             foreach ($this->_fieldsDatabase as $field => $values) {
                 if (isset($values['required']) and $values['required']) {
                     if (($value = Tools::getValue($field)) == false and (string) $value != '0') {
                         $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required.');
                     }
                 }
             }
             if (!sizeof($this->_errors)) {
                 /* Datas are not saved in database but in config/settings.inc.php */
                 $settings = array();
                 foreach ($_POST as $k => $value) {
                     if ($value) {
                         $settings['_' . Tools::strtoupper($k) . '_'] = $value;
                     }
                 }
                 rewriteSettingsFile(NULL, NULL, $settings);
                 Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     }
     if (Tools::isSubmit('submitEngine')) {
         if (!isset($_POST['tablesBox']) or !sizeof($_POST['tablesBox'])) {
             $this->_errors[] = Tools::displayError('You did not select any tables');
         } else {
             $available_engines = $this->_getEngines();
             $tables_status = $this->_getTablesStatus();
             $tables_engine = array();
             foreach ($tables_status as $table) {
                 $tables_engine[$table['Name']] = $table['Engine'];
             }
             $engineType = pSQL(Tools::getValue('engineType'));
             /* Datas are not saved in database but in config/settings.inc.php */
             $settings = array('_MYSQL_ENGINE_' => $engineType);
             rewriteSettingsFile(NULL, NULL, $settings);
             foreach ($_POST['tablesBox'] as $table) {
                 if ($engineType == $tables_engine[$table]) {
                     $this->_errors[] = $table . ' ' . $this->l('is already in') . ' ' . $engineType;
                 } else {
                     if (!Db::getInstance()->Execute('ALTER TABLE `' . bqSQL($table) . '` ENGINE=`' . bqSQL($engineType) . '`')) {
                         $this->_errors[] = $this->l('Can\'t change engine for') . ' ' . $table;
                     } else {
                         echo '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Confirmation') . '" />' . $this->l('Engine change of') . ' ' . $table . ' ' . $this->l('to') . ' ' . $engineType . '</div>';
                     }
                 }
             }
         }
     }
 }
开发者ID:srikanthash09,项目名称:codetestdatld,代码行数:55,代码来源:AdminDb.php

示例3: postProcess

    public function postProcess()
    {
        global $currentIndex;
        /* PrestaShop demo mode */
        if (_PS_MODE_DEMO_) {
            $this->_errors[] = Tools::displayError('This functionnality has been disabled.');
            return;
        }
        if (Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE') or Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') or Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE')) {
            $uploadMaxSize = (int) str_replace('M', '', ini_get('upload_max_filesize'));
            $postMaxSize = (int) str_replace('M', '', ini_get('post_max_size'));
            $maxSize = $uploadMaxSize < $postMaxSize ? $uploadMaxSize : $postMaxSize;
            $_POST['PS_ATTACHMENT_MAXIMUM_SIZE'] = $maxSize < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE') ? $maxSize : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE');
            if (Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') > $maxSize or Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE') > $maxSize) {
                $this->_errors[] = Tools::displayError($this->l('The chosen limit is superior to the server\'s maximum upload capacity. You need to increase your server limit.'));
                return;
            } else {
                if (!Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE')) {
                    $_POST['PS_LIMIT_UPLOAD_FILE_VALUE'] = 1;
                } else {
                    if (!Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE')) {
                        $_POST['PS_LIMIT_UPLOAD_IMAGE_VALUE'] = 1;
                    } else {
                        $_POST['PS_LIMIT_UPLOAD_FILE_VALUE'] = Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE');
                        $_POST['PS_LIMIT_UPLOAD_IMAGE_VALUE'] = Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE');
                    }
                }
            }
        }
        if (isset($_POST['submitGeneral' . $this->table])) {
            Module::hookExec('categoryUpdate');
            // We call this hook, for regenerate cache of categories
            if (Tools::getValue('PS_CONDITIONS') == true and (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 or !Db::getInstance()->getValue('
			SELECT `id_cms` FROM `' . _DB_PREFIX_ . 'cms`
			WHERE id_cms = ' . (int) Tools::getValue('PS_CONDITIONS_CMS_ID')))) {
                $this->_errors[] = Tools::displayError('Assign a valid CMS page if you want it to be read.');
            }
            if ($this->tabAccess['edit'] === '1') {
                $this->_postConfig($this->_fieldsGeneral);
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
            }
        } elseif (isset($_POST['submitShop' . $this->table])) {
            if ($this->tabAccess['edit'] === '1') {
                $this->_postConfig($this->_fieldsShop);
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
            }
        } elseif (isset($_POST['submitAppearance' . $this->table])) {
            if ($this->tabAccess['edit'] === '1') {
                $this->_postConfig($this->_fieldsAppearance);
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
            }
        } elseif (isset($_POST['submitThemes' . $this->table])) {
            if ($this->tabAccess['edit'] === '1') {
                if ($val = Tools::getValue('PS_THEME')) {
                    if (rewriteSettingsFile(NULL, $val, NULL)) {
                        Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
                    } else {
                        $this->_errors[] = Tools::displayError('Cannot access settings file.');
                    }
                } else {
                    $this->_errors[] = Tools::displayError('You must choose a graphical theme.');
                }
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
            }
        }
        parent::postProcess();
    }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:71,代码来源:AdminPreferences.php

示例4: postProcess


//.........这里部分代码省略.........
                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_');
                    $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);
                    Tools::clearSmartyCache();
                    Media::clearCache();
                    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 {
                $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_ECB);
                            $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_ECB);
                            $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);
                        }
                    }
开发者ID:dev-lav,项目名称:htdocs,代码行数:67,代码来源:AdminPerformanceController.php

示例5: postProcess

 public function postProcess()
 {
     if (Tools::isSubmit('submitAddmeta')) {
         $langs = Language::getLanguages(true);
         $default_language = Configuration::get('PS_LANG_DEFAULT');
         if (Tools::getValue('page') != 'index') {
             $defaultLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         } else {
             // index.php can have empty rewrite rule
             $defaultLangIsValidated = !Tools::getValue('url_rewrite_' . $default_language) or Validate::isLinkRewrite(Tools::getValue('url_rewrite_' . $default_language));
             $englishLangIsValidated = !Tools::getValue('url_rewrite_1') or Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
         }
         if (!$defaultLangIsValidated and !$englishLangIsValidated) {
             $this->_errors[] = Tools::displayError('Url rewrite field must be filled at least in default or english language.');
             return false;
         }
         foreach ($langs as $lang) {
             $current = Tools::getValue('url_rewrite_' . $lang['id_lang']);
             if (strlen($current) == 0) {
                 // Prioritize default language first
                 if ($defaultLangIsValidated) {
                     $_POST['url_rewrite_' . $lang['id_lang']] = Tools::getValue('url_rewrite_' . $default_language);
                 } else {
                     $_POST['url_rewrite_' . $lang['id_lang']] = Tools::getValue('url_rewrite_1');
                 }
             }
         }
     }
     if (Tools::isSubmit('submitOptions' . $this->table)) {
         $baseUrls = array();
         if ($__PS_BASE_URI__ = Tools::getValue('__PS_BASE_URI__')) {
             $baseUrls['__PS_BASE_URI__'] = $__PS_BASE_URI__;
         }
         rewriteSettingsFile($baseUrls, NULL, NULL);
         unset($this->_fieldsGeneral['__PS_BASE_URI__']);
     }
     if (Tools::isSubmit('submitOptions' . $this->table) or Tools::isSubmit('submitAddmeta')) {
         Module::hookExec('afterSaveAdminMeta');
     }
     return parent::postProcess();
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:42,代码来源:AdminMeta.php

示例6: postProcess

    public function postProcess()
    {
        global $currentIndex;
        if (isset($_POST['submitGeneral' . $this->table])) {
            Module::hookExec('categoryUpdate');
            // We call this hook, for regenerate cache of categories
            if (Tools::getValue('PS_CONDITIONS') == true and (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 or !Db::getInstance()->getValue('
			SELECT `id_cms` FROM `' . _DB_PREFIX_ . 'cms`
			WHERE id_cms = ' . (int) Tools::getValue('PS_CONDITIONS_CMS_ID')))) {
                $this->_errors[] = Tools::displayError('Assign a valid CMS page if you want it to be read.');
            }
            if ($this->tabAccess['edit'] === '1') {
                $this->_postConfig($this->_fieldsGeneral);
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
            }
        } elseif (isset($_POST['submitShop' . $this->table])) {
            if ($this->tabAccess['edit'] === '1') {
                $this->_postConfig($this->_fieldsShop);
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
            }
        } elseif (isset($_POST['submitAppearance' . $this->table])) {
            if ($this->tabAccess['edit'] === '1') {
                $this->_postConfig($this->_fieldsAppearance);
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
            }
        } elseif (isset($_POST['submitThemes' . $this->table])) {
            if ($this->tabAccess['edit'] === '1') {
                if ($val = Tools::getValue('PS_THEME')) {
                    if (rewriteSettingsFile(NULL, $val, NULL)) {
                        Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
                    } else {
                        $this->_errors[] = Tools::displayError('Cannot access settings file.');
                    }
                } else {
                    $this->_errors[] = Tools::displayError('You must choose a graphical theme.');
                }
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
            }
        }
        parent::postProcess();
    }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:45,代码来源:AdminPreferences.php

示例7: 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');
//.........这里部分代码省略.........
开发者ID:jicheng17,项目名称:vipinsg,代码行数:101,代码来源:AdminPerformanceController.php

示例8: 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();
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:101,代码来源:AdminPerformance.php

示例9: _postConfig

 /**
  * Update settings in database and configuration files
  *
  * @params array $fields Fields settings
  *
  * @global string $currentIndex Current URL in order to keep current Tab
  */
 protected function _postConfig($fields)
 {
     global $currentIndex;
     $languages = Language::getLanguages();
     /* Check required fields */
     foreach ($fields as $field => $values) {
         if (isset($values['required']) and $values['required']) {
             if ($values['type'] == 'textLang') {
                 foreach ($languages as $language) {
                     if (($value = Tools::getValue($field . '_' . $language['id_lang'])) == false and (string) $value != '0') {
                         $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required');
                     }
                 }
             } elseif (($value = Tools::getValue($field)) == false and (string) $value != '0') {
                 $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required');
             }
         }
     }
     /* Check fields validity */
     foreach ($fields as $field => $values) {
         if ($values['type'] == 'textLang') {
             foreach ($languages as $language) {
                 if (Tools::getValue($field . '_' . $language['id_lang']) and isset($values['validation'])) {
                     if (!Validate::$values['validation'](Tools::getValue($field . '_' . $language['id_lang']))) {
                         $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is invalid');
                     }
                 }
             }
         } elseif (Tools::getValue($field) and isset($values['validation'])) {
             if (!Validate::$values['validation'](Tools::getValue($field))) {
                 $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is invalid');
             }
         }
     }
     /* Default value if null */
     foreach ($fields as $field => $values) {
         if (!Tools::getValue($field) and isset($values['default'])) {
             $_POST[$field] = $values['default'];
         }
     }
     /* Save process */
     if (!sizeof($this->_errors)) {
         if (isset($_POST['submitGeneral' . $this->table])) {
             rewriteSettingsFile(isset($_POST['PS_BASE_URI']) ? $_POST['PS_BASE_URI'] : '', NULL, NULL);
             unset($this->_fieldsGeneral['PS_BASE_URI']);
         } elseif (isset($_POST['submitAppearance' . $this->table])) {
             if (isset($_FILES['PS_LOGO']['tmp_name']) and $_FILES['PS_LOGO']['tmp_name']) {
                 if ($error = checkImage($_FILES['PS_LOGO'], 300000)) {
                     $this->_errors[] = $error;
                 }
                 if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['PS_LOGO']['tmp_name'], $tmpName)) {
                     return false;
                 } elseif (!@imageResize($tmpName, _PS_IMG_DIR_ . 'logo.jpg')) {
                     $this->_errors[] = 'an error occured during logo copy';
                 }
                 unlink($tmpName);
             }
             $this->uploadIco('PS_FAVICON', _PS_IMG_DIR_ . 'favicon.ico');
         }
         /* Update settings in database */
         if (!sizeof($this->_errors)) {
             foreach ($fields as $field => $values) {
                 unset($val);
                 if ($values['type'] == 'textLang') {
                     foreach ($languages as $language) {
                         $val[$language['id_lang']] = isset($values['cast']) ? $values['cast'](Tools::getValue($field . '_' . $language['id_lang'])) : Tools::getValue($field . '_' . $language['id_lang']);
                     }
                 } else {
                     $val = isset($values['cast']) ? $values['cast'](Tools::getValue($field)) : Tools::getValue($field);
                 }
                 Configuration::updateValue($field, $val);
             }
             Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token);
         }
     }
 }
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:83,代码来源:AdminPreferences.php

示例10: postProcess


//.........这里部分代码省略.........
                            $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:');
                        $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('cache_up')) {
            if ($this->access('edit')) {
                $config = Yaml::parse(_PS_ROOT_DIR_ . '/app/config/parameters.yml');
                $cache_active = (bool) Tools::getValue('cache_active');
                if ($caching_system = preg_replace('[^a-zA-Z0-9]', '', Tools::getValue('caching_system'))) {
                    $config['parameters']['ps_caching'] = $caching_system;
                } else {
                    $cache_active = false;
                    $this->errors[] = $this->trans('The caching system is missing.', array(), 'Admin.Parameters.Notification');
开发者ID:M03G,项目名称:PrestaShop,代码行数:67,代码来源:AdminPerformanceController.php


注:本文中的rewriteSettingsFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。