Esempio n. 1
0
 public function renderForm()
 {
     $update_htaccess = Tools::modRewriteActive() && (file_exists('.htaccess') && is_writable('.htaccess') || is_writable(dirname('.htaccess')));
     $this->multiple_fieldsets = true;
     if (!$update_htaccess) {
         $desc_virtual_uri = array('<span class="warning_mod_rewrite">' . $this->l('You need to activate URL Rewriting if you want to add a virtual URL.') . '</span>');
     } else {
         $desc_virtual_uri = array($this->l('You can use this option if you want to create a store with a URL that doesn\'t exist on your server (e.g. if you want your store to be available with the URL www.my-prestashop.com/my-store/shoes/, you have to set shoes/ in this field, assuming that my-store/ is your Physical URL).'), '<strong>' . $this->l('URL rewriting must be activated on your server to use this feature.') . '</strong>');
     }
     $this->fields_form = array(array('form' => array('legend' => array('title' => $this->l('URL options'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'id_shop', 'onchange' => 'checkMainUrlInfo(this.value);', 'options' => array('optiongroup' => array('query' => Shop::getTree(), 'label' => 'name'), 'options' => array('query' => 'shops', 'id' => 'id_shop', 'name' => 'name'))), array('type' => 'switch', 'label' => $this->l('Main URL'), 'name' => 'main', 'class' => 't', 'values' => array(array('id' => 'main_on', 'value' => 1), array('id' => 'main_off', 'value' => 0)), 'desc' => array($this->l('If you set this URL as the Main URL for the selected shop, all URLs set to this shop will be redirected to this URL (you can only have one Main URL per shop).'), array('text' => $this->l('Since the selected shop has no main URL, you have to set this URL as the Main URL.'), 'id' => 'mainUrlInfo'), array('text' => $this->l('The selected shop already has a Main URL. Therefore, if you set this one as the Main URL, the older of the two will be set as the normal URL.'), 'id' => 'mainUrlInfoExplain'))), array('type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'active_on', 'value' => 1), array('id' => 'active_off', 'value' => 0)))), 'submit' => array('title' => $this->l('Save')))), array('form' => array('legend' => array('title' => $this->l('Shop URL'), 'icon' => 'icon-shopping-cart'), 'input' => array(array('type' => 'text', 'label' => $this->l('Domain'), 'name' => 'domain', 'size' => 50), array('type' => 'text', 'label' => $this->l('Domain SSL'), 'name' => 'domain_ssl', 'size' => 50)), 'submit' => array('title' => $this->l('Save')))));
     if (!defined('_PS_HOST_MODE_')) {
         $this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Physical URL'), 'name' => 'physical_uri', 'desc' => $this->l('This is the physical folder for your store on the server. Leave this field empty if your store is installed on the root path (e.g. if your store is available at www.my-prestashop.com/my-store/, you input my-store/ in this field).'), 'size' => 50)));
     }
     $this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Virtual URL'), 'name' => 'virtual_uri', 'desc' => $desc_virtual_uri, 'size' => 50, 'hint' => !$update_htaccess ? $this->l('Warning: URL rewriting (e.g. mod_rewrite for Apache) seems to be disabled. If your URL doesn\'t work, please check with your host provider on how to activate URL rewriting.') : null), array('type' => 'text', 'label' => $this->l('Your final URL will be'), 'name' => 'final_url', 'size' => 76, 'readonly' => true)));
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     self::$currentIndex = self::$currentIndex . '&id_shop=' . $obj->id;
     $current_shop = Shop::initialize();
     $list_shop_with_url = array();
     foreach (Shop::getShops(false, null, true) as $id) {
         $list_shop_with_url[$id] = (bool) count(ShopUrl::getShopUrls($id));
     }
     $this->tpl_form_vars = array('js_shop_url' => Tools::jsonEncode($list_shop_with_url));
     $this->fields_value = array('domain' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain') : $current_shop->domain, 'domain_ssl' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain_ssl') : $current_shop->domain_ssl, 'physical_uri' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'physical_uri') : $current_shop->physical_uri, 'active' => true);
     return parent::renderForm();
 }
