require_once "functions.php";
require_once "./back_office/Functions.php";
$input = explode("/",trim(str_replace('_',' ',urldecode($_GET['mr_str']))));
//$input[0] = iconv("UTF-8","WINDOWS-1255",$input[0]);
/*if ($input[0] == "page.php" || $input[0] == "products.php"){
switch($input[0]){
case "products.php" : if ($_GET['CategoryID'])
$que = "SELECT `CategoryTitle` FROM `Categories`
WHERE LangID = $_GET['LangID'] and `CategoryID` = ".intval($_GET['CategoryID']);
elseif (strlen($_GET['FreeText'])) {
include($input[0]);
exit;
}
break;
case "page.php" : if ($_GET['PageID'])
$que = "SELECT IFNULL(MainPages.MainTitle,Pages.PageTitle) as `sName` FROM `Pages` INNER JOIN `MainPages` USING(MainPageID) WHERE Pages.PageID = ".intval($_GET['PageID']);
break;
}
if ($que) {
$sql = mysql_query($que) or die(__LINE__.": ".mysql_error()."
".$que);
if (mysql_num_rows($sql)){
list($tit) = mysql_fetch_row($sql);
$tit = urlencode(str_replace(" ","_",$tit));
header("HTTP/1.1 301 Moved Permanently");
header("Location: /{$tit}/");
exit;
}
}
header("HTTP/1.0 404 Not Found");
exit;
}*/
$_GET['HeadName'] = $input[0];
/*$sql = "SELECT LangID FROM languages WHERE name='$input[0]'";
$res = mysql_query($sql) or die(mysql_error().$sql);
if(mysql_num_rows($res)){
$data = mysql_fetch_assoc($res);
$_GET['LangID'] = $data[LangID];
include("index.php");
exit;
}*/
$mrtmp = str_replace("'","'",urldecode($input[0]));
if (!strcmp(mb_substr($mrtmp,-5),".html"))
$mrtmp = mb_substr($mrtmp,0,-5);
if (strlen($mrtmp)) {
// PageLink
if (strpos($mrtmp," and ") !== false)
$cond = "(LOWER(Pages.PageLink) = '{$mrtmp}' OR LOWER(Pages.PageLink) = '".str_replace(" and "," & ",$mrtmp)."')";
else
$cond = "LOWER(Pages.PageLink) = '{$mrtmp}'";
$que = "SELECT Pages.PageID
FROM `Categories_menu` INNER JOIN `Pages` USING(`CategoryID`)
WHERE {$cond} AND Categories_menu.LangID = ".$_GET['LangID'];
$sql = mysql_query($que) or die(__FILE__.":".__LINE__." ".mysql_error()."
".$que);
if (mysql_num_rows($sql)){
$row = mysql_fetch_row($sql);
$_GET['PageID'] = $row[0];
include "page.php";
exit;
}
// CategoryTitle
if (strpos($mrtmp," and ") !== false)
$cond = "(LOWER(Categories_menu.CategoryTitle) = '{$mrtmp}' OR LOWER(Categories_menu.CategoryTitle) = '".str_replace(" and "," & ",$mrtmp)."')";
else
$cond = "LOWER(Categories_menu.CategoryTitle) = '{$mrtmp}'";
$que = "SELECT Pages.PageID
FROM `Categories_menu` INNER JOIN `Pages` USING(`CategoryID`)
WHERE {$cond} AND Categories_menu.LangID = ".$_GET['LangID'];
$sql = mysql_query($que) or die(__FILE__.":".__LINE__." ".mysql_error()."
".$que);
if (mysql_num_rows($sql)){
$row = mysql_fetch_row($sql);
$_GET['PageID'] = $row[0];
include "page.php";
exit;
}
}
header("Status: 404 Not Found");
?>