public function preProcess() { if ($id_category = (int) Tools::getValue('id_category')) { $this->category = new Category($id_category, self::$cookie->id_lang); } if (!Validate::isLoadedObject($this->category)) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); } else { // Automatically redirect to the canonical URL if the current in is the right one // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain $currentURL = self::$link->getCategoryLink($this->category); $currentURL = preg_replace('/[?&].*$/', '', $currentURL); if (!preg_match('/^' . Tools::pRegexp($currentURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $currentURL . '">' . $currentURL . '</a>'); } Tools::redirectLink($currentURL); } } parent::preProcess(); if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { if ($id_category = (int) Tools::getValue('id_category')) { $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category); $default_rewrite = array(); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = self::$link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']); } self::$smarty->assign('lang_rewrite_urls', $default_rewrite); } } }
public function canonicalRedirection() { // Automatically redirect to the canonical URL if the current in is the right one // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain if (Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') { if (Validate::isLoadedObject($this->cms) and $canonicalURL = self::$link->getCMSLink($this->cms)) { if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); header('Cache-Control: no-cache'); if (_PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>'); } Tools::redirectLink($canonicalURL); } } if (Validate::isLoadedObject($this->cms_category) and $canonicalURL = self::$link->getCMSCategoryLink($this->cms_category)) { if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); header('Cache-Control: no-cache'); if (_PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>'); } Tools::redirectLink($canonicalURL); } } } }
protected function canonicalRedirection() { global $link, $cookie; if (Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') { // Automatically redirect to the canonical URL if needed if (isset($this->php_self) && !empty($this->php_self)) { // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain $canonicalURL = $link->getPageLink($this->php_self, $this->ssl, $cookie->id_lang); if (!Tools::getValue('ajax') && !preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', ($this->ssl && _PS_SSL_ENABLED_ ? 'https://' : 'http://') . urldecode($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']))) { if ($_SERVER['REQUEST_URI'] == __PS_BASE_URI__) { header('HTTP/1.0 303 See Other'); header('Cache-Control: no-cache'); } else { header('HTTP/1.0 301 Moved Permanently'); header('Cache-Control: no-cache'); } $params = ''; $excludedKey = array('isolang', 'id_lang'); foreach ($_GET as $key => $value) { if (!in_array($key, $excludedKey)) { $params .= ($params == '' ? '?' : '&') . $key . '=' . $value; } } Module::hookExec('frontCanonicalRedirect'); if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . $params . '">' . $canonicalURL . $params . '</a>'); } Tools::redirectLink($canonicalURL . $params); } } } }
public function canonicalRedirection() { if (Validate::isLoadedObject($this->manufacturer) && Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') { $canonicalURL = self::$link->getManufacturerLink($this->manufacturer); if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>'); } Tools::redirectLink($canonicalURL); } } }
public function canonicalRedirection() { // Automatically redirect to the canonical URL if the current in is the right one // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain if (Validate::isLoadedObject($this->product) && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') { $canonicalURL = self::$link->getProductLink($this->product); if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>'); } Tools::redirectLink($canonicalURL); } } }
public function preProcess() { if ($id_cms = (int) Tools::getValue('id_cms')) { $this->cms = new CMS($id_cms, self::$cookie->id_lang); } elseif ($id_cms_category = (int) Tools::getValue('id_cms_category')) { $this->cms_category = new CMSCategory($id_cms_category, self::$cookie->id_lang); } // Automatically redirect to the canonical URL if the current in is the right one // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain if ($this->cms and $canonicalURL = self::$link->getCMSLink($this->cms)) { if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); if (defined(_PS_MODE_DEV_) and _PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>'); } Tools::redirectLink($canonicalURL); } } if ($this->cms_category and $canonicalURL = self::$link->getCMSCategoryLink($this->cms_category)) { if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); if (_PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>'); } Tools::redirectLink($canonicalURL); } } parent::preProcess(); /* assignCase (1 = CMS page, 2 = CMS category) */ if (Validate::isLoadedObject($this->cms) and ($this->cms->active or Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS' . $this->cms->id) and file_exists(dirname(__FILE__) . '/../' . Tools::getValue('ad') . '/ajax.php'))) { $this->assignCase = 1; } elseif (Validate::isLoadedObject($this->cms_category)) { $this->assignCase = 2; } else { Tools::redirect('404.php'); } if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { $rewrite_infos = (isset($id_cms) and !isset($id_cms_category)) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category); $default_rewrite = array(); foreach ($rewrite_infos as $infos) { $arr_link = (isset($id_cms) and !isset($id_cms_category)) ? self::$link->getCMSLink($id_cms, $infos['link_rewrite'], $this->ssl, $infos['id_lang']) : self::$link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']); $default_rewrite[$infos['id_lang']] = $arr_link; } self::$smarty->assign('lang_rewrite_urls', $default_rewrite); } }
protected function canonicalRedirection($canonical_url = '') { if (!$canonical_url || !Configuration::get('PS_CANONICAL_REDIRECT') || strtoupper($_SERVER['REQUEST_METHOD']) != 'GET' || Tools::getValue('live_edit')) { return; } $match_url = rawurldecode(Tools::getCurrentUrlProtocolPrefix() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); if (!preg_match('/^' . Tools::pRegexp(rawurldecode($canonical_url), '/') . '([&?].*)?$/', $match_url)) { $params = array(); $str_params = ''; $url_details = parse_url($canonical_url); if (!empty($url_details['query'])) { parse_str($url_details['query'], $query); foreach ($query as $key => $value) { $params[Tools::safeOutput($key)] = Tools::safeOutput($value); } } $excluded_key = array('isolang', 'id_lang', 'controller', 'fc', 'id_product', 'id_category', 'id_manufacturer', 'id_supplier', 'id_cms'); foreach ($_GET as $key => $value) { if (!in_array($key, $excluded_key) && Validate::isUrl($key) && Validate::isUrl($value)) { $params[Tools::safeOutput($key)] = Tools::safeOutput($value); } } $str_params = http_build_query($params, '', '&'); if (!empty($str_params)) { $final_url = preg_replace('/^([^?]*)?.*$/', '$1', $canonical_url) . '?' . $str_params; } else { $final_url = preg_replace('/^([^?]*)?.*$/', '$1', $canonical_url); } // Don't send any cookie Context::getContext()->cookie->disallowWriting(); if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $final_url . '">' . $final_url . '</a>'); } $redirect_type = Configuration::get('PS_CANONICAL_REDIRECT') == 2 ? '301' : '302'; header('HTTP/1.0 ' . $redirect_type . ' Moved'); header('Cache-Control: no-cache'); Tools::redirectLink($final_url); } }
public function preProcess() { if ((int) Tools::getValue('pp') == 1) { $intime = time(); echo 'intime: ' . $intime; } if ($id_product = (int) Tools::getValue('id_product')) { $this->product = new Product($id_product, true, self::$cookie->id_lang); //if((int)Tools::getValue('pp') == 1){ // print_r($this->product->getPrice(false, null, 2)); //} $id_product = (int) Tools::getValue('id_product'); $productsViewed = (isset(self::$cookie->viewed) and !empty(self::$cookie->viewed)) ? array_slice(explode(',', self::$cookie->viewed), 0, 12) : array(); if (sizeof($productsViewed)) { if ($id_product and !in_array($id_product, $productsViewed)) { array_unshift($productsViewed, $id_product); } } else { $productsViewed[] = $id_product; } self::$cookie->viewed = implode(',', $productsViewed); } if (!Validate::isLoadedObject($this->product)) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); } else { // Automatically redirect to the canonical URL if the current in is the right one // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain if (Validate::isLoadedObject($this->product)) { $canonicalURL = self::$link->getProductLink($this->product); if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) && !Tools::getValue('adtoken')) { header('HTTP/1.0 301 Moved'); if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . '">' . $canonicalURL . '</a>'); } Tools::redirectLink($canonicalURL); } } } parent::preProcess(); if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { if ($id_product = (int) Tools::getValue('id_product')) { $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product); $default_rewrite = array(); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = self::$link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']); } self::$smarty->assign('lang_rewrite_urls', $default_rewrite); } } //get categories $categories = $this->product->getCategories(); if (in_array(CAT_SAREE, $categories)) { if (in_array(CAT_BOLLYWOOD_SAREE, $categories)) { self::$smarty->assign('bollywood', true); } $this->is_saree = true; } else { if (in_array(CAT_SKD, $categories)) { if (in_array(CAT_BOLLYWOOD_SKD, $categories)) { self::$smarty->assign('bollywood', true); } if ($this->product->is_rts) { $this->is_skd_rts = true; if (in_array(CAT_PAKISTANI_SKD, $categories)) { $this->is_pakistani_rts = true; } if ($this->product->has_bottom) { $this->has_bottom = true; } } else { $this->is_skd = true; } } else { if (in_array(CAT_KURTI, $categories)) { //replace 4 with constant from defines later if ($this->product->is_rts) { $this->is_skd_rts = true; } else { $this->is_skd = true; } if ($this->product->has_bottom) { $this->has_bottom = true; } } else { if (in_array(CAT_LEHENGA, $categories)) { if (in_array(CAT_BOLLYWOOD_LEHENGA, $categories)) { self::$smarty->assign('bollywood', true); } $this->is_lehenga = true; } else { if (in_array(CAT_GIFTCARD, $categories)) { $this->is_giftcard = true; } else { if (in_array(CAT_JEWELRY, $categories)) { $this->is_jewelry = true; } else { if (in_array(CAT_KIDS, $categories)) { $this->is_kids = true; } else { if (in_array(CAT_MEN, $categories)) { $this->is_men = true; } } } } } } } } if (in_array(CAT_ANARKALI, $categories)) { $this->is_anarkali = true; } if (in_array(CAT_BOTTOMS, $categories)) { $this->is_bottoms = true; } if (in_array(CAT_CHOLIS, $categories)) { $this->is_cholis = true; } if (in_array(CAT_ABAYA, $categories)) { $this->is_abaya = true; } if (in_array(CAT_HANDBAG, $categories)) { $this->is_handbag = true; } if (in_array(465, $categories)) { $this->is_wristwear = true; } if ((int) Tools::getValue('pp') == 1) { $time1 = time(); echo 'preprocess end: ' . $time1; } }
protected function canonicalRedirection() { global $link, $cookie; if (Configuration::get('PS_CANONICAL_REDIRECT')) { // Automatically redirect to the canonical URL if needed if (isset($this->php_self) and !empty($this->php_self)) { // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain $canonicalURL = $link->getPageLink($this->php_self, $this->ssl, $cookie->id_lang); if (!preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', (($this->ssl and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); $params = ''; $excludedKey = array('isolang', 'id_lang'); foreach ($_GET as $key => $value) { if (!in_array($key, $excludedKey)) { $params .= ($params == '' ? '?' : '&') . $key . '=' . $value; } } if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_ and $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . $params . '">' . $canonicalURL . $params . '</a>'); } Tools::redirectLink($canonicalURL . $params); } } } }
* @since 22/May/2007 * */ require_once '../../config/config.inc.php'; require_once '../init.php'; if (!isset($manager)) { /** * this is part of script for processing file paste */ //$_GET = $_POST; include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php"; include_once CLASS_PAGINATION; $pagination = new pagination(false); if (!empty($_GET['search'])) { include_once CLASS_SEARCH; if (!preg_match('/^' . Tools::pRegexp(realpath(dirname(__FILE__) . '/' . $_GET['search_folder']), '/') . '/i', _PS_ROOT_DIR_ . '/img/cms')) { exit; } $search = new Search($_GET['search_folder']); $search->addSearchKeyword('recursive', @$_GET['search_recursively']); $search->addSearchKeyword('mtime_from', @$_GET['search_mtime_from']); $search->addSearchKeyword('mtime_to', @$_GET['search_mtime_to']); $search->addSearchKeyword('size_from', @$_GET['search_size_from']); $search->addSearchKeyword('size_to', @$_GET['search_size_to']); $search->addSearchKeyword('recursive', @$_GET['search_recursively']); $search->addSearchKeyword('name', @$_GET['search_name']); $search->doSearch(); $fileList = $search->getFoundFiles(); $folderInfo = $search->getRootFolderInfo(); } else { include_once CLASS_MANAGER;
public function preProcess() { if ($id_category = (int) Tools::getValue('id_category')) { $this->productSort(); if ($this->category->id != 1) { $brand_id = Tools::getValue('brand'); $this->category = new Category($id_category, self::$cookie->id_lang); $nbProducts = 0; $this->n = (int) Configuration::get('PS_PRODUCTS_PER_PAGE'); $this->p = abs((int) Tools::getValue('p', 1)); try { global $cart, $cookie; $id_country = (int) Country::getDefaultCountryId(); if ($cart->id_address_delivery) { $address = new Address($cart->id_address_delivery); if ($address->id_country) { $id_country = $address->id_country; } elseif (isset($cookie->id_country)) { $id_country = (int) $cookie->id_country; } } self::$smarty->assign('price_tax_country', $id_country); $products = SolrSearch::getCategoryProducts($id_category, $brand_id, $nbProducts); } catch (Exception $e) { self::$smarty->assign('fetch_error', 1); } $this->pagination((int) $nbProducts); self::$smarty->assign('nb_products', (int) $nbProducts); $this->cat_page_products = $products; } } if (!Validate::isLoadedObject($this->category)) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); } else { // Automatically redirect to the canonical URL if the current in is the right one // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain $currentURL = self::$link->getCategoryLink($this->category); $currentURL = preg_replace('/[?&].*$/', '', $currentURL); if (!preg_match('/^' . Tools::pRegexp($currentURL, '/') . '([&?].*)?$/', Tools::getProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) { header('HTTP/1.0 301 Moved'); if (defined('_PS_MODE_DEV_') and _PS_MODE_DEV_) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $currentURL . '">' . $currentURL . '</a>'); } Tools::redirectLink($currentURL); } } parent::preProcess(); if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { if ($id_category = (int) Tools::getValue('id_category')) { $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category); $default_rewrite = array(); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = self::$link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']); } self::$smarty->assign('lang_rewrite_urls', $default_rewrite); } } }