Esempio n. 2
0
 private function generateRewriteRules()
 {
     if (Configuration::get('PS_REWRITING_SETTINGS')) {
         $rules = "#start_prestanews - not remove this comment \n";
         $physical_uri = array();
         foreach (ShopUrl::getShopUrls() as $shop_url) {
             if (in_array($shop_url->physical_uri, $physical_uri)) {
                 continue;
             }
             $rules .= "RewriteRule ^(.*)news\$ " . $shop_url->physical_uri . "index.php?fc=module&module=psnews&controller=news [QSA,L] \n";
             $rules .= "RewriteRule ^(.*)news/([0-9]+)\\-([a-zA-Z0-9-]*) " . $shop_url->physical_uri . "index.php?fc=module&module=psnews&controller=news&news=\$2 [QSA,L] \n";
             $physical_uri[] = $shop_url->physical_uri;
         }
         $rules .= "#end_prestanews \n\n";
         $path = _PS_ROOT_DIR_ . '/.htaccess';
         if (is_writable($path)) {
             $existingRules = file_get_contents($path);
             if (!strpos($existingRules, "start_prestanews")) {
                 $handle = fopen($path, 'w');
                 fwrite($handle, $rules . $existingRules);
                 fclose($handle);
             }
         }
     }
 }
 public function __construct()
 {
     parent::__construct();
     $this->ht_file = _PS_ROOT_DIR_ . '/.htaccess';
     $this->rb_file = _PS_ROOT_DIR_ . '/robots.txt';
     $this->sm_file = _PS_ROOT_DIR_ . '/sitemap.xml';
     $this->rb_data = $this->getRobotsContent();
     $this->explicitSelect = true;
     $this->addRowAction('edit');
     $this->addRowAction('delete');
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
     $this->fields_list = array('id_meta' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'page' => array('title' => $this->l('Page'), 'width' => 120), 'title' => array('title' => $this->l('Title'), 'width' => 120), 'url_rewrite' => array('title' => $this->l('Friendly URL'), 'width' => 120));
     $this->_group = 'GROUP BY a.id_meta';
     // Options to generate friendly urls
     $mod_rewrite = Tools::modRewriteActive();
     $general_fields = array('PS_REWRITING_SETTINGS' => array('title' => $this->l('Friendly URL'), 'desc' => $mod_rewrite ? $this->l('Enable only if your server allows URL rewriting (recommended).') : '', 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'rewriting_settings', 'mod_rewrite' => $mod_rewrite), 'PS_ALLOW_ACCENTED_CHARS_URL' => array('title' => $this->l('Accented URL'), 'desc' => $this->l('Enable if you want to allow accented characters in your friendly URLs.') . ' ' . $this->l('You should only activate this option if you are using non-latin characters ; for all the latin charsets, your SEO will be better without this option.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CANONICAL_REDIRECT' => array('title' => $this->l('Automatically redirect to the canonical URL'), 'desc' => $this->l('Recommended, but your theme must be compliant.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'));
     $url_description = '';
     if ($this->checkConfiguration($this->ht_file)) {
         $general_fields['PS_HTACCESS_DISABLE_MULTIVIEWS'] = array('title' => $this->l('Disable apache multiviews'), 'desc' => $this->l('Enable this option only if you have problems with URL rewriting.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool');
         $general_fields['PS_HTACCESS_DISABLE_MODSEC'] = array('title' => $this->l('Disable apache mod security'), 'desc' => $this->l('Some features could not work correctly with a specific configuration of apache mod security. We recommend to turn it off.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool');
     } else {
         $url_description = $this->l('Before being able to use this tool, you need to:');
         $url_description .= '<br />- ' . $this->l('Create a blank .htaccess in your root directory.');
         $url_description .= '<br />- ' . $this->l('Give it write permissions (CHMOD 666 on Unix system)');
     }
     // Options to generate robot.txt
     $robots_description = $this->l('Your robots.txt file MUST be in your website\'s root directory and nowhere else (e.g. http://www.yoursite.com/robots.txt).');
     if ($this->checkConfiguration($this->rb_file)) {
         $robots_description .= '<br />' . $this->l('Generate your "robots.txt" file by clicking on the following button (this will erase the old robots.txt file)');
         $robots_submit = array('name' => 'submitRobots', 'title' => $this->l('Generate robots.txt file'));
     } else {
         $robots_description .= '<br />' . $this->l('Before being able to use this tool, you need to:');
         $robots_description .= '<br />- ' . $this->l('Create a blank robots.txt file in your root directory.');
         $robots_description .= '<br />- ' . $this->l('Give it write permissions (CHMOD 666 on Unix system)');
     }
     $robots_options = array('title' => $this->l('Robots file generation'), 'description' => $robots_description);
     if (isset($robots_submit)) {
         $robots_options['submit'] = $robots_submit;
     }
     // Options for shop URL if multishop is disabled
     $shop_url_options = array('title' => $this->l('Set shop URL'), 'fields' => array());
     if (!Shop::isFeatureActive()) {
         $this->url = ShopUrl::getShopUrls($this->context->shop->id)->where('main', '=', 1)->getFirst();
         if ($this->url) {
             $shop_url_options['description'] = $this->l('Here you can set the URL for your shop. If you migrate your shop to a new URL, remember to change the values below.');
             $shop_url_options['fields'] = array('domain' => array('title' => $this->l('Shop domain'), 'validation' => 'isString', 'type' => 'text', 'size' => 70, 'defaultValue' => $this->url->domain), 'domain_ssl' => array('title' => $this->l('SSL domain'), 'validation' => 'isString', 'type' => 'text', 'size' => 70, 'defaultValue' => $this->url->domain_ssl), 'uri' => array('title' => $this->l('Base URI'), 'validation' => 'isString', 'type' => 'text', 'size' => 70, 'defaultValue' => $this->url->physical_uri));
         }
     } else {
         $shop_url_options['description'] = $this->l('The multistore option is enabled. If you want to change the URL of your shop, you must go to the "Multistore" page under the "Advanced Parameters" menu.');
     }
     // List of options
     $this->fields_options = array('general' => array('title' => $this->l('Set up URLs'), 'description' => $url_description, 'fields' => $general_fields, 'submit' => array()), 'shop_url' => $shop_url_options);
     // Add display route options to options form
     if (Configuration::get('PS_REWRITING_SETTINGS')) {
         $this->fields_options['routes'] = array('title' => $this->l('Schema of URLs'), 'description' => $this->l('Change the pattern of your links. There are some available keywords for each route listed below, keywords with * are required. To add a keyword in your URL use {keyword} syntax. You can add text before or after the keyword if the keyword is not empty with syntax {prepend:keyword:append}. For example {-hey-:meta_title} will add "-hey-my-title" in the URL if the meta title is set. Friendly URL and rewriting Apache option must be activated on your web server to use this functionality.'), 'fields' => array());
         $this->addAllRouteFields();
     }
     $this->fields_options['robots'] = $robots_options;
 }
 public function ajaxProcessInfoQuery()
 {
     $this->content_only = true;
     $result = array('status' => false);
     if (time() > (int) Configuration::get('PP_INFO_CHECK_TIME')) {
         $protocol = Tools::getCurrentUrlProtocolPrefix();
         $iso_lang = Context::getContext()->language->iso_code;
         $iso_country = Context::getContext()->country->iso_code;
         $stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 3)));
         $old_content = $this->getInfo();
         $msg = $old_content === false ? 0 : $old_content[0];
         $shop_url = ShopUrl::getShopUrls($this->context->shop->id)->where('main', '=', 1)->getFirst();
         $shop = $shop_url ? $shop_url->getURL() : Tools::getShopDomain();
         $date = Db::getInstance()->getValue('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'configuration` WHERE `name` = \'PSM_ID_' . Tools::strtoupper($this->module->name) . '\'');
         $psm_date = $date ? urlencode(date('Y-m-d H:i:s', strtotime($date))) : '';
         $plugins_string = '';
         $plugins = $this->module->plugins();
         foreach ($plugins as $name => $api_version) {
             if (Module::isInstalled($name)) {
                 $plugins_string .= '&' . $name . '=' . $this->moduleVersion($name);
             }
         }
         $url = $protocol . 'store.psandmore.com/query/?key=' . $this->module->name . '&ver=' . $this->module->version . '&psm=' . PSM::getPSMId($this->module) . '&psm_date=' . $psm_date . $plugins_string . '&msg=' . $msg . '&iso_country=' . $iso_country . '&iso_lang=' . $iso_lang . '&shop=' . urlencode($shop);
         $contents = Tools::file_get_contents($url, false, $stream_context);
         $check_info_offset = 3600;
         if ($contents !== false) {
             $content = explode('|', $contents);
             if (is_numeric($content[0])) {
                 if (!$this->infoIgnore(false, $content[0])) {
                     if (Validate::isCleanHtml($content[1])) {
                         $this->putInfo($contents);
                         $check_info_offset = 86400;
                     }
                 }
             } else {
                 if ($content[0] == 'hide') {
                     Configuration::deleteByName('PP_INFO_CONTENT');
                 }
             }
         }
         Configuration::updateValue('PP_INFO_CHECK_TIME', time() + $check_info_offset);
     }
     $content = $this->getInfo();
     if ($content !== false) {
         if (!$this->infoIgnore($content)) {
             if (Validate::isCleanHtml($content[1])) {
                 $result['status'] = 'success';
                 $result['content'] = $content[1];
             }
         }
     }
     $this->content = Tools::jsonEncode($result);
 }
Esempio n. 5
0
 public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false, $disable_modsec = null)
 {
     if (defined('PS_INSTALLATION_IN_PROGRESS') && $rewrite_settings === null) {
         return true;
     }
     // Default values for parameters
     if (is_null($path)) {
         $path = _PS_ROOT_DIR_ . '/.htaccess';
     }
     if (is_null($cache_control)) {
         $cache_control = (int) Configuration::get('PS_HTACCESS_CACHE_CONTROL');
     }
     if (is_null($disable_multiviews)) {
         $disable_multiviews = (int) Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
     }
     if ($disable_modsec === null) {
         $disable_modsec = (int) Configuration::get('PS_HTACCESS_DISABLE_MODSEC');
     }
     // Check current content of .htaccess and save all code outside of prestashop comments
     $specific_before = $specific_after = '';
     if (file_exists($path)) {
         $content = file_get_contents($path);
         if (preg_match('#^(.*)\\# ~~start~~.*\\# ~~end~~[^\\n]*(.*)$#s', $content, $m)) {
             $specific_before = $m[1];
             $specific_after = $m[2];
         } else {
             // For retrocompatibility
             if (preg_match('#\\# http://www\\.prestashop\\.com - http://www\\.prestashop\\.com/forums\\s*(.*)<IfModule mod_rewrite\\.c>#si', $content, $m)) {
                 $specific_before = $m[1];
             } else {
                 $specific_before = $content;
             }
         }
     }
     // Write .htaccess data
     if (!($write_fd = fopen($path, 'w'))) {
         return false;
     }
     if ($specific_before) {
         fwrite($write_fd, trim($specific_before) . "\n\n");
     }
     $domains = array();
     foreach (ShopUrl::getShopUrls() as $shop_url) {
         if (!isset($domains[$shop_url->domain])) {
             $domains[$shop_url->domain] = array();
         }
         $domains[$shop_url->domain][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
         if ($shop_url->domain == $shop_url->domain_ssl) {
             continue;
         }
         if (!isset($domains[$shop_url->domain_ssl])) {
             $domains[$shop_url->domain_ssl] = array();
         }
         $domains[$shop_url->domain_ssl][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
     }
     // Write data in .htaccess file
     fwrite($write_fd, "# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again\n");
     fwrite($write_fd, "# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution\n");
     fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
     if ($disable_modsec) {
         fwrite($write_fd, "<IfModule mod_security.c>\nSecFilterEngine Off\nSecFilterScanPOST Off\n</IfModule>\n\n");
     }
     fwrite($write_fd, "<IfModule mod_headers.c>\n");
     fwrite($write_fd, "Header set Access-Control-Allow-Origin: *\n");
     fwrite($write_fd, 'Header set Access-Control-Allow-Headers: "cache-control"' . "\n");
     fwrite($write_fd, "</IfModule>\n");
     // RewriteEngine
     fwrite($write_fd, "<IfModule mod_rewrite.c>\n");
     // Ensure HTTP_MOD_REWRITE variable is set in environment
     fwrite($write_fd, "<IfModule mod_env.c>\n");
     fwrite($write_fd, "SetEnv HTTP_MOD_REWRITE On\n");
     fwrite($write_fd, "</IfModule>\n\n");
     // Disable multiviews ?
     if ($disable_multiviews) {
         fwrite($write_fd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
     }
     fwrite($write_fd, "RewriteEngine on\n\n");
     fwrite($write_fd, "RewriteCond %{REQUEST_URI} ^/komplekty\$\n");
     fwrite($write_fd, "RewriteRule ^.*\$ http://decor.etagerca.ru/complects/ [R=301,L]\n\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans\$ /style/klassicheskaja-mebel-provans [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/divany\$ /style/dizajnerskaja-mebel/divany [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/komody\$ /style/dizajnerskaja-mebel/komody [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/kresla\$ /style/dizajnerskaja-mebel/kresla [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/krovati\$ /style/dizajnerskaja-mebel/krovati [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/konsoli\$ /style/dizajnerskaja-mebel/konsoli [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/stoly\$ /style/dizajnerskaja-mebel/stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/pufi\$ /style/dizajnerskaja-mebel/pufi [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/shkafy\$ /style/dizajnerskaja-mebel/shkafy [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^dizajnerskaja-mebel/stulya\$ /style/dizajnerskaja-mebel/stulya [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/bufety\$ /style/klassicheskaja-mebel-provans/bufety [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/divany\$ /style/klassicheskaja-mebel-provans/divany [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/komody\$ /style/klassicheskaja-mebel-provans/komody [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/konsoli\$ /style/klassicheskaja-mebel-provans/konsoli [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/kresla\$ /style/klassicheskaja-mebel-provans/kresla [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/krovati\$ /style/klassicheskaja-mebel-provans/krovati [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/obedennye-stoly\$ /style/klassicheskaja-mebel-provans/obedennye-stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/shkafy\$ /style/klassicheskaja-mebel-provans/shkafy [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/stoly\$ /style/klassicheskaja-mebel-provans/stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/stulya\$ /style/klassicheskaja-mebel-provans/stulya [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/tumbochki\$ /style/klassicheskaja-mebel-provans/tumbochki [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^klassicheskaja-mebel-provans/gazetnicy\$ /style/klassicheskaja-mebel-provans/gazetnicy [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-v-stile-loft/divany\$ /style/mebel-v-stile-loft/divany [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-v-stile-loft/stoly\$ /style/mebel-v-stile-loft/stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-v-stile-shebbi-shik\$ /style/mebel-v-stile-shebbi-shik [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-v-stile-kantry\$ /style/mebel-v-stile-kantry [R=301,L]\n\n");
     fwrite($write_fd, "RewriteRule ^kozhanaja-mebel/komody\$ /material/kozhanaja-mebel/komody [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^kozhanaja-mebel/kresla\$ /material/kozhanaja-mebel/kresla [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^kozhanaja-mebel/divany\$ /material/kozhanaja-mebel/divany [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-iz-massiva/divany\$ /material/mebel-iz-massiva/divany [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-iz-massiva/komody\$ /material/mebel-iz-massiva/komody [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-iz-massiva/kresla\$ /material/mebel-iz-massiva/kresla [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-iz-massiva/pismennye-stoly\$ /material/mebel-iz-massiva/pismennye-stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-iz-massiva/stoly\$ /material/mebel-iz-massiva/stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-iz-massiva/stulya\$ /material/mebel-iz-massiva/stulya [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-iz-massiva/obedennye-gruppy\$ /material/mebel-iz-massiva/obedennye-gruppy [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^myagkaja-mebel/kresla\$ /material/myagkaja-mebel/kresla [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^myagkaja-mebel/divany\$ /material/myagkaja-mebel/divany [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^wrought-iron-furniture\$ /material/wrought-iron-furniture [R=301,L]\n\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-gostinoj/divany\$ /type/mebel-dlja-gostinoj/divany [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-gostinoj/komody\$ /type/mebel-dlja-gostinoj/komody [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-gostinoj/kresla\$ /type/mebel-dlja-gostinoj/kresla [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-gostinoj/stellazhi\$ /type/mebel-dlja-gostinoj/stellazhi [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-gostinoj/stoly\$ /type/mebel-dlja-gostinoj/stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-gostinoj/stulya\$ /type/mebel-dlja-gostinoj/stulya [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-gostinoj/shkafy\$ /type/mebel-dlja-gostinoj/shkafy [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-kabineta/divany\$ /type/mebel-dlja-kabineta/divany [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-kabineta/kresla\$ /type/mebel-dlja-kabineta/kresla [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-kabineta/shkafy\$ /type/mebel-dlja-kabineta/shkafy [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-kabineta/stoly\$ /type/mebel-dlja-kabineta/stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-kabineta/stulya\$ /type/mebel-dlja-kabineta/stulya [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-kabineta/komody\$ /type/mebel-dlja-kabineta/komody [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-kabineta/stellazhi\$ /type/mebel-dlja-kabineta/stellazhi [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-spalny/divany\$ /type/mebel-dlja-spalny/divany [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-spalny/komody\$ /type/mebel-dlja-spalny/komody [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-spalny/kresla\$ /type/mebel-dlja-spalny/kresla [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-spalny/krovati\$ /type/mebel-dlja-spalny/krovati [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-spalny/prikrovatnye-stoliky\$ /type/mebel-dlja-spalny/prikrovatnye-stoliky [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-spalny/shkafy\$ /type/mebel-dlja-spalny/shkafy [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-spalny/stulya\$ /type/mebel-dlja-spalny/stulya [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-spalny/stoly\$ /type/mebel-dlja-spalny/stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-stolovoj/bufety\$ /type/mebel-dlja-stolovoj/bufety [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-stolovoj/obedennye-gruppy\$ /type/mebel-dlja-stolovoj/obedennye-gruppy [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-stolovoj/obedennye-stoly\$ /type/mebel-dlja-stolovoj/obedennye-stoly [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-stolovoj/stellazhi\$ /type/mebel-dlja-stolovoj/stellazhi [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^mebel-dlja-stolovoj/stulya\$ /type/mebel-dlja-stolovoj/stulya [R=301,L]\n\n");
     fwrite($write_fd, "RewriteRule ^leontina\$ /collections/leontina [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^olivia\$ /collections/olivia [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^bruni\$ /collections/bruni [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^aquarelle\$ /collections/aquarelle [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^gouache\$ /collections/gouache [R=301,L]\n");
     fwrite($write_fd, "RewriteRule ^emerson\$ /collections/emerson [R=301,L]\n\n");
     if (!$medias && defined('_MEDIA_SERVER_1_') && defined('_MEDIA_SERVER_2_') && defined('_MEDIA_SERVER_3_')) {
         $medias = array(_MEDIA_SERVER_1_, _MEDIA_SERVER_2_, _MEDIA_SERVER_3_);
     }
     $media_domains = '';
     if ($medias[0] != '') {
         $media_domains = 'RewriteCond %{HTTP_HOST} ^' . $medias[0] . '$ [OR]' . "\n";
     }
     if ($medias[1] != '') {
         $media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[1] . '$ [OR]' . "\n";
     }
     if ($medias[2] != '') {
         $media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[2] . '$ [OR]' . "\n";
     }
     if (Configuration::get('PS_WEBSERVICE_CGI_HOST')) {
         fwrite($write_fd, "RewriteCond %{HTTP:Authorization} ^(.*)\nRewriteRule . - [E=HTTP_AUTHORIZATION:%1]\n\n");
     }
     foreach ($domains as $domain => $list_uri) {
         $physicals = array();
         foreach ($list_uri as $uri) {
             if (Shop::isFeatureActive()) {
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^' . $domain . '$' . "\n");
             }
             fwrite($write_fd, 'RewriteRule . - [E=REWRITEBASE:' . $uri['physical'] . ']' . "\n");
             // Webservice
             fwrite($write_fd, 'RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]' . "\n\n");
             if (!$rewrite_settings) {
                 $rewrite_settings = (int) Configuration::get('PS_REWRITING_SETTINGS', null, null, (int) $uri['id_shop']);
             }
             $domain_rewrite_cond = 'RewriteCond %{HTTP_HOST} ^' . $domain . '$' . "\n";
             // Rewrite virtual multishop uri
             if ($uri['virtual']) {
                 if (!$rewrite_settings) {
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^' . trim($uri['virtual'], '/') . '/?$ ' . $uri['physical'] . $uri['virtual'] . "index.php [L,R]\n");
                 } else {
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^' . trim($uri['virtual'], '/') . '$ ' . $uri['physical'] . $uri['virtual'] . " [L,R]\n");
                 }
                 fwrite($write_fd, $media_domains);
                 if (Shop::isFeatureActive()) {
                     fwrite($write_fd, $domain_rewrite_cond);
                 }
                 fwrite($write_fd, 'RewriteRule ^' . ltrim($uri['virtual'], '/') . '(.*) ' . $uri['physical'] . "\$1 [L]\n\n");
             }
             if ($rewrite_settings) {
                 fwrite($write_fd, "##редиректы со старого сайта start\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.rudecoration$ http://decor.etagerca.ru [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ruaccessories$ http://decor.etagerca.ru/-accessories [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^15-kozhanaja-mebel$ http://etagerca.ru/kozhanaja-mebel [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^30-boxes-and-boxes$ http://decor.etagerca.ru/boxes-and-boxes [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^vases$ http://decor.etagerca.ru/vases [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^frames-for-photos$ http://decor.etagerca.ru/frames-for-photos [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^boxes-and-boxes$ http://decor.etagerca.ru/boxes-and-boxes [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^candles-and-candlesticks$ http://decor.etagerca.ru/candles-and-candlesticks [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^watch$ http://decor.etagerca.ru/watch [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^ornamental-flowerpot$ http://decor.etagerca.ru/ornamental-flowerpot [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^accessories$ http://decor.etagerca.ru/-accessories [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^flowers$ http://decor.etagerca.ru/flowers [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^-korzini-$ http://decor.etagerca.ru/-korzini- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^-shkatulki-$ http://decor.etagerca.ru/-shkatulki- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^-prinadlejnosti-dlia-vanna-$ http://decor.etagerca.ru/-prinadlejnosti-dlia-vanna- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^-dekor-na-stenu-$ http://decor.etagerca.ru/-dekor-na-stenu- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteRule ^dekorativnye-svechi$ http://decor.etagerca.ru/dekorativnye-svechi [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^new/$ http://etagerca.ru/content/-novosti- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^27-vases$ http://decor.etagerca.ru/vases [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^11-mirrors$ http://etagerca.ru/mirrors [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^13--gift-ideas$ http://etagerca.ru/gift-ideas [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^16--wrought-iron-furniture$ http://etagerca.ru/wrought-iron-furniture [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^45-other$ http://etagerca.ru/other [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^48--accessories-$ http://etagerca.ru/gift-ideas [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^70-zonty$ http://etagerca.ru/gift-ideas [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^69--korzini$ http://decor.etagerca.ru/-korzini- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru27-vases$ http://decor.etagerca.ru/vases [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru33-watch$ http://decor.etagerca.ru/watch [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru71-letnyaya-obuv$ http://decor.etagerca.ru/-dekor-na-stenu- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru70-zonty$  http://decor.etagerca.ru/-shkatulki- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru28--frames-for-photos  http://decor.etagerca.ru/frames-for-photos [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru31--candles-and-candlesticks  http://decor.etagerca.ru/candles-and-candlesticks [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru30--panel-  http://decor.etagerca.ru/boxes-and-boxes [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru35-ornamental-flowerpot  http://decor.etagerca.ru/ornamental-flowerpot [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ruboxes-and-boxes http://decor.etagerca.ru/dekorativnoe-nastennoe-panno [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.rucandles-and-candlesticks http://decor.etagerca.ru/podsvechniki [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ruflowers http://decor.etagerca.ru/iskusstvennye-cvety [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ruornamental-flowerpot http://decor.etagerca.ru/kashpo-dlja-cvetov [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru-shkatulki- http://decor.etagerca.ru/sunduki-i-shkatulki [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ruvases http://decor.etagerca.ru/vazy-dlja-cvetov [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ruwatch http://decor.etagerca.ru/originalnye-nastennye-chasy [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.rucart.php  /cart.php [QSA,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru[a-zA-Z0-9-]*/([0-9]+)\\-[a-zA-Z0-9-]*(\\.html)? /product.php?id_product=$1 [QSA,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ruindex.php  /category.php?id_category=decoration&noredirect=1 [QSA,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru([a-zA-Z0-9-]+)$ /category.php?id_category=$1&noredirect=1 [QSA,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru([0-9]+)\\-[a-zA-Z0-9-]*\\.html /product.php?id_product=$1 [QSA,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^decor\\.etagerca.ru[a-zA-Z0-9-]*/([0-9]+)\\-[a-zA-Z0-9-]*\\.html /product.php?id_product=$1 [QSA,L]' . "\n");
                 // fwrite($write_fd, 'RewriteRule ^63--dizainerskie-komody-$ http://etagerca.ru/dizajnerskie-komody [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^63--dizainerskie-komody-\$ http://etagerca.ru/dizajnerskaja-mebel/komody [R=301,L]" . "\n");
                 //fwrite($write_fd, 'RewriteRule ^53--kojanie-komodi-$ http://etagerca.ru/kozhanye-komody [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^53--kojanie-komodi-\$ http://etagerca.ru/kozhanaja-mebel/komody [R=301,L]" . "\n");
                 //fwrite($write_fd, 'RewriteRule ^52--kojanie-divani-$ http://etagerca.ru/kozhanye-divany [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^52--kojanie-divani-\$ http://etagerca.ru/kozhanaja-mebel/divany [R=301,L]" . "\n");
                 // fwrite($write_fd, 'RewriteRule ^55--klassicheskie-komody-$ http://etagerca.ru/komody [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^55--klassicheskie-komody-\$ http://etagerca.ru/mebel/komody [R=301,L]" . "\n");
                 // fwrite($write_fd, 'RewriteRule ^57--klassicheskie-stoly-$ http://etagerca.ru/stoly [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^57--klassicheskie-stoly-\$ http://etagerca.ru/mebel/stoly [R=301,L]" . "\n");
                 //fwrite($write_fd, 'RewriteRule ^58--klassicheskie-shkafy-$ http://etagerca.ru/shkafy [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^58--klassicheskie-shkafy-\$ http://etagerca.ru/mebel/shkafy [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteRule ^60--mebel-provans-$ http://etagerca.ru/provans-mebel [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^prices-drop$ http://etagerca.ru/skidki [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^7-furniture$ http://etagerca.ru/mebel [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^15--leather-furniture$ http://etagerca.ru/kozhanaja-mebel [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^18--furniture-provence-$ http://etagerca.ru/klassicheskaja-mebel [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^50--soft-furniture-$ http://etagerca.ru/dizajnerskaja-mebel [R=301,L]' . "\n");
                 // fwrite($write_fd, 'RewriteRule ^61--klassicheskie-gazetnicy-$ http://etagerca.ru/klassicheskie-gazetnicy [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^61--klassicheskie-gazetnicy-\$ http://etagerca.ru/mebel/gazetnicy [R=301,L]" . "\n");
                 //  fwrite($write_fd, 'RewriteRule ^klassicheskie-gazetnicy$ http://etagerca.ru/gazetnicy [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-gazetnicy\$ http://etagerca.ru/mebel/gazetnicy [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteRule ^klassicheskaja-mebel$ http://etagerca.ru/klassicheskaja-mebel-provans [R=301,L]' . "\n");
                 // fwrite($write_fd, 'RewriteRule ^provans-mebel$ http://etagerca.ru/klassicheskaja-mebel-provans [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^provans-mebel\$ http://etagerca.ru/klassicheskaja-mebel-provans [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteRule ^klassicheskaja-mebel/(.*)$ http://etagerca.ru/klassicheskaja-mebel-provans/$1 [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, "RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1037\\ HTTP/" . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/1037--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteCond %{HTTP_HOST} ^etagerca.ru" . "\n");
                 fwrite($write_fd, "RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1042\\ HTTP/" . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/1042--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteCond %{HTTP_HOST} ^etagerca.ru" . "\n");
                 fwrite($write_fd, "RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1044\\ HTTP/" . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/1044--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteCond %{HTTP_HOST} ^etagerca.ru" . "\n");
                 fwrite($write_fd, "RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1035\\ HTTP/" . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/1035--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteCond %{HTTP_HOST} ^etagerca.ru" . "\n");
                 fwrite($write_fd, "RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1043\\ HTTP/" . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/1043--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1032\\ HTTP/' . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/1032--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteCond %{HTTP_HOST} ^etagerca.ru" . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1038\\ HTTP/' . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/1038--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1041\\ HTTP/' . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/1041--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteCond %{HTTP_HOST} ^etagerca.ru" . "\n");
                 fwrite($write_fd, "RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1039\\ HTTP/" . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/1039--.html? [R=301,L]" . "\n");
                 //fwrite($write_fd, 'RewriteRule ^stoly-dlya-stolovoj$ http://etagerca.ru/obedennye-stoly [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^stoly-dlya-stolovoj\$ http://etagerca.ru/mebel-dlja-stolovoj/stoly [R=301,L]" . "\n");
                 //  fwrite($write_fd, 'RewriteRule ^klassicheskie-komody$ http://etagerca.ru/klassicheskie-komody-provans [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-komody\$ http://etagerca.ru/klassicheskaja-mebel-provans/komody [R=301,L]" . "\n");
                 //  fwrite($write_fd, 'RewriteRule ^klasicheskie-konsoli$ http://etagerca.ru/klasicheskie-konsoli-provans [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^klasicheskie-konsoli\$ http://etagerca.ru/klassicheskaja-mebel-provans/konsoli [R=301,L]" . "\n");
                 //fwrite($write_fd, 'RewriteRule ^klassicheskie-stoly$ http://etagerca.ru/klassicheskie-stoly-provans [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-stoly\$ http://etagerca.ru/klassicheskaja-mebel-provans/stoly [R=301,L]" . "\n");
                 //fwrite($write_fd, 'RewriteRule ^klassicheskie-shkafy$ http://etagerca.ru/klassicheskie-shkafy-provans [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-shkafy\$ http://etagerca.ru/klassicheskaja-mebel-provans/shkafy [R=301,L]" . "\n");
                 // fwrite($write_fd, 'RewriteRule ^klassicheskie-stulya$ http://etagerca.ru/klassicheskie-stulya-provans [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-stulya\$ http://etagerca.ru/klassicheskaja-mebel-provans/stulya [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteRule ^klassicheskie-gazetnicy$ http://etagerca.ru/klassicheskie-gazetnicy-provans [R=301,L]' . "\n");
                 // fwrite($write_fd, 'RewriteRule ^klassicheskie-divany$ http://etagerca.ru/klassicheskie-divany-provans [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-divany\$ http://etagerca.ru/klassicheskaja-mebel-provans/divany [R=301,L]" . "\n");
                 //fwrite($write_fd, 'RewriteRule ^klassicheskie-kresla$ http://etagerca.ru/klassicheskie-kresla-provans [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-kresla\$ http://etagerca.ru/klassicheskaja-mebel-provans/kresla [R=301,L]" . "\n");
                 // fwrite($write_fd, 'RewriteRule ^klassicheskie-krovati$ http://etagerca.ru/klassicheskie-krovati-provans [R=301,L]'."\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-krovati\$ http://etagerca.ru/klassicheskaja-mebel-provans/krovati [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteRule ^content/-$ http://etagerca.ru/content/-programma-loyalnosti- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^klassicheskie-stulya/(.*)\\.html http://etagerca.ru/klassicheskie-stulya-provans/$1.html [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1128\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/mebel/1128--.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=653\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/klassicheskie-stulya/653--.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1047\\ HTTP/' . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$  http://etagerca.ru/1047--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1046\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/1046--.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1021\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/mebel/1021--candy.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1117\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/1117--.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1103\\ HTTP/' . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$  http://etagerca.ru/1103--.html? [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1112\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/1112--.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1076\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/1076--portobello-brun.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1102\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/1102--.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=87\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/cups-kettles-jars/87--.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=715\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/light/715--aurore-.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=90\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/cups-kettles-jars/90--plume.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /product\\.php\\?id_product=1107\\ HTTP/' . "\n");
                 fwrite($write_fd, 'RewriteRule ^(.*)$  http://etagerca.ru/1107--.html? [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^-leather-furniture/138--\\.html http://etagerca.ru/kozhanaja-mebel/138--.html [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^kresla/652--.html http://etagerca.ru/klassicheskie-kresla-provans/652--.html [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^44-glass http://etagerca.ru/glass [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^46-dishes-and-plates- http://etagerca.ru/dishes-and-plates- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^7-mebel http://etagerca.ru/mebel [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^content/5--novosti- http://etagerca.ru/content/-novosti- [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /prices-drop\\.php\\ HTTP/' . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/skidki? [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^etagerca.ru' . "\n");
                 fwrite($write_fd, 'RewriteCond %{THE_REQUEST} GET\\ /best-sales\\.php\\ HTTP/' . "\n");
                 fwrite($write_fd, "RewriteRule ^(.*)\$ http://etagerca.ru/best-sales? [R=301,L]" . "\n");
                 fwrite($write_fd, 'RewriteRule ^home$ http://etagerca.ru/mebel [R=301,L]' . "\n");
                 fwrite($write_fd, 'RewriteRule ^content/contacts$ http://etagerca.ru/content/Contacts [R=301,L]' . "\n");
                 fwrite($write_fd, "##редиректы со старого сайта end\n\n");
                 fwrite($write_fd, "##редиректы после изменения формирования url start\n");
                 fwrite($write_fd, "RewriteRule ^-dizainerskie-divany-\$ http://etagerca.ru/dizajnerskaja-mebel/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^dizajnerskie-komody\$ http://etagerca.ru/dizajnerskaja-mebel/komody [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^dizajnerskie-kresla\$ http://etagerca.ru/dizajnerskaja-mebel/kresla [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^dizajnerskie-krovati\$ http://etagerca.ru/dizajnerskaja-mebel/krovati [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^dizainerskie-konsoli\$ http://etagerca.ru/dizajnerskaja-mebel/konsoli [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^dizainerskie-stoly\$ http://etagerca.ru/dizajnerskaja-mebel/stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^dizajnerskie-pufi\$ http://etagerca.ru/dizajnerskaja-mebel/pufi [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^dizajnerskie-shkafy\$ http://etagerca.ru/dizajnerskaja-mebel/shkafy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^dizajnerskie-stulja\$ http://etagerca.ru/dizajnerskaja-mebel/stulya [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^bufety-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/bufety [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-divany-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-komody-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/komody [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^klasicheskie-konsoli-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/konsoli [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-kresla-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/kresla [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-krovati-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/krovati [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^obedennye-stoly-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/obedennye-stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-shkafy-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/shkafy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-stoly-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-stulya-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/stulya [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^tumbochki-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/tumbochki [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^klassicheskie-gazetnicy-provans\$ http://etagerca.ru/klassicheskaja-mebel-provans/gazetnicy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^kozhanye-komody\$ http://etagerca.ru/kozhanaja-mebel/komody [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^kojanie-kresla\$ http://etagerca.ru/kozhanaja-mebel/kresla [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^kozhanye-divany\$ http://etagerca.ru/kozhanaja-mebel/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^divany\$ http://etagerca.ru/mebel/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^gazetnicy\$ http://etagerca.ru/mebel/gazetnicy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^komody\$ http://etagerca.ru/mebel/komody [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^kresla\$ http://etagerca.ru/mebel/kresla [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^krovati\$ http://etagerca.ru/mebel/krovati [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^pufi\$ http://etagerca.ru/mebel/pufi [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stelajy\$ http://etagerca.ru/mebel/stellazhi [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^prikrovatnye-tumbochki\$ http://etagerca.ru/mebel/tumbochki [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^bufety\$ http://etagerca.ru/mebel/bufety [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stoly\$ http://etagerca.ru/mebel/stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stulya\$ http://etagerca.ru/mebel/stulya [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^shkafy\$ http://etagerca.ru/mebel/shkafy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^konsoly\$ http://etagerca.ru/mebel/konsoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^divany-dlja-gostinoj\$ http://etagerca.ru/mebel-dlja-gostinoj/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^komody-dlja-gostinoj\$ http://etagerca.ru/mebel-dlja-gostinoj/komody [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^kresla-dlja-gostinoj\$ http://etagerca.ru/mebel-dlja-gostinoj/kresla [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stellazhi-dlja-gostinoj\$ http://etagerca.ru/mebel-dlja-gostinoj/stellazhi [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stoly-dlya-gostinoj\$ http://etagerca.ru/mebel-dlja-gostinoj/stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stulja-dlja-gostinoj\$ http://etagerca.ru/mebel-dlja-gostinoj/stulya [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^shkafy-dlja-gostinoj\$ http://etagerca.ru/mebel-dlja-gostinoj/shkafy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^divany-dlja-kabineta\$ http://etagerca.ru/mebel-dlja-kabineta/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^kresla-dlja-kabineta\$ http://etagerca.ru/mebel-dlja-kabineta/kresla [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^shkafy-dlja-kabineta\$ http://etagerca.ru/mebel-dlja-kabineta/shkafy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stoly-dlja-kabineta\$ http://etagerca.ru/mebel-dlja-kabineta/stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stulia-dlja-kabineta\$ http://etagerca.ru/mebel-dlja-kabineta/stulya [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^komody-dlja-kabineta\$ http://etagerca.ru/mebel-dlja-kabineta/komody [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stellaji-dlja-kabineta\$ http://etagerca.ru/mebel-dlja-kabineta/stellazhi [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^divany-dlja-spalny\$ http://etagerca.ru/mebel-dlja-spalny/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^komody-dlja-spalny\$ http://etagerca.ru/mebel-dlja-spalny/komody [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^kresla-dlja-spalny\$ http://etagerca.ru/mebel-dlja-spalny/kresla [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^krovaty-dlja-spalny\$ http://etagerca.ru/mebel-dlja-spalny/krovati [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^prikrovatnye-stoliky-dlja-spalny\$ http://etagerca.ru/mebel-dlja-spalny/prikrovatnye-stoliky [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^shkafy-dlja-spalny\$ http://etagerca.ru/mebel-dlja-spalny/shkafy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stulja-dlja-spalny\$ http://etagerca.ru/mebel-dlja-spalny/stulya [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stoly-dlja-spalny\$ http://etagerca.ru/mebel-dlja-spalny/stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^bufety-dlja-stolovoj\$ http://etagerca.ru/mebel-dlja-stolovoj/bufety [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^obedennye-gruppy\$ http://etagerca.ru/mebel-dlja-stolovoj/obedennye-gruppy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^obedennye-stoly\$ http://etagerca.ru/mebel-dlja-stolovoj/obedennye-stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stellazhi-dlja-stolovoj\$ http://etagerca.ru/mebel-dlja-stolovoj/stellazhi [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stulja-dlja-stolovoj\$ http://etagerca.ru/mebel-dlja-stolovoj/stulya [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^divany-iz-massiva\$ http://etagerca.ru/mebel-iz-massiva/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^komody-iz-massiva\$ http://etagerca.ru/mebel-iz-massiva/komody [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^kresla-iz-massiva\$ http://etagerca.ru/mebel-iz-massiva/kresla [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^pismennye-stoly-iz-massiva\$ http://etagerca.ru/mebel-iz-massiva/pismennye-stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stoly-iz-massiva\$ http://etagerca.ru/mebel-iz-massiva/stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stulja-iz-massiva-dereva\$ http://etagerca.ru/mebel-iz-massiva/stulya [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^obedennye-gruppy-iz-massiva\$ http://etagerca.ru/mebel-iz-massiva/obedennye-gruppy [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^divany-v-stile-loft\$ http://etagerca.ru/mebel-v-stile-loft/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^stoly-v-stile-loft\$ http://etagerca.ru/mebel-v-stile-loft/stoly [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^mjagkie-kresla\$ http://etagerca.ru/myagkaja-mebel/kresla [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^mjagkie-divany\$ http://etagerca.ru/myagkaja-mebel/divany [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^tablecloths\$ http://etagerca.ru/textile/tablecloths [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^pillows\$ http://etagerca.ru/textile/pillows [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^salfetki\$ http://etagerca.ru/textile/salfetki [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^glass\$ http://etagerca.ru/dishes/glass [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^other\$ http://etagerca.ru/dishes/other [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^dishes-and-plates-\$ http://etagerca.ru/dishes/dishes-and-plates [R=301,L]" . "\n");
                 fwrite($write_fd, "RewriteRule ^cups-kettles-jars\$ http://etagerca.ru/dishes/cups-kettles-jars [R=301,L]" . "\n");
                 fwrite($write_fd, "##редиректы после изменения формирования url end\n");
                 // Compatibility with the old image filesystem
                 fwrite($write_fd, "# Images\n");
                 if (Configuration::get('PS_LEGACY_IMAGES')) {
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^([a-z0-9]+)\\-([a-z0-9]+)(\\-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3$4.jpg [L]' . "\n");
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^([0-9]+)\\-([0-9]+)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3.jpg [L]' . "\n");
                 }
                 // Rewrite product images < 100 millions
                 for ($i = 1; $i <= 8; $i++) {
                     $img_path = $img_name = '';
                     for ($j = 1; $j <= $i; $j++) {
                         $img_path .= '$' . $j . '/';
                         $img_name .= '$' . $j;
                     }
                     $img_name .= '$' . $j;
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^' . str_repeat('([0-9])', $i) . '(\\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/p/' . $img_path . $img_name . '$' . ($j + 1) . ".jpg [L]\n");
                 }
                 fwrite($write_fd, $media_domains);
                 if (Shop::isFeatureActive()) {
                     fwrite($write_fd, $domain_rewrite_cond);
                 }
                 fwrite($write_fd, 'RewriteRule ^c/([0-9]+)(\\-[\\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]' . "\n");
                 fwrite($write_fd, $media_domains);
                 if (Shop::isFeatureActive()) {
                     fwrite($write_fd, $domain_rewrite_cond);
                 }
                 fwrite($write_fd, 'RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]' . "\n");
             }
             fwrite($write_fd, "# AlphaImageLoader for IE and fancybox\n");
             if (Shop::isFeatureActive()) {
                 fwrite($write_fd, $domain_rewrite_cond);
             }
             fwrite($write_fd, 'RewriteRule ^images_ie/?([^/]+)\\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]' . "\n");
         }
         // Redirections to dispatcher
         if ($rewrite_settings) {
             fwrite($write_fd, "\n# Dispatcher\n");
             fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} -s [OR]\n");
             fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} -l [OR]\n");
             fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} -d\n");
             if (Shop::isFeatureActive()) {
                 fwrite($write_fd, $domain_rewrite_cond);
             }
             fwrite($write_fd, "RewriteRule ^.*\$ - [NC,L]\n");
             if (Shop::isFeatureActive()) {
                 fwrite($write_fd, $domain_rewrite_cond);
             }
             fwrite($write_fd, "RewriteRule ^.*\$ %{ENV:REWRITEBASE}index.php [NC,L]\n");
         }
     }
     fwrite($write_fd, "</IfModule>\n\n");
     fwrite($write_fd, "AddType application/vnd.ms-fontobject .eot\n");
     fwrite($write_fd, "AddType font/ttf .ttf\n");
     fwrite($write_fd, "AddType font/otf .otf\n");
     fwrite($write_fd, "AddType application/x-font-woff .woff\n\n");
     // Cache control
     if ($cache_control) {
         $cache_control = "<IfModule mod_expires.c>\n\tExpiresActive On\n\tExpiresByType image/gif \"access plus 1 month\"\n\tExpiresByType image/jpeg \"access plus 1 month\"\n\tExpiresByType image/png \"access plus 1 month\"\n\tExpiresByType text/css \"access plus 1 week\"\n\tExpiresByType text/javascript \"access plus 1 week\"\n\tExpiresByType application/javascript \"access plus 1 week\"\n\tExpiresByType application/x-javascript \"access plus 1 week\"\n\tExpiresByType image/x-icon \"access plus 1 year\"\n\tExpiresByType image/svg+xml \"access plus 1 year\"\n\tExpiresByType image/vnd.microsoft.icon \"access plus 1 year\"\n\tExpiresByType application/font-woff \"access plus 1 year\"\n\tExpiresByType application/x-font-woff \"access plus 1 year\"\n\tExpiresByType application/vnd.ms-fontobject \"access plus 1 year\"\n\tExpiresByType font/opentype \"access plus 1 year\"\n\tExpiresByType font/ttf \"access plus 1 year\"\n\tExpiresByType font/otf \"access plus 1 year\"\n\tExpiresByType application/x-font-ttf \"access plus 1 year\"\n\tExpiresByType application/x-font-otf \"access plus 1 year\"\n</IfModule>\n\nFileETag INode MTime Size\n<IfModule mod_deflate.c>\n\t<IfModule mod_filter.c>\n\t\tAddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript\n\t</IfModule>\n</IfModule>\n\n";
         fwrite($write_fd, $cache_control);
     }
     // In case the user hasn't rewrite mod enabled
     fwrite($write_fd, "#If rewrite mod isn't enabled\n");
     // Do not remove ($domains is already iterated upper)
     reset($domains);
     $domain = current($domains);
     fwrite($write_fd, 'ErrorDocument 404 ' . $domain[0]['physical'] . "index.php?controller=404\n\n");
     fwrite($write_fd, "# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again");
     if ($specific_after) {
         fwrite($write_fd, "\n\n" . trim($specific_after));
     }
     fclose($write_fd);
     if (!defined('PS_INSTALLATION_IN_PROGRESS')) {
         Hook::exec('actionHtaccessCreate');
     }
     return true;
 }
Esempio n. 6
0
 public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false, $disable_modsec = null)
 {
     if (defined('PS_INSTALLATION_IN_PROGRESS') && $rewrite_settings === null) {
         return true;
     }
     // Default values for parameters
     if (is_null($path)) {
         $path = _PS_ROOT_DIR_ . '/.htaccess';
     }
     if (is_null($cache_control)) {
         $cache_control = (int) Configuration::get('PS_HTACCESS_CACHE_CONTROL');
     }
     if (is_null($disable_multiviews)) {
         $disable_multiviews = (int) Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
     }
     if ($disable_modsec === null) {
         $disable_modsec = (int) Configuration::get('PS_HTACCESS_DISABLE_MODSEC');
     }
     // Check current content of .htaccess and save all code outside of prestashop comments
     $specific_before = $specific_after = '';
     if (file_exists($path)) {
         $content = file_get_contents($path);
         if (preg_match('#^(.*)\\# ~~start~~.*\\# ~~end~~[^\\n]*(.*)$#s', $content, $m)) {
             $specific_before = $m[1];
             $specific_after = $m[2];
         } else {
             // For retrocompatibility
             if (preg_match('#\\# http://www\\.prestashop\\.com - http://www\\.prestashop\\.com/forums\\s*(.*)<IfModule mod_rewrite\\.c>#si', $content, $m)) {
                 $specific_before = $m[1];
             } else {
                 $specific_before = $content;
             }
         }
     }
     // Write .htaccess data
     if (!($write_fd = @fopen($path, 'w'))) {
         return false;
     }
     if ($specific_before) {
         fwrite($write_fd, trim($specific_before) . "\n\n");
     }
     $domains = array();
     foreach (ShopUrl::getShopUrls() as $shop_url) {
         if (!isset($domains[$shop_url->domain])) {
             $domains[$shop_url->domain] = array();
         }
         $domains[$shop_url->domain][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
         if ($shop_url->domain == $shop_url->domain_ssl) {
             continue;
         }
         if (!isset($domains[$shop_url->domain_ssl])) {
             $domains[$shop_url->domain_ssl] = array();
         }
         $domains[$shop_url->domain_ssl][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
     }
     // Write data in .htaccess file
     fwrite($write_fd, "# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again\n");
     fwrite($write_fd, "# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution\n");
     fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
     if ($disable_modsec) {
         fwrite($write_fd, "<IfModule mod_security.c>\nSecFilterEngine Off\nSecFilterScanPOST Off\n</IfModule>\n\n");
     }
     // RewriteEngine
     fwrite($write_fd, "<IfModule mod_rewrite.c>\n");
     // Ensure HTTP_MOD_REWRITE variable is set in environment
     fwrite($write_fd, "<IfModule mod_env.c>\n");
     fwrite($write_fd, "SetEnv HTTP_MOD_REWRITE On\n");
     fwrite($write_fd, "</IfModule>\n\n");
     // Disable multiviews ?
     if ($disable_multiviews) {
         fwrite($write_fd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
     }
     fwrite($write_fd, "RewriteEngine on\n");
     if (!$medias && defined('_MEDIA_SERVER_1_') && defined('_MEDIA_SERVER_2_') && defined('_MEDIA_SERVER_3_')) {
         $medias = array(_MEDIA_SERVER_1_, _MEDIA_SERVER_2_, _MEDIA_SERVER_3_);
     }
     $media_domains = '';
     if ($medias[0] != '') {
         $media_domains = 'RewriteCond %{HTTP_HOST} ^' . $medias[0] . '$ [OR]' . "\n";
     }
     if ($medias[1] != '') {
         $media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[1] . '$ [OR]' . "\n";
     }
     if ($medias[2] != '') {
         $media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[2] . '$ [OR]' . "\n";
     }
     if (Configuration::get('PS_WEBSERVICE_CGI_HOST')) {
         fwrite($write_fd, "RewriteCond %{HTTP:Authorization} ^(.*)\nRewriteRule . - [E=HTTP_AUTHORIZATION:%1]\n\n");
     }
     foreach ($domains as $domain => $list_uri) {
         $physicals = array();
         foreach ($list_uri as $uri) {
             fwrite($write_fd, PHP_EOL . PHP_EOL . '#Domain: ' . $domain . PHP_EOL);
             if (Shop::isFeatureActive()) {
                 fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^' . $domain . '$' . "\n");
             }
             fwrite($write_fd, 'RewriteRule . - [E=REWRITEBASE:' . $uri['physical'] . ']' . "\n");
             // Webservice
             fwrite($write_fd, 'RewriteRule ^api$ api/ [L]' . "\n\n");
             fwrite($write_fd, 'RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]' . "\n\n");
             if (!$rewrite_settings) {
                 $rewrite_settings = (int) Configuration::get('PS_REWRITING_SETTINGS', null, null, (int) $uri['id_shop']);
             }
             $domain_rewrite_cond = 'RewriteCond %{HTTP_HOST} ^' . $domain . '$' . "\n";
             // Rewrite virtual multishop uri
             if ($uri['virtual']) {
                 if (!$rewrite_settings) {
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^' . trim($uri['virtual'], '/') . '/?$ ' . $uri['physical'] . $uri['virtual'] . "index.php [L,R]\n");
                 } else {
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^' . trim($uri['virtual'], '/') . '$ ' . $uri['physical'] . $uri['virtual'] . " [L,R]\n");
                 }
                 fwrite($write_fd, $media_domains);
                 if (Shop::isFeatureActive()) {
                     fwrite($write_fd, $domain_rewrite_cond);
                 }
                 fwrite($write_fd, 'RewriteRule ^' . ltrim($uri['virtual'], '/') . '(.*) ' . $uri['physical'] . "\$1 [L]\n\n");
             }
             if ($rewrite_settings) {
                 // Compatibility with the old image filesystem
                 fwrite($write_fd, "# Images\n");
                 if (Configuration::get('PS_LEGACY_IMAGES')) {
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^([a-z0-9]+)\\-([a-z0-9]+)(\\-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3$4.jpg [L]' . "\n");
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^([0-9]+)\\-([0-9]+)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3.jpg [L]' . "\n");
                 }
                 // Rewrite product images < 100 millions
                 for ($i = 1; $i <= 8; $i++) {
                     $img_path = $img_name = '';
                     for ($j = 1; $j <= $i; $j++) {
                         $img_path .= '$' . $j . '/';
                         $img_name .= '$' . $j;
                     }
                     $img_name .= '$' . $j;
                     fwrite($write_fd, $media_domains);
                     if (Shop::isFeatureActive()) {
                         fwrite($write_fd, $domain_rewrite_cond);
                     }
                     fwrite($write_fd, 'RewriteRule ^' . str_repeat('([0-9])', $i) . '(\\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/p/' . $img_path . $img_name . '$' . ($j + 1) . ".jpg [L]\n");
                 }
                 fwrite($write_fd, $media_domains);
                 if (Shop::isFeatureActive()) {
                     fwrite($write_fd, $domain_rewrite_cond);
                 }
                 fwrite($write_fd, 'RewriteRule ^c/([0-9]+)(\\-[\\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]' . "\n");
                 fwrite($write_fd, $media_domains);
                 if (Shop::isFeatureActive()) {
                     fwrite($write_fd, $domain_rewrite_cond);
                 }
                 fwrite($write_fd, 'RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]' . "\n");
             }
             fwrite($write_fd, "# AlphaImageLoader for IE and fancybox\n");
             if (Shop::isFeatureActive()) {
                 fwrite($write_fd, $domain_rewrite_cond);
             }
             fwrite($write_fd, 'RewriteRule ^images_ie/?([^/]+)\\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]' . "\n");
         }
         // Redirections to dispatcher
         if ($rewrite_settings) {
             fwrite($write_fd, "\n# Dispatcher\n");
             fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} -s [OR]\n");
             fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} -l [OR]\n");
             fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} -d\n");
             if (Shop::isFeatureActive()) {
                 fwrite($write_fd, $domain_rewrite_cond);
             }
             fwrite($write_fd, "RewriteRule ^.*\$ - [NC,L]\n");
             if (Shop::isFeatureActive()) {
                 fwrite($write_fd, $domain_rewrite_cond);
             }
             fwrite($write_fd, "RewriteRule ^.*\$ %{ENV:REWRITEBASE}index.php [NC,L]\n");
         }
     }
     fwrite($write_fd, "</IfModule>\n\n");
     fwrite($write_fd, "AddType application/vnd.ms-fontobject .eot\n");
     fwrite($write_fd, "AddType font/ttf .ttf\n");
     fwrite($write_fd, "AddType font/otf .otf\n");
     fwrite($write_fd, "AddType application/x-font-woff .woff\n");
     fwrite($write_fd, "<IfModule mod_headers.c>\r\n\t<FilesMatch \"\\.(ttf|ttc|otf|eot|woff|svg)\$\">\r\n\t\tHeader add Access-Control-Allow-Origin \"*\"\r\n\t</FilesMatch>\r\n</IfModule>\n\n");
     // Cache control
     if ($cache_control) {
         $cache_control = "<IfModule mod_expires.c>\r\n\tExpiresActive On\r\n\tExpiresByType image/gif \"access plus 1 month\"\r\n\tExpiresByType image/jpeg \"access plus 1 month\"\r\n\tExpiresByType image/png \"access plus 1 month\"\r\n\tExpiresByType text/css \"access plus 1 week\"\r\n\tExpiresByType text/javascript \"access plus 1 week\"\r\n\tExpiresByType application/javascript \"access plus 1 week\"\r\n\tExpiresByType application/x-javascript \"access plus 1 week\"\r\n\tExpiresByType image/x-icon \"access plus 1 year\"\r\n\tExpiresByType image/svg+xml \"access plus 1 year\"\r\n\tExpiresByType image/vnd.microsoft.icon \"access plus 1 year\"\r\n\tExpiresByType application/font-woff \"access plus 1 year\"\r\n\tExpiresByType application/x-font-woff \"access plus 1 year\"\r\n\tExpiresByType application/vnd.ms-fontobject \"access plus 1 year\"\r\n\tExpiresByType font/opentype \"access plus 1 year\"\r\n\tExpiresByType font/ttf \"access plus 1 year\"\r\n\tExpiresByType font/otf \"access plus 1 year\"\r\n\tExpiresByType application/x-font-ttf \"access plus 1 year\"\r\n\tExpiresByType application/x-font-otf \"access plus 1 year\"\r\n</IfModule>\r\n\r\n<IfModule mod_headers.c>\r\n\tHeader unset Etag\r\n</IfModule>\r\nFileETag none\r\n<IfModule mod_deflate.c>\r\n\t<IfModule mod_filter.c>\r\n\t\tAddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript font/ttf application/x-font-ttf font/otf application/x-font-otf font/opentype\r\n\t</IfModule>\r\n</IfModule>\n\n";
         fwrite($write_fd, $cache_control);
     }
     // In case the user hasn't rewrite mod enabled
     fwrite($write_fd, "#If rewrite mod isn't enabled\n");
     // Do not remove ($domains is already iterated upper)
     reset($domains);
     $domain = current($domains);
     fwrite($write_fd, 'ErrorDocument 404 ' . $domain[0]['physical'] . "index.php?controller=404\n\n");
     fwrite($write_fd, "# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again");
     if ($specific_after) {
         fwrite($write_fd, "\n\n" . trim($specific_after));
     }
     fclose($write_fd);
     if (!defined('PS_INSTALLATION_IN_PROGRESS')) {
         Hook::exec('actionHtaccessCreate');
     }
     return true;
 }
Esempio n. 7
0
    private function _displayForm()
    {
        $values = isset($_POST) && isset($_POST['submitPsblog']) ? Tools::getValue('pref') : array_merge(self::$default_values, self::getPreferences());
        $this->_html .= '
		
		<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
		<fieldset>
		<legend>' . $this->l('General') . '</legend>
			
		
		<label>' . $this->l('Active categories') . '</label>  
		<div class="margin-form">
		<input type="checkbox" name="pref[category_active]" value="1" ' . (isset($values['category_active']) && $values['category_active'] == '1' ? 'checked' : '') . ' />
		</div>
		<div class="clear"></div>
		
		<label>' . $this->l('Active products') . '</label>  
		<div class="margin-form">
		<input type="checkbox" name="pref[product_active]" value="1" ' . (isset($values['product_active']) && $values['product_active'] == '1' ? 'checked' : '') . ' />
		</div>
		<div class="clear"></div>
		
		<label>' . $this->l('Active comments') . '</label>  
		<div class="margin-form">
		<input type="checkbox" name="pref[comment_active]" value="1" ' . (isset($values['comment_active']) && $values['comment_active'] == '1' ? 'checked' : '') . ' />
		</div>
		<div class="clear"></div>
		
		<label>' . $this->l('Enable related articles') . '</label>  
		<div class="margin-form">
		<input type="checkbox" name="pref[related_active]" value="1" ' . (isset($values['related_active']) && $values['related_active'] == '1' ? 'checked' : '') . ' />
		</div>';
        $this->_html .= '
			</fieldset>
			<br /><div class="clear"></div>';
        $this->_html .= '<fieldset>
                <legend>' . $this->l('List settings') . '</legend>

                <label>' . $this->l('Number of articles per page') . '</label> 
                <div class="margin-form">
                <input type="text" name="pref[list_limit_page]" value="' . $values['list_limit_page'] . '" size="3" />
                </div><div class="clear"></div><br />

                <label>' . $this->l('Display date') . '</label>  
                <div class="margin-form">
                <input type="checkbox" name="pref[list_display_date]" value="1" ' . (isset($values['list_display_date']) && $values['list_display_date'] == '1' ? 'checked' : '') . '/>
                </div><div class="clear"></div><br />

                <label>' . $this->l('Image width in lists') . '</label>
                <div class="margin-form">
                        <input type="text" name="pref[img_list_width]" value="' . $values['img_list_width'] . '" size="3" /> px
                </div>';
        $this->_html .= '</fieldset><br /><div class="clear"></div>';
        $this->_html .= '<fieldset>
				
                                <legend>' . $this->l('View settings') . '</legend>
		
				<label>' . $this->l('Image width in article detail') . '</label>
				<div class="margin-form">
					<input type="text" name="pref[img_width]" value="' . $values['img_width'] . '" size="3" /> px
				</div><div class="clear"></div><br />
				
				<label>' . $this->l('Enable popin for images') . '</label>  
					<div class="margin-form">
					<input type="checkbox" name="pref[view_display_popin]" value="1" ' . (isset($values['view_display_popin']) && $values['view_display_popin'] == '1' ? 'checked' : '') . '/>
				</div>
				
				<div class="clear"></div><br />
				
				<label>' . $this->l('Display date') . '</label>  
				<div class="margin-form">
				<input type="checkbox" name="pref[view_display_date]" value="1" ' . (isset($values['view_display_date']) && $values['view_display_date'] == '1' ? 'checked' : '') . '/>
				</div>
				
				<div class="clear"></div><br />';
        $this->_html .= '<label>' . $this->l('Active Addthis') . '</label>  
				<div class="margin-form">
					<input type="checkbox" name="pref[share_active]" value="1" ' . (isset($values['share_active']) && $values['share_active'] == '1' ? 'checked' : '') . ' />
				</div>
				
				</fieldset>
				<div class="clear"></div><br />';
        $this->_html .= '<fieldset>
                                <legend>' . $this->l('Related products settings') . '</legend>
				
                                <label>' . $this->l('Enable related articles in product page') . '</label>  
                                <div class="margin-form">
                                <input type="checkbox" name="pref[product_page_related]" value="1" ' . (isset($values['product_page_related']) && $values['product_page_related'] == '1' ? 'checked' : '') . '/>
                                </div><div class="clear"></div><br />';
        $formats = ImageType::getImagesTypes();
        $this->_html .= '<label>' . $this->l('Product image format') . '</label>  
                                  <div class="margin-form">
                                      <select name="pref[product_img_format]">';
        foreach ($formats as $f) {
            $this->_html .= '<option value="' . $f['name'] . '" ' . ($values['product_img_format'] == $f['name'] ? "selected" : "") . '>' . $f['name'] . ' &nbsp;</option>';
        }
        $this->_html .= '</select>
                                 </div>';
        $this->_html .= '</fieldset><div class="clear"></div><br />';
        $this->_html .= '<fieldset>
                                        
                                <legend>' . $this->l('Comments settings') . '</legend>

                                <label>' . $this->l('All comments must be validated by an employee') . '</label>  
                                <div class="margin-form">
                                <input type="checkbox" name="pref[comment_moderate]" value="1" ' . (isset($values['comment_moderate']) && $values['comment_moderate'] == '1' ? 'checked' : '') . '/>
                                </div>

                                <div class="clear"></div><br />

                                <label>' . $this->l('Allow guest comments') . '</label>  
                                <div class="margin-form">
                                <input type="checkbox" name="pref[comment_guest]" value="1" ' . (isset($values['comment_guest']) && $values['comment_guest'] == '1' ? 'checked' : '') . '/>
                                </div>

                                <div class="clear"></div><br />

                                <label>' . $this->l('Minimum time between 2 comments from the same user') . '</label>
                                <div class="margin-form">
                                        <input name="pref[comment_min_time]" type="text" class="text" value="' . $values['comment_min_time'] . '" style="width: 40px; text-align: right;" /> ' . $this->l('seconds') . '
                                </div>

                                <div class="clear"></div><br />

                                <label>' . $this->l('Minimum length of user name') . '</label>
                                <div class="margin-form">
                                        <input name="pref[comment_name_min_length]" type="text" class="text" value="' . $values['comment_name_min_length'] . '" style="width: 40px; text-align: right;" /> ' . $this->l('characters') . '
                                </div>';
        $this->_html .= '</fieldset>';
        $this->_html .= '<div class="clear"></div><br />';
        $this->_html .= '<fieldset>
                            
                            <legend>' . $this->l('RSS settings') . '</legend>

                            <label>' . $this->l('Enable RSS feed') . '</label>  
                            <div class="margin-form">
                            <input type="checkbox" name="pref[rss_active]" value="1" ' . (isset($values['rss_active']) && $values['rss_active'] == '1' ? 'checked' : '') . '/>
                            </div>

                            <div class="clear"></div><br />

                            <label>' . $this->l('Post field used for content') . '</label> 
                            <div class="margin-form">
                                    <select name="pref[rss_display]">
                                            <option value="excerpt" ' . ($values['rss_display'] == "excerpt" ? "selected" : "") . '>' . $this->l('Excerpt') . ' &nbsp;</option>
                                            <option value="content" ' . ($values['rss_display'] == "content" ? "selected" : "") . '>' . $this->l('Content') . ' &nbsp;</option>
                                    </select>
                            </div>';
        $this->_html .= '</fieldset><div class="clear"></div><br />';
        $this->_html .= '<div class="clear"></div>
		
                    <input class="button" name="submitPsblog" value="' . $this->l('Update settings') . '" type="submit" />';
        $this->_html .= '<div class="clear"></div><br /><br />';
        $this->_html .= '<fieldset>
                            
                                <legend>' . $this->l('Tools') . '</legend>
                                
                                 <p>
                                 <input class="button" name="submitGenerateImg" value="' . $this->l('Regenerate all blog images') . '" type="submit" />
                                 &nbsp; ' . $this->l('Useful if you change the images sizes') . '
                                 </p>';
        if (self::isInstalled('gsitemap')) {
            $this->_html .= '<p>
                                        <input class="button" name="submitGenerateSitemap" value="' . $this->l('Regenerate Google sitemap') . '" type="submit" /> 
                                            &nbsp; <a href="' . _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/psblog/sitemap-blog.xml" target="_blank">' . _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/psblog/sitemap-blog.xml</a> ' . '
                                    </p>';
        }
        $this->_html .= '<div class="multishop_info">
                            <p>
                            ' . $this->l('If url rewriting doesn\'t works, check that this above lines exist in your current .htaccess file, if no, add it manually on top of your .htaccess file') . ': <br /><br />

                                  <strong>';
        $physical_uri = array();
        foreach (ShopUrl::getShopUrls() as $shop_url) {
            if (in_array($shop_url->physical_uri, $physical_uri)) {
                continue;
            }
            $this->_html .= "RewriteRule ^(.*)blog\$ " . $shop_url->physical_uri . "index.php?fc=module&module=psblog&controller=posts [QSA,L] <br />";
            $this->_html .= "RewriteRule ^(.*)blog/([0-9]+)\\-([a-zA-Z0-9-]*) " . $shop_url->physical_uri . "index.php?fc=module&module=psblog&controller=posts&post=\$2 [QSA,L] <br />";
            $this->_html .= "RewriteRule ^(.*)blog/category/([0-9]+)\\-([a-zA-Z0-9-]*) " . $shop_url->physical_uri . "index.php?fc=module&module=psblog&controller=posts&category=\$2 [QSA,L] <br />";
            $physical_uri[] = $shop_url->physical_uri;
        }
        $this->_html .= '</strong>
                                </p>
                              </div>';
        $this->_html .= '<div class="multishop_info">
                            <p>
                            ' . $this->l('To declare blog sitemap xml, add this line at the end of your robots.txt file') . ': <br /><br />

                                  <strong>
                                    Sitemap ' . _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/psblog/sitemap-blog.xml
                                 </strong>
                            </p>
                </div>';
        $this->_html .= '</fieldset>
                    						
		</form>';
    }
 public function __construct()
 {
     $this->table = 'meta';
     $this->className = 'Meta';
     $this->bootstrap = true;
     $this->identifier_name = 'page';
     $this->ht_file = _PS_ROOT_DIR_ . '/.htaccess';
     $this->rb_file = _PS_ROOT_DIR_ . '/robots.txt';
     $this->rb_data = $this->getRobotsContent();
     $this->explicitSelect = true;
     $this->addRowAction('edit');
     $this->addRowAction('delete');
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
     $this->fields_list = array('id_meta' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'page' => array('title' => $this->l('Page')), 'title' => array('title' => $this->l('Page title')), 'url_rewrite' => array('title' => $this->l('Friendly URL')));
     $this->_where = ' AND a.configurable = 1';
     $this->_group = 'GROUP BY a.id_meta';
     parent::__construct();
     $this->sm_file = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $this->context->shop->id . '_index_sitemap.xml';
     // Options to generate friendly urls
     $mod_rewrite = Tools::modRewriteActive();
     $general_fields = array('PS_REWRITING_SETTINGS' => array('title' => $this->l('Friendly URL'), 'hint' => $mod_rewrite ? $this->l('Enable this option only if your server allows URL rewriting (recommended).') : '', 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'desc' => !$mod_rewrite ? $this->l('URL rewriting (mod_rewrite) is not active on your server, or it is not possible to check your server configuration. If you want to use Friendly URLs, you must activate this mod.') : ''), 'PS_ALLOW_ACCENTED_CHARS_URL' => array('title' => $this->l('Accented URL'), 'hint' => $this->l('Enable this option if you want to allow accented characters in your friendly URLs.') . ' ' . $this->l('You should only activate this option if you are using non-latin characters ; for all the latin charsets, your SEO will be better without this option.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CANONICAL_REDIRECT' => array('title' => $this->l('Redirect to the canonical URL'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'select', 'list' => array(array('value' => 0, 'name' => $this->l('No redirection (you may have duplicate content issues)')), array('value' => 1, 'name' => $this->l('302 Moved Temporarily (recommended while setting up your store)')), array('value' => 2, 'name' => $this->l('301 Moved Permanently (recommended once you have gone live)'))), 'identifier' => 'value'));
     $url_description = '';
     if (!defined('_PS_HOST_MODE_')) {
         if ($this->checkConfiguration($this->ht_file)) {
             $general_fields['PS_HTACCESS_DISABLE_MULTIVIEWS'] = array('title' => $this->l('Disable Apache\'s MultiViews option'), 'hint' => $this->l('Enable this option only if you have problems with URL rewriting.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool');
             $general_fields['PS_HTACCESS_DISABLE_MODSEC'] = array('title' => $this->l('Disable Apache\'s mod_security module'), 'hint' => $this->l('Some of PrestaShop\'s features might not work correctly with a specific configuration of Apache\'s mod_security module. We recommend to turn it off.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool');
         } else {
             $url_description = $this->l('Before you can use this tool, you need to:');
             $url_description .= $this->l('1) Create a blank .htaccess file in your root directory.');
             $url_description .= $this->l('2) Give it write permissions (CHMOD 666 on Unix system).');
         }
     }
     // Options to generate robot.txt
     $robots_description = $this->l('Your robots.txt file MUST be in your website\'s root directory and nowhere else (e.g. http://www.example.com/robots.txt).');
     if ($this->checkConfiguration($this->rb_file)) {
         $robots_description .= $this->l('Generate your "robots.txt" file by clicking on the following button (this will erase the old robots.txt file)');
         $robots_submit = array('name' => 'submitRobots', 'title' => $this->l('Generate robots.txt file'));
     } else {
         $robots_description .= $this->l('Before you can use this tool, you need to:');
         $robots_description .= $this->l('1) Create a blank robots.txt file in your root directory.');
         $robots_description .= $this->l('2) Give it write permissions (CHMOD 666 on Unix system).');
     }
     $robots_options = array('title' => $this->l('Robots file generation'), 'description' => $robots_description);
     if (isset($robots_submit)) {
         $robots_options['submit'] = $robots_submit;
     }
     if (!defined('_PS_HOST_MODE_')) {
         // Options for shop URL if multishop is disabled
         $shop_url_options = array('title' => $this->l('Set shop URL'), 'fields' => array());
         if (!Shop::isFeatureActive()) {
             $this->url = ShopUrl::getShopUrls($this->context->shop->id)->where('main', '=', 1)->getFirst();
             if ($this->url) {
                 $shop_url_options['description'] = $this->l('Here you can set the URL for your shop. If you migrate your shop to a new URL, remember to change the values below.');
                 $shop_url_options['fields'] = array('domain' => array('title' => $this->l('Shop domain'), 'validation' => 'isString', 'type' => 'text', 'defaultValue' => $this->url->domain), 'domain_ssl' => array('title' => $this->l('SSL domain'), 'validation' => 'isString', 'type' => 'text', 'defaultValue' => $this->url->domain_ssl), 'uri' => array('title' => $this->l('Base URI'), 'validation' => 'isString', 'type' => 'text', 'defaultValue' => $this->url->physical_uri));
                 $shop_url_options['submit'] = array('title' => $this->l('Save'));
             }
         } else {
             $shop_url_options['description'] = $this->l('The multistore option is enabled. If you want to change the URL of your shop, you must go to the "Multistore" page under the "Advanced Parameters" menu.');
         }
     }
     // List of options
     $this->fields_options = array('general' => array('title' => $this->l('Set up URLs'), 'description' => $url_description, 'fields' => $general_fields, 'submit' => array('title' => $this->l('Save'))));
     if (!defined('_PS_HOST_MODE_')) {
         $this->fields_options['shop_url'] = $shop_url_options;
     } else {
         $this->fields_options['manage_domain_name'] = array('title' => $this->l('Manage domain name'), 'description' => $this->l('You can search for a new domain name or add a domain name that you already own. You will be redirected to your PrestaShop account.'), 'buttons' => array(array('title' => $this->l('Add a domain name'), 'href' => 'https://www.prestashop.com/cloud/', 'class' => 'pull-right', 'icon' => 'process-icon-new', 'js' => 'return !window.open(this.href);')));
     }
     // Add display route options to options form
     if (Configuration::get('PS_REWRITING_SETTINGS') || Tools::getValue('PS_REWRITING_SETTINGS')) {
         if (Configuration::get('PS_REWRITING_SETTINGS')) {
             $this->addAllRouteFields();
         }
         $this->fields_options['routes']['title'] = $this->l('Schema of URLs');
         $this->fields_options['routes']['description'] = $this->l('This section enables you to change the default pattern of your links. In order to use this functionality, PrestaShop\'s "Friendly URL" option must be enabled, and Apache\'s URL rewriting module (mod_rewrite) must be activated on your web server.') . '<br />' . $this->l('There are several available keywords for each route listed below; note that keywords with * are required!') . '<br />' . $this->l('To add a keyword in your URL, use the {keyword} syntax. If the keyword is not empty, you can add text before or after the keyword with syntax {prepend:keyword:append}. For example {-hey-:meta_title} will add "-hey-my-title" in the URL if the meta title is set.');
         $this->fields_options['routes']['submit'] = array('title' => $this->l('Save'));
     }
     $this->fields_options['robots'] = $robots_options;
 }
Esempio n. 9
0
 public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null, $medias = false)
 {
     if (defined('PS_INSTALLATION_IN_PROGRESS')) {
         return true;
     }
     // Default values for parameters
     if (is_null($path)) {
         $path = _PS_ROOT_DIR_ . '/.htaccess';
     }
     if (is_null($cache_control)) {
         $cache_control = (int) Configuration::get('PS_HTACCESS_CACHE_CONTROL');
     }
     if (is_null($disable_multiviews)) {
         $disable_multiviews = (int) Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
     }
     // Check current content of .htaccess and save all code outside of prestashop comments
     $specific_before = $specific_after = '';
     if (file_exists($path)) {
         $content = file_get_contents($path);
         if (preg_match('#^(.*)\\# ~~start~~.*\\# ~~end~~[^\\n]*(.*)$#s', $content, $m)) {
             $specific_before = $m[1];
             $specific_after = $m[2];
         } else {
             // For retrocompatibility
             if (preg_match('#\\# http://www\\.prestashop\\.com - http://www\\.prestashop\\.com/forums\\s*(.*)<IfModule mod_rewrite\\.c>#si', $content, $m)) {
                 $specific_before = $m[1];
             } else {
                 $specific_before = $content;
             }
         }
     }
     // Write .htaccess data
     if (!($write_fd = @fopen($path, 'w'))) {
         return false;
     }
     fwrite($write_fd, trim($specific_before) . "\n\n");
     $domains = array();
     foreach (ShopUrl::getShopUrls() as $shop_url) {
         if (!isset($domains[$shop_url->domain])) {
             $domains[$shop_url->domain] = array();
         }
         $domains[$shop_url->domain][] = array('physical' => $shop_url->physical_uri, 'virtual' => $shop_url->virtual_uri, 'id_shop' => $shop_url->id_shop);
     }
     // Write data in .htaccess file
     fwrite($write_fd, "# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again\n");
     fwrite($write_fd, "# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution\n");
     fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
     // RewriteEngine
     fwrite($write_fd, "<IfModule mod_rewrite.c>\n");
     // Disable multiviews ?
     if ($disable_multiviews) {
         fwrite($write_fd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
     }
     fwrite($write_fd, "RewriteEngine on\n");
     if (!$medias) {
         $medias = array(_MEDIA_SERVER_1_, _MEDIA_SERVER_2_, _MEDIA_SERVER_3_);
     }
     $media_domains = '';
     if ($medias[0] != '') {
         $media_domains = 'RewriteCond %{HTTP_HOST} ^' . $medias[0] . '$ [OR]' . "\n";
     }
     if ($medias[1] != '') {
         $media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[1] . '$ [OR]' . "\n";
     }
     if ($medias[2] != '') {
         $media_domains .= 'RewriteCond %{HTTP_HOST} ^' . $medias[2] . '$ [OR]' . "\n";
     }
     if (Configuration::get('PS_WEBSERVICE_CGI_HOST')) {
         fwrite($write_fd, "RewriteCond %{HTTP:Authorization} ^(.*)\nRewriteRule . - [E=HTTP_AUTHORIZATION:%1]\n\n");
     }
     foreach ($domains as $domain => $list_uri) {
         $physicals = array();
         foreach ($list_uri as $uri) {
             fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^' . $domain . '$' . "\n");
             fwrite($write_fd, 'RewriteRule . - [E=REWRITEBASE:' . $uri['physical'] . ']' . "\n");
             // Webservice
             fwrite($write_fd, 'RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]' . "\n\n");
             $rewrite_settings = (int) Configuration::get('PS_REWRITING_SETTINGS', null, null, (int) $uri['id_shop']);
             $domain_rewrite_cond = 'RewriteCond %{HTTP_HOST} ^' . $domain . '$' . "\n";
             // Rewrite virtual multishop uri
             if ($uri['virtual']) {
                 if (!$rewrite_settings) {
                     fwrite($write_fd, $media_domains);
                     fwrite($write_fd, $domain_rewrite_cond);
                     fwrite($write_fd, 'RewriteRule ^' . trim($uri['virtual'], '/') . '/?$ ' . $uri['physical'] . $uri['virtual'] . "index.php [L,R]\n");
                 } else {
                     fwrite($write_fd, $media_domains);
                     fwrite($write_fd, $domain_rewrite_cond);
                     fwrite($write_fd, 'RewriteRule ^' . trim($uri['virtual'], '/') . '$ ' . $uri['physical'] . $uri['virtual'] . " [L,R]\n");
                 }
                 fwrite($write_fd, $media_domains);
                 fwrite($write_fd, $domain_rewrite_cond);
                 fwrite($write_fd, 'RewriteRule ^' . ltrim($uri['virtual'], '/') . '(.*) ' . $uri['physical'] . "\$1 [L]\n\n");
             }
             if ($rewrite_settings) {
                 // Compatibility with the old image filesystem
                 fwrite($write_fd, "# Images\n");
                 if (Configuration::get('PS_LEGACY_IMAGES')) {
                     fwrite($write_fd, $media_domains);
                     fwrite($write_fd, $domain_rewrite_cond);
                     fwrite($write_fd, 'RewriteRule ^([a-z0-9]+)\\-([a-z0-9]+)(\\-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}' . _PS_PROD_IMG_ . '$1-$2$3$4.jpg [L]' . "\n");
                     fwrite($write_fd, $media_domains);
                     fwrite($write_fd, $domain_rewrite_cond);
                     fwrite($write_fd, 'RewriteRule ^([0-9]+)\\-([0-9]+)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}' . _PS_PROD_IMG_ . '$1-$2$3.jpg [L]' . "\n");
                 }
                 // Rewrite product images < 100 millions
                 for ($i = 1; $i <= 8; $i++) {
                     $img_path = $img_name = '';
                     for ($j = 1; $j <= $i; $j++) {
                         $img_path .= '$' . $j . '/';
                         $img_name .= '$' . $j;
                     }
                     $img_name .= '$' . $j;
                     fwrite($write_fd, $media_domains);
                     fwrite($write_fd, $domain_rewrite_cond);
                     fwrite($write_fd, 'RewriteRule ^' . str_repeat('([0-9])', $i) . '(\\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}' . _PS_PROD_IMG_ . $img_path . $img_name . '$' . ($j + 1) . ".jpg [L]\n");
                 }
                 fwrite($write_fd, $media_domains);
                 fwrite($write_fd, $domain_rewrite_cond);
                 fwrite($write_fd, 'RewriteRule ^c/([0-9]+)(\\-[\\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]' . "\n");
                 fwrite($write_fd, $media_domains);
                 fwrite($write_fd, $domain_rewrite_cond);
                 fwrite($write_fd, 'RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]' . "\n");
             }
         }
         // Redirections to dispatcher
         if ($rewrite_settings) {
             fwrite($write_fd, "\n# Dispatcher\n");
             fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} -s [OR]\n");
             fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} -l [OR]\n");
             fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} -d\n");
             fwrite($write_fd, $domain_rewrite_cond);
             fwrite($write_fd, "RewriteRule ^.*\$ - [NC,L]\n");
             fwrite($write_fd, $domain_rewrite_cond);
             fwrite($write_fd, "RewriteRule ^.*\$ %{ENV:REWRITEBASE}index.php [NC,L]\n");
         }
     }
     fwrite($write_fd, "</IfModule>\n\n");
     // Cache control
     if ($cache_control) {
         $cache_control = "<IfModule mod_expires.c>\n\tExpiresActive On\n\tExpiresByType image/gif \"access plus 1 month\"\n\tExpiresByType image/jpeg \"access plus 1 month\"\n\tExpiresByType image/png \"access plus 1 month\"\n\tExpiresByType text/css \"access plus 1 week\"\n\tExpiresByType text/javascript \"access plus 1 week\"\n\tExpiresByType application/javascript \"access plus 1 week\"\n\tExpiresByType application/x-javascript \"access plus 1 week\"\n\tExpiresByType image/x-icon \"access plus 1 year\"\n</IfModule>\n\nFileETag INode MTime Size\n<IfModule mod_deflate.c>\n\tAddOutputFilterByType DEFLATE text/html\n\tAddOutputFilterByType DEFLATE text/css\n\tAddOutputFilterByType DEFLATE text/javascript\n\tAddOutputFilterByType DEFLATE application/javascript\n\tAddOutputFilterByType DEFLATE application/x-javascript\n</IfModule>\n\n";
         fwrite($write_fd, $cache_control);
     }
     // In case the user hasn't rewrite mod enabled
     fwrite($write_fd, "#If rewrite mod isn't enabled\n");
     // Do not remove ($domains is already iterated upper)
     reset($domains);
     $domain = current($domains);
     fwrite($write_fd, 'ErrorDocument 404 ' . $domain[0]['physical'] . "index.php?controller=404\n\n");
     fwrite($write_fd, "# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again\n");
     fwrite($write_fd, "\n\n" . trim($specific_after));
     fclose($write_fd);
     Hook::exec('actionHtaccessCreate');
     return true;
 }
Esempio n. 10
0
 * needs please refer to http://www.prestashop.com for more information.
 *
 *  @author    PrestaShop SA <*****@*****.**>
 *  @copyright 2007-2015 PrestaShop SA
 *  @version  Release: $Revision: 14390 $
 *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */
// Workaround for redirection on init
$_POST['id_shop'] = 1;
require_once 'config/config.inc.php';
if (!defined('_PS_VERSION_')) {
    exit;
}
// First, we get the URL used to reach this page.
$domain = Tools::getHttpHost();
$old_domain = Configuration::get('PS_SHOP_DOMAIN');
if (version_compare(_PS_VERSION_, '1.5', '>=') && $domain != $old_domain && !Shop::isFeatureActive()) {
    $url = ShopUrl::getShopUrls(Configuration::get('PS_SHOP_DEFAULT'))->where('main', '=', 1)->getFirst();
    if ($url) {
        $url->domain = $domain;
        $url->domain_ssl = $domain;
        $url->save();
        // Then, we update the configuration table
        Configuration::updateValue('PS_SHOP_DOMAIN', $domain);
        Configuration::updateValue('PS_SHOP_DOMAIN_SSL', $domain);
    }
}
unlink(__FILE__);
Tools::redirect("index.php");
die;
Esempio n. 11
0
 public static function update_base_uri($uri)
 {
     $context = Context::getContext();
     $url = ShopUrl::getShopUrls($context->shop->id)->where('main', '=', 1)->getFirst();
     if ($url->physical_uri == $uri) {
         echo "Base uri is already {$uri}\n";
         return true;
     }
     $url->physical_uri = $uri;
     if ($url->update()) {
         echo "Successfully updated base URI\n";
         return true;
     } else {
         echo "Error, could not update base URI\n";
         return false;
     }
 }