getPath()); $uriHelper = new UriHelper($path->getContent()); $route_name = (isset($_REQUEST['route'])) ? trim($_REQUEST['route']) : false; if ($route_name) { try { // check if the route is category's name $oCategory = Category::getByRewriteURL($route_name); if (!is_null($oCategory)) { $_GET['categoryID'] = $oCategory->id; $_REQUEST['categoryID'] = $_GET['categoryID']; $_GET['cPath'] = $oCategory->id; $_REQUEST['cPath'] = $_GET['cPath']; $landingPage = new LandingPage($oCategory); $route = 'filter.php'; if ( $landingPage->categoryId > 0 && !isset($_GET['bypass_category_landing']) ) { $landingPage->category = $oCategory; $route = 'landing_page.php'; } } } catch (Exception $e) { error_log($e->getMessage()); tep_redirect('404.php?invalid=' . $route_name, 404); } // check if the route is product's name $product = Product::getByName($route_name, false, false); if (!is_null($product)) { if (isset($_SESSION['tag_obj'])) { unset($_SESSION['tag_obj']); } $_GET['products_id'] = $product->id; $_REQUEST['products_id'] = $product->id; $route = FILENAME_PRODUCT_INFO; } // check if the route is tag's name $product_tag = ProductTag::getByTagName($route_name); if (!is_null($product_tag)) { $_REQUEST['tag_obj'] = $product_tag; $route = 'filter.php'; } $db = new MySql(); $db->selectSimple( '', TABLE_URL_REDIRECTION, ['url' => $route_name] ); if ($_urlRedirection = $db->nextRecord()) { $redirection = ($_urlRedirection['redirection'] != '/') ? "{$_urlRedirection['redirection']}.html" : ''; $query = array_filter($_GET, function ($item, $key) { $localParams = ['route', 'products_id', 'categoryID', 'cPath']; return !in_array($key, $localParams); }, ARRAY_FILTER_USE_BOTH); if (!empty($query)) { $redirection .= '?' . http_build_query($query); } tep_redirect(ROOT_URL . $redirection, 301); } // check if the route is content page $db->selectSimple('content_name', TABLE_SITE_CONTENT, ['page' => $route_name]); $content_page = $db->nextRecord(); if (!empty($content_page)) { $route = 'content.php'; $_REQUEST['contentName'] = $content_page['content_name']; } // check if route is some other special page $special_pages = ['custom-company-online-stores']; if (rush_site() && in_array($route_name, $special_pages)) { $route = 'special_pages/' . str_replace('-', '_', $route_name) . '.php'; /* * Check if there's a customer group by this name. * Groups should follow the format "some-company-name" => "Some Company Name" */ $private_page = PrivateLandingPage::getByRoute($route_name); if ($private_page) { $route = 'private_landing_page.php'; } } } elseif (isset($_REQUEST['cPath']) && !empty($_REQUEST['cPath'])) { $cPath_parts = explode('_', $_REQUEST['cPath']); $_GET['categoryID'] = intval(array_pop($cPath_parts)); $_GET['cPath'] = $_GET['categoryID']; $_REQUEST['cPath'] = $_GET['categoryID']; $_REQUEST['categoryID'] = $_GET['categoryID']; $route = 'filter.php'; } elseif (isset($_REQUEST['products_id']) && !empty($_REQUEST['products_id'])) { $_GET['products_id'] = $product->id; $_REQUEST['products_id'] = $product->id; $route = FILENAME_PRODUCT_INFO; } if (!isset($route) || $route == false || !file_exists($route)) { $route = '404.php'; } $_SERVER['SCRIPT_NAME'] = str_replace('dispatcher.php', $route, $_SERVER['SCRIPT_NAME']); $_SERVER['SCRIPT_FILENAME'] = str_replace('dispatcher.php', $route, $_SERVER['SCRIPT_FILENAME']); require_once $route;