public function init() { if (Tools::getValue('cms_rewrite')) { $rewrite_url = Tools::getValue('cms_rewrite'); $id_cms = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_cms` FROM `' . _DB_PREFIX_ . 'cms_lang` WHERE `link_rewrite` = \'' . $rewrite_url . '\''); if ($id_cms > 0) { $_GET['id_cms'] = $id_cms; //$_GET['noredirect'] = 1; } else { Tools::display404Error(); die; } } else { if (Tools::getValue('cms_category_rewrite')) { $rewrite_url = Tools::getValue('cms_category_rewrite'); $id_cms_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_cms_category` FROM `' . _DB_PREFIX_ . 'cms_category_lang` WHERE `link_rewrite` = \'' . $rewrite_url . '\''); if ($id_cms_category > 0) { $_GET['id_cms_category'] = $id_cms_category; //$_GET['noredirect'] = 1; } else { Tools::display404Error(); die; } } } parent::init(); }
public function displayPageForm() { if (!$this->active) { Tools::display404Error(); } include dirname(__FILE__) . '/../../header.php'; echo $this->displayFrontForm(); include dirname(__FILE__) . '/../../footer.php'; }
public function init() { if (Tools::getValue('cms_rewrite')) { $rewrite_url = Tools::getValue('cms_rewrite'); $id_cms = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_cms` FROM `' . _DB_PREFIX_ . 'cms_lang` WHERE `link_rewrite` = \'' . $rewrite_url . '\''); if ($id_cms > 0) { $_GET['id_cms'] = $id_cms; $_GET['noredirect'] = 1; } else { Tools::display404Error(); die; } } if ($id_cms = (int) Tools::getValue('id_cms')) { $this->cms = new CMS($id_cms, $this->context->language->id); } else { if ($id_cms_category = (int) Tools::getValue('id_cms_category')) { $this->cms_category = new CMSCategory($id_cms_category, $this->context->language->id); } } if (Configuration::get('PS_SSL_ENABLED') && Tools::getValue('content_only') && Tools::getValue('id_cms') == (int) Configuration::get('PS_CONDITIONS_CMS_ID') && Validate::isLoadedObject($this->cms)) { $this->ssl = true; } parent::init(); $this->canonicalRedirection(); // assignCase (1 = CMS page, 2 = CMS category) if (Validate::isLoadedObject($this->cms)) { $adtoken = Tools::getAdminToken('AdminCmsContent' . (int) Tab::getIdFromClassName('AdminCmsContent') . (int) Tools::getValue('id_employee')); if (!$this->cms->isAssociatedToShop() || !$this->cms->active && Tools::getValue('adtoken') != $adtoken) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); } else { $this->assignCase = 1; } } else { if (Validate::isLoadedObject($this->cms_category)) { $this->assignCase = 2; } else { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); } } }
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); } $this->canonicalRedirection(); 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::display404Error('404.php'); } }
public function init() { if (Tools::getValue('product_rewrite')) { $rewrite_url = Tools::getValue('product_rewrite'); $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product_lang` WHERE `link_rewrite` = \'' . $rewrite_url . '\''); if ($id_product > 0) { $_GET['id_product'] = $id_product; //$_GET['noredirect'] = 1; } else { Tools::display404Error(); die; } } parent::init(); }
public function init() { if (Tools::getValue('manufacturer_rewrite')) { $name_manufacturer = str_replace('-', '%', Tools::getValue('manufacturer_rewrite')); $id_manufacturer = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_manufacturer` FROM `' . _DB_PREFIX_ . 'manufacturer` WHERE `name` LIKE \'' . $name_manufacturer . '\''); if ($id_manufacturer > 0) { $_GET['id_manufacturer'] = $id_manufacturer; $_GET['noredirect'] = 1; } else { Tools::display404Error(); die; } } parent::init(); }
/** * Shows the 404 page to the user. */ protected function notFound() { if (_PS_VERSION_ < '1.5') { Tools::display404Error(); } else { Controller::getController('PageNotFoundController')->run(); } }
* NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7013 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/sendtoafriend.php'; $sendtoafriend = new sendToAFriend(); if (!$sendtoafriend->active) { Tools::display404Error(); } include dirname(__FILE__) . '/../../header.php'; echo $sendtoafriend->displayFrontForm(); include dirname(__FILE__) . '/../../footer.php';
/** * Initialize product controller * @see FrontController::init() */ public function init() { if (Tools::getValue('product_rewrite')) { $rewrite_url = Tools::getValue('product_rewrite'); $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product_lang` WHERE `link_rewrite` = \'' . $rewrite_url . '\''); if ($id_product > 0) { $_GET['id_product'] = $id_product; $_GET['noredirect'] = 1; } else { $redirect_url = str_replace('.html', '', $_SERVER['REQUEST_URI']); $redirect_type = Configuration::get('PS_CANONICAL_REDIRECT') == 2 ? '301' : '302'; header('HTTP/1.0 ' . $redirect_type . ' Moved'); header('Cache-Control: no-cache'); Tools::redirectLink('http://' . $_SERVER['HTTP_HOST'] . $redirect_url); Tools::display404Error(); die; } } parent::init(); if ($id_product = (int) Tools::getValue('id_product')) { $this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id); } if (!Validate::isLoadedObject($this->product)) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); $this->errors[] = Tools::displayError('Product not found'); } else { $this->canonicalRedirection(); /* * If the product is associated to the shop * and is active or not active but preview mode (need token + file_exists) * allow showing the product * In all the others cases => 404 "Product is no longer available" */ if (!$this->product->isAssociatedToShop() || !$this->product->active) { if (Tools::getValue('adtoken') == Tools::getAdminToken('AdminProducts' . (int) Tab::getIdFromClassName('AdminProducts') . (int) Tools::getValue('id_employee')) && $this->product->isAssociatedToShop()) { // If the product is not active, it's the admin preview mode $this->context->smarty->assign('adminActionDisplay', true); } else { $this->context->smarty->assign('adminActionDisplay', false); if ($this->product->id_product_redirected == $this->product->id) { $this->product->redirect_type = '404'; } switch ($this->product->redirect_type) { case '301': header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $this->context->link->getProductLink($this->product->id_product_redirected)); break; case '302': header('HTTP/1.1 302 Moved Temporarily'); header('Cache-Control: no-cache'); header('Location: ' . $this->context->link->getProductLink($this->product->id_product_redirected)); break; case '404': default: header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); $this->errors[] = Tools::displayError('This product is no longer available.'); break; } } } elseif (!$this->product->checkAccess(isset($this->context->customer) ? $this->context->customer->id : 0)) { header('HTTP/1.1 403 Forbidden'); header('Status: 403 Forbidden'); $this->errors[] = Tools::displayError('You do not have access to this product.'); } else { // Load category $id_category = false; if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] == Tools::secureReferrer($_SERVER['HTTP_REFERER']) && preg_match('~^.*(?<!\\/content)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_(category|product)=([0-9]+)(.*)$~', $_SERVER['HTTP_REFERER'], $regs)) { // If the previous page was a category and is a parent category of the product use this category as parent category $id_object = false; if (isset($regs[1]) && is_numeric($regs[1])) { $id_object = (int) $regs[1]; } elseif (isset($regs[5]) && is_numeric($regs[5])) { $id_object = (int) $regs[5]; } if ($id_object) { $referers = array($_SERVER['HTTP_REFERER'], urldecode($_SERVER['HTTP_REFERER'])); if (in_array($this->context->link->getCategoryLink($id_object), $referers)) { $id_category = (int) $id_object; } elseif (isset($this->context->cookie->last_visited_category) && (int) $this->context->cookie->last_visited_category && in_array($this->context->link->getProductLink($id_object), $referers)) { $id_category = (int) $this->context->cookie->last_visited_category; } } } if (!$id_category || !Category::inShopStatic($id_category, $this->context->shop) || !Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => $id_category)))) { $id_category = (int) $this->product->id_category_default; } if (Category::inDecor($id_category) && !$this->ajax && strpos($_SERVER['SERVER_NAME'], 'decor') <= -1) { $final_url = $this->context->link->getProductLink($this->product); $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); } $this->category = new Category((int) $id_category, (int) $this->context->cookie->id_lang); if (isset($this->context->cookie) && isset($this->category->id_category) && !(Module::isInstalled('blockcategories') && Module::isEnabled('blockcategories'))) { $this->context->cookie->last_visited_category = (int) $this->category->id_category; } } } }