/** * Install Procedure */ public function install() { // Set an url rewriting for prediggo search page $oMeta = new Meta(); $oMeta->page = 'search_prediggo'; $oMeta->title = array(1 => '', 2 => ''); $oMeta->description = array(1 => '', 2 => ''); $oMeta->keywords = array(1 => '', 2 => ''); $oMeta->url_rewrite = array(1 => 'prediggo_search', 2 => 'prediggo_recherche'); // Set the hook registration return $oMeta->save() && Db::getInstance()->autoExecute(_DB_PREFIX_ . 'meta', array('page' => 'modules/prediggo/prediggo_search'), 'UPDATE', '`page` = "search_prediggo"') && Tools::generateHtaccess(dirname(__FILE__) . '/../../.htaccess', Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Configuration::get('PS_HTACCESS_SPECIFIC')) && parent::install() && $this->oPrediggoConfig->install() && $this->oPrediggoExportConfig->install() && $this->oPrediggoRecommendationConfig->install() && $this->oPrediggoSearchConfig->install() && $this->registerHook('header') && $this->registerHook('top') && $this->registerHook('leftColumn') && $this->registerHook('rightColumn') && $this->registerHook('footer') && $this->registerHook('authentication') && $this->registerHook('createAccount') && $this->registerHook('backOfficeHeader') && $this->registerHook('paymentTop'); }
/** * Called when PS_REWRITING_SETTINGS option is saved */ public function updateOptionPsRewritingSettings() { Configuration::updateValue('PS_REWRITING_SETTINGS', (int) Tools::getValue('PS_REWRITING_SETTINGS')); Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')); }
public function processSave() { $object = $this->loadObject(true); if ($object->canAddThisUrl(Tools::getValue('domain'), Tools::getValue('domain_ssl'), Tools::getValue('physical_uri'), Tools::getValue('virtual_uri'))) { $this->errors[] = Tools::displayError('A shop URL that uses this domain already exists.'); } $return = parent::processSave(); if (!$this->errors) { Tools::generateHtaccess(); } return $return; }
public static function create_new_shop($id_seller, $name) { $knpphuwouh = "name"; $ebmaugy = "name"; $awebgo = "name"; ${"GLOBALS"}["avcwqfcrll"] = "name"; ${"GLOBALS"}["ecrzsoxmp"] = "id_show_url"; ${"GLOBALS"}["eoufbdiy"] = "shop"; if (empty(${${"GLOBALS"}["plonjgth"]})) { ${$awebgo} = "shop"; } if (Shop::shop_name_duplicated(${${"GLOBALS"}["avcwqfcrll"]}, 0)) { ${$knpphuwouh} = ${$ebmaugy} . "-" . ${${"GLOBALS"}["blyprwch"]}; } ${${"GLOBALS"}["dcjyfpglzfy"]} = new Shop((int) Configuration::get("PS_SHOP_DEFAULT")); ${${"GLOBALS"}["eoufbdiy"]} = new Shop(); $shop->name = ${${"GLOBALS"}["plonjgth"]}; $shop->id_shop_group = $defshop->id_shop_group; $shop->id_category = $defshop->id_category; ${"GLOBALS"}["lydbmjobdy"] = "id_found"; $shop->active = 1; $shop->deleted = 0; $shop->id_theme = $defshop->id_theme; ${"GLOBALS"}["dbvkuxo"] = "id_show_url"; $shop->add(); ${${"GLOBALS"}["iqatubf"]} = "SELECT id_shop_url \tFROM " . _DB_PREFIX_ . "shop_url WHERE active = 1 AND main=1 AND id_shop = " . (int) Configuration::get("PS_SHOP_DEFAULT"); ${${"GLOBALS"}["dbvkuxo"]} = intval(Db::getInstance()->getValue(${${"GLOBALS"}["iqatubf"]})); ${${"GLOBALS"}["flauwpvwozn"]} = new ShopUrl(${${"GLOBALS"}["ecrzsoxmp"]}); $shopurl->id = 0; $shopurl->id_shop = $shop->id; if ((int) Configuration::get("ASP_SHOP_URL_MODE") == agilemultipleshop::SHOP_URL_MODE_DOMAIN) { $shopurl->domain = Tools::link_rewrite(${${"GLOBALS"}["plonjgth"]}) . "." . str_replace("www.", "", $shopurl->domain); $shopurl->domain_ssl = Tools::link_rewrite(${${"GLOBALS"}["plonjgth"]}) . "." . str_replace("www.", "", $shopurl->domain_ssl); } else { $shopurl->virtual_uri = Tools::link_rewrite(${${"GLOBALS"}["plonjgth"]}); } ${${"GLOBALS"}["lydbmjobdy"]} = $shopurl->canAddThisUrl($shopurl->domain, $shopurl->domain_ssl, $shopurl->physical_uri, $shopurl->virtual_uri); if (intval(${${"GLOBALS"}["ewdnile"]}) > 0) { $shopurl->virtual_uri = $shopurl->virtual_uri . "-" . ${${"GLOBALS"}["blyprwch"]}; } $shopurl->active = 1; $shopurl->add(); Tools::generateHtaccess(); return $shop->id; }
public function update($nullValues = false) { if (!parent::update($nullValues)) { return false; } return Tools::generateHtaccess(dirname(__FILE__) . '/../.htaccess', (int) Configuration::get('PS_REWRITING_SETTINGS'), (int) Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Configuration::get('PS_HTACCESS_SPECIFIC')); }
public function processDelete() { if (!Validate::isLoadedObject($object = $this->loadObject())) { $this->errors[] = Tools::displayError('Unable to load this shop.'); } else { if (!Shop::hasDependency($object->id)) { $result = Category::deleteCategoriesFromShop($object->id) && parent::processDelete(); Tools::generateHtaccess(); return $result; } else { $this->errors[] = Tools::displayError('You can\'t delete this shop (customer and/or order dependency).'); } } return false; }
public function deleteSelection($selection) { if (!is_array($selection)) { die(Tools::displayError()); } $result = true; foreach ($selection as $id) { $this->id = (int) $id; $result = $result && $this->delete(); } return $result && Tools::generateHtaccess(); }
public function processSave() { /** @var ShopUrl $object */ $object = $this->loadObject(true); if ($object->canAddThisUrl(Tools::getValue('domain'), Tools::getValue('domain_ssl'), Tools::getValue('physical_uri'), Tools::getValue('virtual_uri'))) { $this->errors[] = $this->trans('A shop URL that uses this domain already exists.', array(), 'Admin.Notifications.Error'); } $unallowed = str_replace('/', '', Tools::getValue('virtual_uri')); if ($unallowed == 'c' || $unallowed == 'img' || is_numeric($unallowed)) { $this->errors[] = $this->trans('A shop virtual URL cannot be "%URL%"', array('%URL%' => $unallowed), 'Admin.Notifications.Error'); } $return = parent::processSave(); if (!$this->errors) { Tools::generateHtaccess(); Tools::clearSmartyCache(); Media::clearCache(); } return $return; }
/** * Called when PS_REWRITING_SETTINGS option is saved */ public function updateOptionPsRewritingSettings() { Configuration::updateValue('PS_REWRITING_SETTINGS', (int) Tools::getValue('PS_REWRITING_SETTINGS')); Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')); Tools::enableCache(); Tools::clearCache($this->context->smarty); Tools::restoreCacheSettings(); }
protected function processSubmitSellerinfo() { $lang_cookie = self::$cookie->id_lang; if ($lang_cookie != 1) { $_POST['address1_1'] = $_POST['address1_' . $lang_cookie]; $_POST['address2_1'] = $_POST['address1_' . $lang_cookie]; $_POST['address2_1'] = $_POST['address1_' . $lang_cookie]; $_POST['city_1'] = $_POST['city_' . $lang_cookie]; $_POST['description_1'] = $_POST['description_' . $lang_cookie]; } ${"GLOBALS"}["vjnnsubap"] = "list"; $vhheljumal = "selected_country"; $zryhlvp = "list"; $tjuksry = "countries"; ${"GLOBALS"}["vpjnzdqa"] = "countries"; if (Tools::isSubmit("id_country") && !is_null(Tools::getValue("id_country")) && is_numeric(Tools::getValue("id_country"))) { ${$vhheljumal} = (int) Tools::getValue("id_country"); } else { if (isset($this->sellerinfo) && isset($this->sellerinfo->id_country) && !empty($this->sellerinfo->id_country) && is_numeric($this->sellerinfo->id_country)) { ${${"GLOBALS"}["ontiydub"]} = (int) $this->sellerinfo->id_country; } else { if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { $duwbhhjzvvl = "array"; ${$duwbhhjzvvl} = preg_split("/,|-/", $_SERVER["HTTP_ACCEPT_LANGUAGE"]); if (!Validate::isLanguageIsoCode(${${"GLOBALS"}["tjlrhpthnf"]}[0]) || !(${${"GLOBALS"}["ontiydub"]} = Country::getByIso(${${"GLOBALS"}["tjlrhpthnf"]}[0]))) { ${${"GLOBALS"}["ontiydub"]} = (int) Configuration::get("PS_COUNTRY_DEFAULT"); } } else { ${${"GLOBALS"}["ontiydub"]} = (int) Configuration::get("PS_COUNTRY_DEFAULT"); } } } if (Configuration::get("PS_RESTRICT_DELIVERED_COUNTRIES")) { ${${"GLOBALS"}["vpjnzdqa"]} = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { ${${"GLOBALS"}["coohkibbnl"]} = Country::getCountries($this->context->language->id, true); } ${$zryhlvp} = ""; $countries = ${$tjuksry}; /**************** LANGUAGE LEVEL *******************/ $seller_id_lang = $this->sellerinfo->id_seller; $langLevel = Tools::getValue("lang_level"); $dialect = Tools::getValue("lang"); $main_lang = Tools::getValue('main_lang'); /*foreach ($dialect as $key => $value) { $level = $langLevel[$key]; Db::getInstance(_PS_USE_SQL_SLAVE_)->execute(" INSERT INTO " . _DB_PREFIX_ . "sellerinfo_language (seller_id, language, language_level) VALUES ('$seller_id_lang', '$value', '$level') "); }*/ // die('<pre>' . print_r($dialect, true)); $langLevel = implode(',', Tools::getValue("lang_level")); $languages = implode(',', Tools::getValue("lang")); $this->sellerinfo->language = $languages; $this->sellerinfo->language_level = $langLevel; $this->sellerinfo->main_language = $main_lang; $jlbwjt = "shop_name"; ${"GLOBALS"}["oonrqhi"] = "shop_name"; ${"GLOBALS"}["zlobvkbr"] = "virtual_uri"; AgileMultipleSeller::ensure_date_custom_field(); $uskhfeodhv = "zip_code_format"; ${${"GLOBALS"}["oonrqhi"]} = ""; if (isset($_POST["shop_name"])) { ${$jlbwjt} = trim($_POST["shop_name"], " "); } $famsbcd = "country"; if (isset($_POST["virtual_uri"])) { ${${"GLOBALS"}["zlobvkbr"]} = Tools::link_rewrite(trim($_POST["virtual_uri"], " /")) . "/"; } /*if (empty($_POST["postcode"])) $this->errors[] = Tools::displayError("Postcode is required field.");*/ if (empty($_POST["address1_1"])) { $this->errors[] = Tools::displayError("Address is required field."); } if (empty($_POST["city_1"])) { $this->errors[] = Tools::displayError("City is required field."); } if (empty($_POST["phone"])) { $this->errors[] = Tools::displayError("Phone is required field."); } $this->errors = array_merge($this->errors, $this->sellerinfo->validateController()); $this->sellerinfo->id_customer = self::$cookie->id_customer; if (Module::isInstalled("agilemultipleshop")) { $mcovgfrp = "shop_name"; ${"GLOBALS"}["xdpblji"] = "seller_shopurl"; if (empty(${$mcovgfrp})) { $this->errors[] = Tools::displayError("The shop name can not be empty."); } if (empty($_POST["virtual_uri"]) and (int) Configuration::get("ASP_SHOP_URL_MODE") == agilemultipleshop::SHOP_URL_MODE_VIRTUAL) { $this->errors[] = Tools::displayError("The shop Virtual Uri can not be empty."); } ${"GLOBALS"}["edessnqo"] = "id_found"; ${"GLOBALS"}["kkzhciyk"] = "seller_shop"; if ($this->sellerinfo->id_shop <= 1) { $this->sellerinfo->id_shop = 0; } ${${"GLOBALS"}["kkzhciyk"]} = new Shop($this->sellerinfo->id_shop); if (Shop::shop_name_duplicated(${${"GLOBALS"}["oxjolt"]}, $seller_shop->id)) { $this->errors[] = Tools::displayError("The shop name you select has been used by other seller. Please choose a new one."); } ${"GLOBALS"}["asepnxuok"] = "seller_shop"; if ($this->errors) { return; } if (!Validate::isLoadedObject(${${"GLOBALS"}["asepnxuok"]})) { $this->sellerinfo->id_shop = AgileMultipleShop::create_new_shop($this->sellerinfo->id_seller, ${${"GLOBALS"}["oxjolt"]}); $this->sellerinfo->update(); ${${"GLOBALS"}["esrnnrtkg"]} = new Shop($this->sellerinfo->id_shop); } ${${"GLOBALS"}["xdpblji"]} = new ShopUrl(Shop::get_main_url_id($seller_shop->id)); ${${"GLOBALS"}["edessnqo"]} = $seller_shopurl->canAddThisUrl($seller_shopurl->domain, $seller_shopurl->domain_ssl, $seller_shopurl->physical_uri, ${${"GLOBALS"}["uovivsqns"]}); if (intval(${${"GLOBALS"}["vphoqso"]}) > 0) { $this->errors[] = Tools::displayError("The uri you select has been used by other seller. Please choose a new one."); } } ${"GLOBALS"}["uehqptpfhppm"] = "seller_shop"; if (!(${${"GLOBALS"}["flggvi"]} = new Country($this->sellerinfo->id_country)) || !Validate::isLoadedObject(${$famsbcd})) { throw new PrestaShopException("Country cannot be loaded with address->id_country"); } if ((int) $country->contains_states && !(int) $this->sellerinfo->id_state) { $this->errors[] = Tools::displayError("This country requires a state selection."); } ${$uskhfeodhv} = $country->zip_code_format; if ($country->need_zip_code) { $guefxsgyxvp = "zip_code_format"; ${"GLOBALS"}["ayucbbdhdhcq"] = "zip_code_format"; $krvjmkmqh = "postcode"; ${"GLOBALS"}["smbwfoxbj"] = "zip_code_format"; if ((${${"GLOBALS"}["wnwubvg"]} = Tools::getValue("postcode")) && ${${"GLOBALS"}["ayucbbdhdhcq"]}) { ${"GLOBALS"}["gusjike"] = "zip_regexp"; ${"GLOBALS"}["bgahkjn"] = "zip_regexp"; $edhlvb = "zip_regexp"; ${"GLOBALS"}["yvbcolkxptn"] = "zip_regexp"; $pslxhegowq = "zip_regexp"; ${${"GLOBALS"}["ctdciodhb"]} = "/^" . ${${"GLOBALS"}["ebwpvmqblmd"]} . "\$/ui"; ${"GLOBALS"}["mivinoyltqoh"] = "zip_regexp"; ${$pslxhegowq} = str_replace(" ", "( |)", ${${"GLOBALS"}["ctdciodhb"]}); ${${"GLOBALS"}["mivinoyltqoh"]} = str_replace("-", "(-|)", ${${"GLOBALS"}["bgahkjn"]}); ${${"GLOBALS"}["ctdciodhb"]} = str_replace("N", "[0-9]", ${${"GLOBALS"}["gusjike"]}); ${${"GLOBALS"}["ctdciodhb"]} = str_replace("L", "[a-zA-Z]", ${${"GLOBALS"}["ctdciodhb"]}); ${${"GLOBALS"}["ctdciodhb"]} = str_replace("C", $country->iso_code, ${${"GLOBALS"}["yvbcolkxptn"]}); // if (!preg_match(${$edhlvb}, ${${"GLOBALS"}["wnwubvg"]})) // $this->errors[] = "<strong>" . Tools::displayError("Zip / Postal code") . "</strong> " . Tools::displayError("is invalid.") . "<br />" . Tools::displayError("Must be typed as follows:") . " " . str_replace("C", $country->iso_code, str_replace("N", "0", str_replace("L", "A", ${${"GLOBALS"}["ebwpvmqblmd"]}))); } /*else if (${$guefxsgyxvp}) $this->errors[] = "<strong>" . Tools::displayError("Zip / Postal code") . "</strong> " . Tools::displayError("is required."); else if (${${"GLOBALS"}["wnwubvg"]} && !preg_match("/^[0-9a-zA-Z -]{4,9}\$/ui", ${$krvjmkmqh})) $this->errors[] = "<strong>" . Tools::displayError("Zip / Postal code") . "</strong> " . Tools::displayError("is invalid.") . "<br />" . Tools::displayError("Must be typed as follows:") . " " . str_replace("C", $country->iso_code, str_replace("N", "0", str_replace("L", "A", ${${"GLOBALS"}["smbwfoxbj"]}))); */ } if ($country->isNeedDni() && (!Tools::getValue("dni") || !Validate::isDniLite(Tools::getValue("dni")))) { $this->errors[] = Tools::displayError("Identification number is incorrect or has already been used."); } $this->sellerinfo->dni = Tools::getValue("dni"); $this->sellerinfo->latitude = Tools::getValue("latitude"); $this->sellerinfo->longitude = Tools::getValue("longitude"); $this->sellerinfo->id_sellertype1 = Tools::getValue("id_sellertype1"); $this->sellerinfo->id_sellertype2 = Tools::getValue("id_sellertype2"); // echo '<pre>', print_r($_FILES, true) , '</pre>'; SellerInfo::processLogoUpload($this->sellerinfo); SellerInfo::processLicenseUpload($this->sellerinfo); $this->errors = array_merge($this->errors, $this->sellerinfo->validateController()); if (!empty($this->errors)) { return; } $this->sellerinfo->save(); if (Module::isInstalled("agilemultipleshop") and Validate::isLoadedObject(${${"GLOBALS"}["uehqptpfhppm"]})) { $wrheluzg = "shop_name"; $seller_shop->name = ${$wrheluzg}; $seller_shop->save(); ${"GLOBALS"}["sxuwmytjl"] = "virtual_uri"; $seller_shopurl->virtual_uri = ${${"GLOBALS"}["sxuwmytjl"]}; $seller_shopurl->save(); Tools::generateHtaccess(); } if (empty($this->errors)) { self::$smarty->assign("cfmmsg_flag", 1); } }
private static function disable_htaccess_cache() { $successMsg = 'Successfully disabled htaccess cache control'; $errMsg = 'Could not disable htaccess cache control'; $notChanged = 'Htaccess cache control wal already disabled'; if (PS_CLI_TOOLS::update_global_value('PS_HTACCESS_CACHE_CONTROL', false, $successMsg, $errMsg, $notChanged)) { if (Tools::generateHtaccess()) { return true; } else { return false; } } else { return false; } }
function enableURLRewriting() { Configuration::updateValue('PS_REWRITING_SETTINGS', 1); Tools::generateHtaccess(); }
public function postProcess() { /* PrestaShop demo mode */ if (_PS_MODE_DEMO_) { $this->errors[] = $this->trans('This functionality has been disabled.', array(), 'Admin.Notifications.Error'); return; } Hook::exec('action' . get_class($this) . ucfirst($this->action) . 'Before', array('controller' => $this)); if (Tools::isSubmit('submitAddServer')) { if ($this->access('add')) { if (!Tools::getValue('memcachedIp')) { $this->errors[] = $this->trans('The Memcached IP is missing.', array(), 'Admin.Parameters.Notification'); } if (!Tools::getValue('memcachedPort')) { $this->errors[] = $this->trans('The Memcached port is missing.', array(), 'Admin.Parameters.Notification'); } if (!Tools::getValue('memcachedWeight')) { $this->errors[] = $this->trans('The Memcached weight is missing.', array(), 'Admin.Parameters.Notification'); } 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[] = $this->trans('The Memcached server cannot be added.', array(), 'Admin.Parameters.Notification'); } } } else { $this->errors[] = $this->trans('You do not have permission to add this.', array(), 'Admin.Notifications.Error'); } } if (Tools::getValue('deleteMemcachedServer')) { if ($this->access('add')) { if (CacheMemcache::deleteServer((int) Tools::getValue('deleteMemcachedServer'))) { Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getValue('token') . '&conf=4'); } else { $this->errors[] = $this->trans('There was an error when attempting to delete the Memcached server.', array(), 'Admin.Parameters.Notification'); } } else { $this->errors[] = $this->trans('You do not have permission to delete this.', array(), 'Admin.Notifications.Error'); } } $redirectAdmin = false; if ((bool) Tools::getValue('smarty_up')) { if ($this->access('edit')) { Configuration::updateValue('PS_SMARTY_FORCE_COMPILE', Tools::getValue('smarty_force_compile', _PS_SMARTY_NO_COMPILE_)); if (Configuration::get('PS_SMARTY_CACHE') != Tools::getValue('smarty_cache')) { Tools::clearSmartyCache(); } Configuration::updateValue('PS_SMARTY_CACHE', Tools::getValue('smarty_cache', 0)); Configuration::updateValue('PS_SMARTY_CLEAR_CACHE', Tools::getValue('smarty_clear_cache')); Configuration::updateValue('PS_SMARTY_LOCAL', Tools::getValue('smarty_local', 0)); $redirectAdmin = true; } else { $this->errors[] = $this->trans('You do not have permission to edit this.', array(), 'Admin.Notifications.Error'); } } if ((bool) Tools::getValue('features_detachables_up')) { if ($this->access('edit')) { if (Tools::isSubmit('combination')) { if ((!Tools::getValue('combination') && Combination::isCurrentlyUsed()) === false) { Configuration::updateValue('PS_COMBINATION_FEATURE_ACTIVE', (bool) Tools::getValue('combination')); } } if (Tools::isSubmit('customer_group')) { if ((!Tools::getValue('customer_group') && Group::isCurrentlyUsed()) === false) { Configuration::updateValue('PS_GROUP_FEATURE_ACTIVE', (bool) Tools::getValue('customer_group')); } } Configuration::updateValue('PS_FEATURE_FEATURE_ACTIVE', (bool) Tools::getValue('feature')); $redirectAdmin = true; } else { $this->errors[] = $this->trans('You do not have permission to edit this.', array(), 'Admin.Notifications.Error'); } } if ((bool) Tools::getValue('ccc_up')) { if ($this->access('edit')) { $theme_cache_directory = _PS_ALL_THEMES_DIR_ . $this->context->shop->theme_directory . '/cache/'; @mkdir($theme_cache_directory, 0777, true); if (((bool) Tools::getValue('PS_CSS_THEME_CACHE') || (bool) Tools::getValue('PS_JS_THEME_CACHE')) && !is_writable($theme_cache_directory)) { $this->errors[] = $this->trans('To use Smart Cache, the directory %directorypath% must be writable.', array('%directorypath%' => realpath($theme_cache_directory)), 'Admin.Parameters.Notification'); } if ($tmp = (int) Tools::getValue('PS_CSS_THEME_CACHE')) { $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:'); $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'); } if ($cache_active) { if ($caching_system == 'CacheMemcache' && !extension_loaded('memcache')) { $this->errors[] = $this->trans('To use Memcached, you must install the Memcache PECL extension on your server.', array(), 'Admin.Parameters.Notification') . ' <a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>'; } elseif ($caching_system == 'CacheMemcached' && !extension_loaded('memcached')) { $this->errors[] = $this->trans('To use Memcached, you must install the Memcached PECL extension on your server.', array(), 'Admin.Parameters.Notification') . ' <a href="http://www.php.net/manual/en/memcached.installation.php">http://www.php.net/manual/en/memcached.installation.php</a>'; } elseif ($caching_system == 'CacheApc' && !extension_loaded('apc') && !extension_loaded('apcu')) { $this->errors[] = $this->trans('To use APC cache, you must install the APC PECL extension on your server.', array(), 'Admin.Parameters.Notification') . ' <a href="http://fr.php.net/manual/fr/apc.installation.php">http://fr.php.net/manual/fr/apc.installation.php</a>'; } elseif ($caching_system == 'CacheXcache' && !extension_loaded('xcache')) { $this->errors[] = $this->trans('To use Xcache, you must install the Xcache extension on your server.', array(), 'Admin.Parameters.Notification') . ' <a href="http://xcache.lighttpd.net">http://xcache.lighttpd.net</a>'; } elseif ($caching_system == 'CacheXcache' && !ini_get('xcache.var_size')) { $this->errors[] = $this->trans('To use Xcache, you must configure "xcache.var_size" for the Xcache extension (recommended value 16M to 64M).', array(), 'Admin.Parameters.Notification') . ' <a href="http://xcache.lighttpd.net/wiki/XcacheIni">http://xcache.lighttpd.net/wiki/XcacheIni</a>'; } elseif ($caching_system == 'CacheFs') { if (!is_dir(_PS_CACHEFS_DIRECTORY_)) { @mkdir(_PS_CACHEFS_DIRECTORY_, 0777, true); } elseif (!is_writable(_PS_CACHEFS_DIRECTORY_)) { $this->errors[] = $this->trans('To use CacheFS, the directory %directorypath% must be writable.', array('%directorypath%' => realpath(_PS_CACHEFS_DIRECTORY_)), 'Admin.Parameters.Notification'); } } if ($caching_system == 'CacheFs') { if (!($depth = Tools::getValue('ps_cache_fs_directory_depth'))) { $this->errors[] = $this->trans('Please set a directory depth.', array(), 'Admin.Parameters.Notification'); } if (!count($this->errors)) { CacheFs::deleteCacheDirectory(); CacheFs::createCacheDirectories((int) $depth); Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int) $depth); } } elseif ($caching_system == 'CacheMemcache' && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'CacheMemcache') { Cache::getInstance()->flush(); } elseif ($caching_system == 'CacheMemcached' && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'CacheMemcached') { Cache::getInstance()->flush(); } } if (!count($this->errors)) { $config['parameters']['ps_cache_enable'] = $cache_active; // If there is not settings file modification or if the backup and replacement of the settings file worked if (file_put_contents(_PS_ROOT_DIR_ . '/app/config/parameters.yml', Yaml::dump($config))) { if (function_exists('opcache_invalidate')) { opcache_invalidate(_PS_ROOT_DIR_ . '/app/config/parameters.yml'); } $redirectAdmin = true; } else { $this->errors[] = $this->trans('The settings file cannot be overwritten.', array(), 'Admin.Parameters.Notification'); } } } else { $this->errors[] = $this->trans('You do not have permission to edit this.', array(), 'Admin.Notifications.Error'); } } if ((bool) Tools::getValue('empty_smarty_cache')) { $redirectAdmin = true; Tools::clearSmartyCache(); Tools::clearXMLCache(); Media::clearCache(); Tools::generateIndex(); } if ((bool) Tools::getValue('empty_sf2_cache')) { $redirectAdmin = true; $sf2Refresh = new \PrestaShopBundle\Service\Cache\Refresh(); $sf2Refresh->addCacheClear(_PS_MODE_DEV_ ? 'dev' : 'prod'); $sf2Refresh->execute(); } if (Tools::isSubmit('submitAddconfiguration')) { Configuration::updateGlobalValue('PS_DISABLE_NON_NATIVE_MODULE', (int) Tools::getValue('native_module')); Configuration::updateGlobalValue('PS_DISABLE_OVERRIDES', (int) Tools::getValue('overrides')); if (Tools::isSubmit('debug_mode') && (bool) Tools::getValue('debug_mode')) { $debug_mode_status = $this->enableDebugMode(); } else { $debug_mode_status = $this->disableDebugMode(); } if (!empty($debug_mode_status)) { switch ($debug_mode_status) { case self::DEBUG_MODE_ERROR_COULD_NOT_BACKUP: $this->errors[] = Tools::displayError(sprintf($this->l('Error: could not write to file. Make sure that the correct permissions are set on the file %s'), _PS_ROOT_DIR_ . '/config/defines.old.php')); break; case self::DEBUG_MODE_ERROR_NO_DEFINITION_FOUND: $this->errors[] = Tools::displayError(sprintf($this->l('Error: could not find whether debug mode is enabled. Make sure that the correct permissions are set on the file %s'), _PS_ROOT_DIR_ . '/config/defines.inc.php')); break; case self::DEBUG_MODE_ERROR_NO_WRITE_ACCESS: $this->errors[] = Tools::displayError(sprintf($this->l('Error: could not write to file. Make sure that the correct permissions are set on the file %s'), _PS_ROOT_DIR_ . '/config/defines.inc.php')); break; case self::DEBUG_MODE_ERROR_NO_WRITE_ACCESS_CUSTOM: $this->errors[] = Tools::displayError(sprintf($this->l('Error: could not write to file. Make sure that the correct permissions are set on the file %s'), _PS_ROOT_DIR_ . '/config/defines_custom.inc.php')); break; case self::DEBUG_MODE_ERROR_NO_READ_ACCESS: $this->errors[] = Tools::displayError(sprintf($this->l('Error: could not read file. Make sure that the correct permissions are set on the file %s'), _PS_ROOT_DIR_ . '/config/defines.inc.php')); break; default: break; } } Tools::generateIndex(); } if ($redirectAdmin && (!isset($this->errors) || !count($this->errors))) { Hook::exec('action' . get_class($this) . ucfirst($this->action) . 'After', array('controller' => $this, 'return' => '')); Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getValue('token') . '&conf=4'); } }
private function _writeRewriteRule() { if ($this->checkRewriteRule()) { return true; } if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $htaccess_source = file_get_contents($this->_htFile); $dest_rule = 'index.php?fc=module&module=pm_advancedsearch4&controller=advancedsearch4&isolang=$1&id_seo=$2&seo_url=$3'; } else { $htaccess_source = Configuration::get('PS_HTACCESS_SPECIFIC'); $dest_rule = __PS_BASE_URI__ . 'modules/pm_advancedsearch4/advancedsearch4.php?isolang=$1&id_seo=$2&seo_url=$3'; $dest_rule_2 = __PS_BASE_URI__ . 'modules/pm_advancedsearch4/advancedsearch4.php?'; } if (preg_match('#\\^\\(\\[a-z\\]\\{2\\}\\)\\/s/#', $htaccess_source)) { $PS_HTACCESS_SPECIFIC = preg_replace('#\\^\\(\\[a-z\\]\\{2\\}\\)\\/s/#', '^([a-z]{2})?/?s/', $htaccess_source); } else { if (preg_match('#\\#START AS4 RULES#', $htaccess_source)) { $htaccess_source = preg_replace('#\\#START AS4 RULES(.*)\\#END AS4 RULES\\n?#s', '', $htaccess_source); } $PS_HTACCESS_SPECIFIC = '#START AS4 RULES (Do not remove)' . "\n"; if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $PS_HTACCESS_SPECIFIC .= '<IfModule mod_rewrite.c>' . "\n" . 'RewriteEngine on' . "\n"; } $PS_HTACCESS_SPECIFIC .= 'RewriteRule ^as4_seositemap.xml$ modules/pm_advancedsearch4/sitemap/seositemap.xml [L]' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteRule ^as4_seositemap-([0-9]+).xml$ modules/pm_advancedsearch4/sitemap/seositemap-$1.xml [L]' . "\n"; if (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && Shop::isFeatureActive()) { foreach (array_values(Shop::getCompleteListOfShopsID()) as $id_shop) { $shopUrl = new Shop($id_shop); $base_uri = $shopUrl->virtual_uri; $PS_HTACCESS_SPECIFIC .= 'RewriteCond %{QUERY_STRING} !^controller=products-comparison [NC]' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteRule ^' . str_replace('\\-', '-', preg_quote($base_uri)) . '([a-z]{2})?/?s/([0-9]+)/([a-zA-Z0-9/_-]*) ' . $dest_rule . ' [QSA,L]' . "\n"; } } else { if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $PS_HTACCESS_SPECIFIC .= 'RewriteCond %{QUERY_STRING} !^controller=products-comparison [NC]' . "\n"; } $PS_HTACCESS_SPECIFIC .= 'RewriteRule ^([a-z]{2})?/?s/([0-9]+)/([a-zA-Z0-9/_-]*) ' . $dest_rule . ' [QSA,L]' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteCond %{QUERY_STRING} ^isolang=([a-z]{2})&id_seo=([0-9]+)&seo_url=([a-zA-Z0-9/_-]*).*p=([0-9]+)$' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteRule ^advancedsearch4.php ' . __PS_BASE_URI__ . '%1/s/%2/%3?p=%4 [R=301,L]' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteCond %{QUERY_STRING} ^isolang=([a-z]{2})&id_seo=([0-9]+)&seo_url=([a-zA-Z0-9/_-]*)' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteRule ^advancedsearch4.php ' . __PS_BASE_URI__ . '%1/s/%2/%3? [R=301,L]' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteCond %{QUERY_STRING} ^id_seo=([0-9]+)&seo_url=([a-zA-Z0-9/_-]*).*p=([0-9]+)$' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteRule ^advancedsearch4.php ' . __PS_BASE_URI__ . 's/%1/%2?p=%3 [R=301,L]' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteCond %{QUERY_STRING} ^id_seo=([0-9]+)&seo_url=([a-zA-Z0-9/_-]*)' . "\n"; $PS_HTACCESS_SPECIFIC .= 'RewriteRule ^advancedsearch4.php ' . __PS_BASE_URI__ . 's/%1/%2? [R=301,L]' . "\n"; } if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $PS_HTACCESS_SPECIFIC .= '</IfModule>' . "\n"; } $PS_HTACCESS_SPECIFIC .= '#END AS4 RULES' . "\n"; $PS_HTACCESS_SPECIFIC .= $htaccess_source; } if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { return file_put_contents($this->_htFile, $PS_HTACCESS_SPECIFIC); } else { Configuration::updateValue('PS_HTACCESS_SPECIFIC', $PS_HTACCESS_SPECIFIC, true); if (Tools::generateHtaccess($this->_htFile, Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), $PS_HTACCESS_SPECIFIC, Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS'))) { return true; } } return false; }
public function update($nullValues = false) { if (!parent::update($nullValues)) { return false; } // If url_rewrite is not enabled, we don't need to regenerate .htaccess if (!Configuration::get('PS_REWRITING_SETTINGS')) { return true; } return Tools::generateHtaccess(dirname(__FILE__) . '/../.htaccess', (int) Configuration::get('PS_REWRITING_SETTINGS'), (int) Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Configuration::get('PS_HTACCESS_SPECIFIC'), (int) Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')); }
public function processSave() { $object = $this->loadObject(true); if ($object->canAddThisUrl(Tools::getValue('domain'), Tools::getValue('domain_ssl'), Tools::getValue('physical_uri'), Tools::getValue('virtual_uri'))) { $this->errors[] = Tools::displayError('A shop URL that uses this domain already exists.'); } if (str_replace('/', '', Tools::getValue('virtual_uri')) == 'c') { $this->errors[] = Tools::displayError('A shop virtual URL can not be "/c/", because "/c/" is the virtual url prefix for category images.'); } $return = parent::processSave(); if (!$this->errors) { Tools::generateHtaccess(); Tools::clearSmartyCache(); Media::clearCache(); } return $return; }
public function deleteSelection($selection) { if (!is_array($selection) or !Validate::isTableOrIdentifier($this->identifier) or !Validate::isTableOrIdentifier($this->table)) { die(Tools::displayError()); } $result = true; foreach ($selection as $id) { $this->id = (int) $id; $result = $result and $this->delete(); } return Tools::generateHtaccess(dirname(__FILE__) . '/../.htaccess', (int) Configuration::get('PS_REWRITING_SETTINGS'), (int) Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Configuration::get('PS_HTACCESS_SPECIFIC'), (int) Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')); }
$sql = 'SELECT distinct LOWER(TRIM(sil.' . AgileMultipleShop::SHOP_BY_CUSTOM_FIELD . ')) AS id, TRIM(sil.' . AgileMultipleShop::SHOP_BY_CUSTOM_FIELD . ') AS name FROM `' . _DB_PREFIX_ . 'sellerinfo_lang` sil WHERE sil.id_lang = ' . $context->cookie->id_lang . ' AND LENGTH(TRIM(sil.' . AgileMultipleShop::SHOP_BY_CUSTOM_FIELD . ')) > 0 ORDER BY sil.' . AgileMultipleShop::SHOP_BY_CUSTOM_FIELD . ' ASC '; } else { $sql = 'SELECT distinct LOWER(TRIM(si.' . AgileMultipleShop::SHOP_BY_CUSTOM_FIELD . ')) AS id, TRIM(si.' . AgileMultipleShop::SHOP_BY_CUSTOM_FIELD . ') AS name FROM `' . _DB_PREFIX_ . 'sellerinfo` si ORDER BY si.' . AgileMultipleShop::SHOP_BY_CUSTOM_FIELD . ' ASC '; } break; } if (empty($sql)) { return array(); } return Db::getInstance()->ExecuteS($sql); } public static function init_shop_header() { $main_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); include_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/SellerInfo.php"; Context::getContext()->smarty->assign(array('is_agilemultipleshop_installed' => 1, 'header_logo_mode' => intval(Configuration::get('ASP_HEADER_LOGO_MODE')), 'base_dir_default' => $main_shop->getBaseURL(), 'seller_shop_name' => Context::getContext()->shop->name, 'id_shop_owner' => Shop::$id_shop_owner, 'seller_logo_url' => isset(Shop::$sellerinfo) ? SellerInfo::get_seller_logo_url_static(Shop::$sellerinfo->id) : '')); } public static function clear_blockcategory_cache() { @session_start(); if (!isset($_SESSION['id_shop_owner'])) { $_SESSION['id_shop_owner'] = 0; } if ($_SESSION['id_shop_owner'] != Shop::$id_shop_owner) { $_SESSION['id_shop_owner'] = Shop::$id_shop_owner; Context::getContext()->smarty->clearAllCache(); } } public static function get_rewrite_rules() {
public function update($nullValues = false) { if (!parent::update($nullValues)) { return false; } return Tools::generateHtaccess(); }
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'); $settings = file_get_contents(dirname(__FILE__) . '/../../config/settings.inc.php'); if ($algo) { if (!function_exists('mcrypt_encrypt')) { $this->errors[] = Tools::displayError('PHP "Mcrypt" extension 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); $redirecAdmin = true; } else { $this->errors[] = Tools::displayError('Cannot overwrite settings file.'); } } } else { $this->errors[] = Tools::displayError('You do not have permission to edit here.'); } } if ((bool) Tools::getValue('cache_up')) { 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.') . ' <a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>'; } 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.') . ' <a href="http://fr.php.net/manual/fr/apc.installation.php">http://fr.php.net/manual/fr/apc.installation.php</a>'; } 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.') . ' <a href="http://xcache.lighttpd.net">http://xcache.lighttpd.net</a>'; } else { if ($cache_active && $caching_system == 'CacheFs' && !is_writable(_PS_CACHEFS_DIRECTORY_)) { $this->errors[] = sprintf(Tools::displayError('To use CacheFS the directory %s must be writable.'), realpath(_PS_CACHEFS_DIRECTORY_)); } } } } if ($caching_system == 'CacheFs' && $cache_active) { if (!($depth = Tools::getValue('ps_cache_fs_directory_depth'))) { $this->errors[] = Tools::displayError('Please set a directory depth'); } if (!count($this->errors)) { CacheFs::deleteCacheDirectory(); CacheFs::createCacheDirectories((int) $depth); Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int) $depth); } } else { if ($caching_system == 'MCached' && $cache_active && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'MCached') { Cache::getInstance()->flush(); } } if (!count($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)) { $redirecAdmin = true; } else { $this->errors[] = Tools::displayError('Cannot overwrite settings file.'); } } } else { $this->errors[] = Tools::displayError('You do not have permission to edit here.'); } } if ($redirecAdmin) { Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getValue('token') . '&conf=4'); } else { return parent::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_'); $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); } } } if (!count($this->errors)) { // If there is not settings file modification or if the backup and replacement of the settings file worked if ($new_settings == $prev_settings || copy(_PS_ROOT_DIR_ . '/config/settings.inc.php', _PS_ROOT_DIR_ . '/config/settings.old.php') && (bool) file_put_contents(_PS_ROOT_DIR_ . '/config/settings.inc.php', $new_settings)) { Configuration::updateValue('PS_CIPHER_ALGORITHM', $algo); $redirectAdmin = true; } else { $this->errors[] = Tools::displayError('The settings file cannot be overwritten.'); } } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } if ((bool) Tools::getValue('cache_up')) { if ($this->tabAccess['edit'] === '1') { $new_settings = $prev_settings = file_get_contents(_PS_ROOT_DIR_ . '/config/settings.inc.php'); $cache_active = (bool) Tools::getValue('cache_active'); if ($caching_system = Tools::getValue('caching_system')) { $new_settings = preg_replace('/define\\(\'_PS_CACHING_SYSTEM_\', \'([a-z0-9=\\/+-_]*)\'\\);/Ui', 'define(\'_PS_CACHING_SYSTEM_\', \'' . $caching_system . '\');', $new_settings); } else { $cache_active = false; $this->errors[] = Tools::displayError('The caching system is missing.'); } if ($cache_active) { if ($caching_system == 'CacheMemcache' && !extension_loaded('memcache')) { $this->errors[] = Tools::displayError('To use Memcached, you must install the Memcache PECL extension on your server.') . ' <a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>'; } elseif ($caching_system == 'CacheApc' && !extension_loaded('apc')) { $this->errors[] = Tools::displayError('To use APC cache, you must install the APC PECL extension on your server.') . ' <a href="http://fr.php.net/manual/fr/apc.installation.php">http://fr.php.net/manual/fr/apc.installation.php</a>'; } elseif ($caching_system == 'CacheXcache' && !extension_loaded('xcache')) { $this->errors[] = Tools::displayError('To use Xcache, you must install the Xcache extension on your server.') . ' <a href="http://xcache.lighttpd.net">http://xcache.lighttpd.net</a>'; } elseif ($caching_system == 'CacheXcache' && !ini_get('xcache.var_size')) { $this->errors[] = Tools::displayError('To use Xcache, you must configure "xcache.var_size" for the Xcache extension (recommended value 16M to 64M).') . ' <a href="http://xcache.lighttpd.net/wiki/XcacheIni">http://xcache.lighttpd.net/wiki/XcacheIni</a>'; } elseif ($caching_system == 'CacheFs') { if (!is_dir(_PS_CACHEFS_DIRECTORY_)) { @mkdir(_PS_CACHEFS_DIRECTORY_, 0777, true); } elseif (!is_writable(_PS_CACHEFS_DIRECTORY_)) { $this->errors[] = sprintf(Tools::displayError('To use CacheFS, the directory %s must be writable.'), realpath(_PS_CACHEFS_DIRECTORY_)); } } if ($caching_system == 'CacheFs') { if (!($depth = Tools::getValue('ps_cache_fs_directory_depth'))) { $this->errors[] = Tools::displayError('Please set a directory depth.'); } if (!count($this->errors)) { CacheFs::deleteCacheDirectory(); CacheFs::createCacheDirectories((int) $depth); Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int) $depth); } } elseif ($caching_system == 'CacheMemcache' && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'CacheMemcache') { Cache::getInstance()->flush(); } } if (!count($this->errors)) { $new_settings = preg_replace('/define\\(\'_PS_CACHE_ENABLED_\', \'([01]?)\'\\);/Ui', 'define(\'_PS_CACHE_ENABLED_\', \'' . (int) $cache_active . '\');', $new_settings); // If there is not settings file modification or if the backup and replacement of the settings file worked if ($new_settings == $prev_settings || copy(_PS_ROOT_DIR_ . '/config/settings.inc.php', _PS_ROOT_DIR_ . '/config/settings.old.php') && (bool) file_put_contents(_PS_ROOT_DIR_ . '/config/settings.inc.php', $new_settings)) { $redirectAdmin = true; } else { $this->errors[] = Tools::displayError('The settings file cannot be overwritten.'); } } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } if ((bool) Tools::getValue('empty_smarty_cache')) { $redirectAdmin = true; Tools::clearSmartyCache(); Tools::clearXMLCache(); Media::clearCache(); PrestaShopAutoload::getInstance()->generateIndex(); } if (Tools::isSubmit('submitAddconfiguration') && _PS_MODE_DEV_) { Configuration::updateGlobalValue('PS_DISABLE_NON_NATIVE_MODULE', (int) Tools::getValue('native_module')); Configuration::updateGlobalValue('PS_DISABLE_OVERRIDES', (int) Tools::getValue('overrides')); if (Tools::getValue('overrides')) { PrestaShopAutoload::getInstance()->_include_override_path = false; } PrestaShopAutoload::getInstance()->generateIndex(); } if ($redirectAdmin && (!isset($this->errors) || !count($this->errors))) { Hook::exec('action' . get_class($this) . ucfirst($this->action) . 'After', array('controller' => $this, 'return' => '')); Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getValue('token') . '&conf=4'); } }
public function postProcess() { global $currentIndex; /* PrestaShop demo mode */ if (_PS_MODE_DEMO_) { $this->_errors[] = Tools::displayError('This functionnality has been disabled.'); return; } /* PrestaShop demo mode*/ if (Tools::isSubmit('submitHtaccess')) { if ($this->tabAccess['edit'] === '1') { Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int) Tools::getValue('PS_HTACCESS_CACHE_CONTROL')); Configuration::updateValue('PS_REWRITING_SETTINGS', (int) Tools::getValue('PS_REWRITING_SETTINGS')); Configuration::updateValue('PS_HTACCESS_DISABLE_MULTIVIEWS', (int) Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')); Configuration::updateValue('PS_HTACCESS_SPECIFIC', pSQL(Tools::getValue('PS_HTACCESS_SPECIFIC')), true); if (Tools::generateHtaccess($this->_htFile, Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Tools::getValue('PS_HTACCESS_SPECIFIC'), Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'))) { Tools::redirectAdmin($currentIndex . '&conf=4&token=' . $this->token); } $this->_errors[] = $this->l('Cannot write to file:') . ' <b>' . $this->_htFile . '</b><br />' . $this->l('Please check write permissions.'); } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } if (Tools::isSubmit('submitRobots')) { if ($this->tabAccess['edit'] === '1') { if (!($writeFd = @fopen($this->_rbFile, 'w'))) { die($this->l('Cannot write to file:') . ' <b>' . $this->_rbFile . '</b><br />' . $this->l('Please check write permissions.')); } else { // PS Comments fwrite($writeFd, "# robots.txt automaticaly generated by PrestaShop e-commerce open-source solution\n"); fwrite($writeFd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n"); fwrite($writeFd, "# This file is to prevent the crawling and indexing of certain parts\n"); fwrite($writeFd, "# of your site by web crawlers and spiders run by sites like Yahoo!\n"); fwrite($writeFd, "# and Google. By telling these \"robots\" where not to go on your site,\n"); fwrite($writeFd, "# you save bandwidth and server resources.\n"); fwrite($writeFd, "# For more information about the robots.txt standard, see:\n"); fwrite($writeFd, "# http://www.robotstxt.org/wc/robots.html\n"); //GoogleBot specific fwrite($writeFd, "# GoogleBot specific\n"); fwrite($writeFd, "User-agent: Googlebot\n"); foreach ($this->_rbData['GB'] as $GB) { fwrite($writeFd, 'Disallow: /*' . $GB . "\n"); } // User-Agent fwrite($writeFd, "# All bots\n"); fwrite($writeFd, "User-agent: *\n"); // Directories fwrite($writeFd, "# Directories\n"); foreach ($this->_rbData['Directories'] as $dir) { fwrite($writeFd, 'Disallow: /*' . $dir . "\n"); } // Files fwrite($writeFd, "# Files\n"); foreach ($this->_rbData['Files'] as $iso_code => $files) { if (!is_numeric($iso_code) && is_array($files)) { foreach ($files as $file) { fwrite($writeFd, 'Disallow: /*' . $iso_code . '/' . $file . "\n"); } } elseif (is_numeric($iso_code) && !is_array($files)) { fwrite($writeFd, 'Disallow: /*' . $files . "\n"); } } // Sitemap fwrite($writeFd, "# Sitemap\n"); if (file_exists($this->_smFile)) { if (filesize($this->_smFile)) { fwrite($writeFd, 'Sitemap: ' . (_PS_SSL_ENABLED_ ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . __PS_BASE_URI__ . 'sitemap.xml' . "\n"); } } fwrite($writeFd, "\n"); fclose($writeFd); @chmod($this->_rbFile, 0775); Tools::redirectAdmin($currentIndex . '&conf=4&token=' . $this->token); } } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } }
/** * Called when PS_REWRITING_SETTINGS option is saved */ public function updateOptionPsRewritingSettings() { Configuration::updateValue('PS_REWRITING_SETTINGS', (int) Tools::getValue('PS_REWRITING_SETTINGS')); if (Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'), false, Tools::getValue('PS_HTACCESS_DISABLE_MODSEC'))) { Tools::enableCache(); Tools::clearCache($this->context->smarty); Tools::restoreCacheSettings(); } else { Configuration::updateValue('PS_REWRITING_SETTINGS', 0); // Message copied/pasted from the information tip $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[] = $message; } }
/** * PROCESS : configureShop * Set default shop configuration */ public function configureShop(array $data = array()) { //clear image cache in tmp folder if (file_exists(_PS_TMP_IMG_DIR_)) { foreach (scandir(_PS_TMP_IMG_DIR_) as $file) { if ($file[0] != '.' && $file != 'index.php') { Tools::deleteFile(_PS_TMP_IMG_DIR_ . $file); } } } $default_data = array('shop_name' => 'My Shop', 'shop_activity' => '', 'shop_country' => 'us', 'shop_timezone' => 'US/Eastern', 'use_smtp' => false, 'smtp_encryption' => 'off', 'smtp_port' => 25, 'rewrite_engine' => false); foreach ($default_data as $k => $v) { if (!isset($data[$k])) { $data[$k] = $v; } } Context::getContext()->shop = new Shop(1); Configuration::loadConfiguration(); // use the old image system if the safe_mod is enabled otherwise the installer will fail with the fixtures installation if (InstallSession::getInstance()->safe_mode) { Configuration::updateGlobalValue('PS_LEGACY_IMAGES', 1); } $id_country = Country::getByIso($data['shop_country']); // Set default configuration Configuration::updateGlobalValue('PS_SHOP_DOMAIN', Tools::getHttpHost()); Configuration::updateGlobalValue('PS_SHOP_DOMAIN_SSL', Tools::getHttpHost()); Configuration::updateGlobalValue('PS_INSTALL_VERSION', _PS_INSTALL_VERSION_); Configuration::updateGlobalValue('PS_LOCALE_LANGUAGE', $this->language->getLanguageIso()); Configuration::updateGlobalValue('PS_SHOP_NAME', $data['shop_name']); Configuration::updateGlobalValue('PS_SHOP_ACTIVITY', $data['shop_activity']); Configuration::updateGlobalValue('PS_COUNTRY_DEFAULT', $id_country); Configuration::updateGlobalValue('PS_LOCALE_COUNTRY', $data['shop_country']); Configuration::updateGlobalValue('PS_TIMEZONE', $data['shop_timezone']); Configuration::updateGlobalValue('PS_CONFIGURATION_AGREMENT', (int) $data['configuration_agrement']); // Set mails configuration Configuration::updateGlobalValue('PS_MAIL_METHOD', $data['use_smtp'] ? 2 : 1); Configuration::updateGlobalValue('PS_MAIL_SMTP_ENCRYPTION', $data['smtp_encryption']); Configuration::updateGlobalValue('PS_MAIL_SMTP_PORT', $data['smtp_port']); // Set default rewriting settings Configuration::updateGlobalValue('PS_REWRITING_SETTINGS', $data['rewrite_engine']); // Activate rijndael 128 encrypt algorihtm if mcrypt is activated Configuration::updateGlobalValue('PS_CIPHER_ALGORITHM', function_exists('mcrypt_encrypt') ? 1 : 0); $groups = Group::getGroups((int) Configuration::get('PS_LANG_DEFAULT')); $groups_default = Db::getInstance()->executeS('SELECT `name` FROM ' . _DB_PREFIX_ . 'configuration WHERE `name` LIKE "PS_%_GROUP" ORDER BY `id_configuration`'); foreach ($groups_default as &$group_default) { if (is_array($group_default) && isset($group_default['name'])) { $group_default = $group_default['name']; } } if (is_array($groups) && count($groups)) { foreach ($groups as $key => $group) { if (Configuration::get($groups_default[$key]) != $groups[$key]['id_group']) { Configuration::updateGlobalValue($groups_default[$key], (int) $groups[$key]['id_group']); } } } $states = Db::getInstance()->executeS('SELECT `id_order_state` FROM ' . _DB_PREFIX_ . 'order_state ORDER by `id_order_state`'); $states_default = Db::getInstance()->executeS('SELECT MIN(`id_configuration`), `name` FROM ' . _DB_PREFIX_ . 'configuration WHERE `name` LIKE "PS_OS_%" GROUP BY `value` ORDER BY`id_configuration`'); foreach ($states_default as &$state_default) { if (is_array($state_default) && isset($state_default['name'])) { $state_default = $state_default['name']; } } if (is_array($states) && count($states)) { foreach ($states as $key => $state) { if (Configuration::get($states_default[$key]) != $states[$key]['id_order_state']) { Configuration::updateGlobalValue($states_default[$key], (int) $states[$key]['id_order_state']); } } /* deprecated order state */ Configuration::updateGlobalValue('PS_OS_OUTOFSTOCK_PAID', (int) Configuration::get('PS_OS_OUTOFSTOCK')); } // Set logo configuration if (file_exists(_PS_IMG_DIR_ . 'logo.jpg')) { list($width, $height) = getimagesize(_PS_IMG_DIR_ . 'logo.jpg'); Configuration::updateGlobalValue('SHOP_LOGO_WIDTH', round($width)); Configuration::updateGlobalValue('SHOP_LOGO_HEIGHT', round($height)); } // Disable cache for debug mode if (_PS_MODE_DEV_) { Configuration::updateGlobalValue('PS_SMARTY_CACHE', 1); } // Active only the country selected by the merchant Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'country SET active = 0 WHERE id_country != ' . (int) $id_country); // Set localization configuration $version = str_replace('.', '', _PS_VERSION_); $version = substr($version, 0, 2); $localization_file_content = $this->getLocalizationPackContent($version, $data['shop_country']); $locale = new LocalizationPackCore(); $locale->loadLocalisationPack($localization_file_content, '', true); // Create default employee if (isset($data['admin_firstname']) && isset($data['admin_lastname']) && isset($data['admin_password']) && isset($data['admin_email'])) { $employee = new Employee(); $employee->firstname = Tools::ucfirst($data['admin_firstname']); $employee->lastname = Tools::ucfirst($data['admin_lastname']); $employee->email = $data['admin_email']; $employee->passwd = md5(_COOKIE_KEY_ . $data['admin_password']); $employee->last_passwd_gen = date('Y-m-d h:i:s', strtotime('-360 minutes')); $employee->bo_theme = 'default'; $employee->default_tab = 1; $employee->active = true; $employee->optin = (bool) $data['send_informations']; $employee->id_profile = 1; $employee->id_lang = Configuration::get('PS_LANG_DEFAULT'); $employee->bo_menu = 1; if (!$employee->add()) { $this->setError($this->language->l('Cannot create admin account')); return false; } } else { $this->setError($this->language->l('Cannot create admin account')); return false; } // Update default contact if (isset($data['admin_email'])) { Configuration::updateGlobalValue('PS_SHOP_EMAIL', $data['admin_email']); $contacts = new PrestaShopCollection('Contact'); foreach ($contacts as $contact) { $contact->email = $data['admin_email']; $contact->update(); } } if (!@Tools::generateHtaccess(null, $data['rewrite_engine'])) { Configuration::updateGlobalValue('PS_REWRITING_SETTINGS', 0); } return true; }
protected function afterUpdate($object) { Tools::generateHtaccess(); WebserviceKey::setPermissionForAccount($object->id, Tools::getValue('resources', array())); }
public static function post_update_uri() { $context = Context::getContext(); $htaccess = _PS_ROOT_DIR_ . '/.htaccess'; if (!is_writable($htaccess)) { echo "Error, htaccess file not writable\n"; return false; } $disableMultiviews = Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS'); $htaccessModSec = Configuration::get('PS_HTACCESS_MODSEC'); if (Tools::generateHtaccess($htaccess, null, null, '', $disableMultiviews, false, $htaccessModSec)) { Tools::enableCache(); Tools::clearCache($context->smarty); Tools::restoreCacheSettings(); echo "Htaccess file regenerated\n"; return true; } else { echo "Error, could not update htaccess file\n"; return false; } }