//error_reporting(E_ALL & ~E_NOTICE);
//die(print_r($_REQUEST, true));
$pos=strpos($_REQUEST['lang'],".php");
if($pos!==false) { $_REQUEST['lang']=str_replace(".php", "", $_REQUEST['lang']); }
if(isset($_REQUEST['op2'])&&$_REQUEST['op2']==$_REQUEST['op'])unset($_REQUEST['op2']);
if(isset($_REQUEST['op3'])&&$_REQUEST['op3']==$_REQUEST['op2'])unset($_REQUEST['op3']);
//PARCHAZO ALFREDO
header('Content-Type: text/html; charset=utf-8');
require_once("config.inc.7.php");
$direct = 200;
$aTLDList = ['es', 'fr', 'pt', 'uk', 'de', 'it'];
$sDomain = $_SERVER['SERVER_NAME'];
$reMatch = '/^.*?\.(' . str_replace('.', '\.', implode('|', $aTLDList)) . ')$/';
$sMatchedTLD = preg_match($reMatch, $sDomain) ?
preg_replace($reMatch, "$1", $sDomain) :
"";
if($sMatchedTLD!="") {
$r = @mysqli_query($conn, "SELECT * FROM GFR_paises WHERE pai_cadena LIKE '" . mysqli_real_escape_string($conn, trim($sMatchedTLD)) . "' AND pai_status = 1");
if ($r && mysqli_num_rows($r) == 1) {
$PAISF = mysqli_fetch_assoc($r);
}else{
//world si el país está desactivado
$PAIS = 13;
$r = @mysqli_query($conn, "SELECT * FROM GFR_paises WHERE pai_id = '" . mysqli_real_escape_string($conn, trim($PAIS)) . "' AND pai_status = 1");
if ($r && mysqli_num_rows($r) == 1) {
$PAISF = mysqli_fetch_assoc($r);
}
$_SESSION["pais"] = $PAISF;
header("Location:https://www.frecan.com");
}
$_SESSION["pais"] = $PAISF;
//R20: idioma per pais només 1
//if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'es')) header("Location:https://www.frecan.es");
/*if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'fr')) header("Location:https://www.frecan.es");
if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'pt')) header("Location:https://www.frecan.es");
if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'de')) header("Location:https://www.frecan.es");
if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'it')) header("Location:https://www.frecan.es");
if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'en')) header("Location:https://www.frecan.es");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'es')) header("Location:https://www.frecan.fr");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'en')) header("Location:https://www.frecan.fr");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'it')) header("Location:https://www.frecan.fr");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'de')) header("Location:https://www.frecan.fr");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'pt')) header("Location:https://www.frecan.fr");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'es')) header("Location:https://www.frecan.pt");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'en')) header("Location:https://www.frecan.pt");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'it')) header("Location:https://www.frecan.pt");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'de')) header("Location:https://www.frecan.pt");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'fr')) header("Location:https://www.frecan.pt");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'es')) header("Location:https://www.frecan.co.uk");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'fr')) header("Location:https://www.frecan.co.uk");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'it')) header("Location:https://www.frecan.co.uk");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'de')) header("Location:https://www.frecan.co.uk");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'pt')) header("Location:https://www.frecan.co.uk");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'es')) header("Location:https://www.frecan.de");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'fr')) header("Location:https://www.frecan.de");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'it')) header("Location:https://www.frecan.de");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'en')) header("Location:https://www.frecan.de");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'pt')) header("Location:https://www.frecan.de");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'es')) header("Location:https://www.frecan.it");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'fr')) header("Location:https://www.frecan.it");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'de')) header("Location:https://www.frecan.it");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'en')) header("Location:https://www.frecan.it");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'pt')) header("Location:https://www.frecan.it");*/
if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'fr')) header("Location:/not_found.php");
if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'pt')) header("Location:/not_found.php");
if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'de')) header("Location:/not_found.php");
if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'it')) header("Location:/not_found.php");
if(($sMatchedTLD == "es") && ($_REQUEST['lang'] == 'en')) header("Location:/not_found.php");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'es')) header("Location:/not_found.php");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'en')) header("Location:/not_found.php");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'it')) header("Location:/not_found.php");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'de')) header("Location:/not_found.php");
if(($sMatchedTLD == "fr") && ($_REQUEST['lang'] == 'pt')) header("Location:/not_found.php");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'es')) header("Location:/not_found.php");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'en')) header("Location:/not_found.php");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'it')) header("Location:/not_found.php");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'de')) header("Location:/not_found.php");
if(($sMatchedTLD == "pt") && ($_REQUEST['lang'] == 'fr')) header("Location:/not_found.php");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'es')) header("Location:/not_found.php");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'fr')) header("Location:/not_found.php");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'it')) header("Location:/not_found.php");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'de')) header("Location:/not_found.php");
if(($sMatchedTLD == "co.uk") && ($_REQUEST['lang'] == 'pt')) header("Location:/not_found.php");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'es')) header("Location:/not_found.php");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'fr')) header("Location:/not_found.php");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'it')) header("Location:/not_found.php");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'en')) header("Location:/not_found.php");
if(($sMatchedTLD == "de") && ($_REQUEST['lang'] == 'pt')) header("Location:/not_found.php");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'es')) header("Location:/not_found.php");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'fr')) header("Location:/not_found.php");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'de')) header("Location:/not_found.php");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'en')) header("Location:/not_found.php");
if(($sMatchedTLD == "it") && ($_REQUEST['lang'] == 'pt')) header("Location:/not_found.php");
} else {
//world
$PAIS = 13;
$r = @mysqli_query($conn, "SELECT * FROM GFR_paises WHERE pai_id = '" . mysqli_real_escape_string($conn, trim($PAIS)) . "' AND pai_status = 1");
if ($r && mysqli_num_rows($r) == 1) {
$PAISF = mysqli_fetch_assoc($r);
}
$_SESSION["pais"] = $PAISF;
}
$PAIS = $_SESSION["pais"]["pai_id"];
/*
// frecan.com
// frecan.com/en/
// frecan.com/campanas/
if(isset($_REQUEST['lang'])) {
echo $_REQUEST['lang'];
echo '-';
}
// frecan.com/en/campanas
// frecan.com/campanas/nueva
if(isset($_REQUEST['op'])) {
echo $_REQUEST['op'];echo '-';
}
// frecan.com/en/campanas/nueva
if(isset($_REQUEST['op2'])) {
echo $_REQUEST['op2'];echo '-';
}
// frecan.com/en/fregaderos/luxury/design-lab
if(isset($_REQUEST['op3'])) {
echo $_REQUEST['op3'];echo '-';
}
// frecan.com/en/fregaderos/luxury/design-lab/m90
if(isset($_REQUEST['op4'])) {
echo $_REQUEST['op4'];
}
*/
//RUBEN16: paràmetres de més
if(isset($_REQUEST['op5'])) {
header("Location:/not_found.php");
}
if($_REQUEST['lang'] == 'blog') header("Location:/blog/");
if($_REQUEST['op'] == 'blog') header("Location:/blog/"); //frecan.es/en/blog
//echo '
';
// R20: hem de parar idiomes fora del domini .es/fr
$lang_idioma = 0; //RUBEN16: lang no està en la URL
$idiomes = Get_Idiomes();
$l = $_SESSION["pais"]["pai_lang"]; //RUBEN16: llenguatge per defecte en el país, definit a la taula
$sql = mysqli_query($conn, "SELECT * FROM GFR_langs l WHERE lng_activar = 'S' AND lng_codi = '$l' ORDER BY lng_orden");
$sql2=mysqli_fetch_array($sql);
$_SESSION['lng'] = $sql2["lng_codi"];
$lng = $_SESSION['lng'];
if(isset($_REQUEST['lang'])){
$sql = mysqli_query($conn, "SELECT * FROM GFR_langs l WHERE lng_activar = 'S' ORDER BY lng_orden");
while($sql2=mysqli_fetch_array($sql)){
if ($_REQUEST['lang'] == $sql2["lng_contenttype"]){
$lng = $sql2["lng_codi"];
$_SESSION['lng'] = $lng;
$lang_idioma = 1;
break;
}
}
}
//RUBEN16: paràmetres de més
if((isset($_REQUEST['op4']))&&($lang_idioma==0)) {
header("Location:/not_found.php");
}
$ct = $idiomes[$lng]['lng_contenttype']; //echo $lang_idioma;
function str_replace_first($from, $to, $subject) {
$from = '/'.preg_quote($from, '/').'/';
return preg_replace($from, $to, $subject, 1);
}
function tradueix_url_ori($URL, $idioma_from, $idioma_to, $lang_idioma) {
global $conn;
// campanas
$URL = substr($URL, 1); //RUBEN16: pq faig aixó? revisar si cal comprobar el darrer caracter de la URL
$param = '';
if($lang_idioma == 1) {
$URL = substr($URL, 3);
}
$parts = explode("/", $URL);
foreach($parts as $part) {
//level 1
$q = "SELECT * FROM GFR_menus WHERE URL_".$idioma_from."_menu = '".$part."'";
$sql = mysqli_query($conn, $q);
if($rs = mysqli_fetch_assoc($sql)) {
$new_url .= "/".$rs['URL_'.$idioma_to.'_menu'];
} else {
$q1 = "SELECT * FROM GFR_traduccions WHERE tra_valor LIKE '".$part."' AND tra_idioma = '".$idioma_from."' AND tra_camp = 'url_seo' ORDER BY tra_id ASC";
$sql1 = mysqli_query($conn, $q1);
if($rs1 = mysqli_fetch_assoc($sql1)) {
$q2 = "SELECT * FROM GFR_traduccions WHERE tra_idioma = '".$idioma_to."' AND tra_camp = 'url_seo' AND tra_taula = '".$rs1['tra_taula']."' AND tra_id = '".$rs1['tra_id']."' ORDER BY tra_id ASC";
$sql2 = mysqli_query($conn, $q2);
if($rs2 = mysqli_fetch_assoc($sql2)) {
$new_url .= "/".$rs2['tra_valor'];
}
} else {
$param = '/'.$part;
}
}
}
return $new_url.$param;
}
function tradueix_url($URL, $idioma_from, $idioma_to, $lang_idioma, $pais_dest = 0, $producte = 0, $subtipo = 0) {
global $conn;
if($producte > 0) {
$q1 = "SELECT * FROM GFR_paises_modelos WHERE pam_modelo = '".$producte."' AND pam_pais=".$pais_dest;
$sql1 = mysqli_query($conn, $q1);
if($rs1 = mysqli_fetch_assoc($sql1)) {
} else {
//return '/';
return 'NA'; //RUBEN17
}
}
if($subtipo > 0) {
$q1 = "SELECT * FROM GFR_paises_stmodelos WHERE pas_stmodelo = '".$subtipo."' AND pas_pais=".$pais_dest;
$sql1 = mysqli_query($conn, $q1);
if($rs1 = mysqli_fetch_assoc($sql1)) {
} else {
//return '/';
return 'NA';//RUBEN17
}
}
$URL = substr($URL, 1); //RUBEN16: pq faig aixó? revisar si cal comprobar el darrer caracter de la URL
$param = '';
if($lang_idioma == 1) {
$URL = substr($URL, 3);
}
$parts = explode("/", $URL);
$level = 0;
foreach($parts as $part) {
$level++;
$q = "SELECT * FROM GFR_menus WHERE URL_".$idioma_from."_menu = '".$part."'";
$q = "SELECT * FROM GFR_menus m, GFR_paises_menu p WHERE URL_".$idioma_from."_menu = '".$part."' AND m.id_menu = p.id_menu AND pais_menu = ".$pais_dest; //RUBEN17
$sql = mysqli_query($conn, $q);
if($rs = mysqli_fetch_assoc($sql)) {
$new_url .= "/".$rs['URL_'.$idioma_to.'_menu'];
} else {
$q1 = "SELECT * FROM GFR_traduccions WHERE tra_valor LIKE '".$part."' AND tra_idioma = '".$idioma_from."' AND tra_camp = 'url_seo' ORDER BY tra_id ASC";
$sql1 = mysqli_query($conn, $q1);
if($rs1 = mysqli_fetch_assoc($sql1)) {
$q2 = "SELECT * FROM GFR_traduccions WHERE tra_idioma = '".$idioma_to."' AND tra_camp = 'url_seo' AND tra_taula = '".$rs1['tra_taula']."' AND tra_id = '".$rs1['tra_id']."' ORDER BY tra_id ASC";
$sql2 = mysqli_query($conn, $q2);
if($rs2 = mysqli_fetch_assoc($sql2)) {
$new_url .= "/".$rs2['tra_valor'];
}
} elseif ($level == 4) {
$new_url .= "/".$part;
} else {
//$param = '/'.$part;
return 'NA';//RUBEN17
}
}
}
return $new_url.$param;
}
function tradueix_url2($URL, $idioma_from, $idioma_to, $lang_idioma, $pais_dest = 0, $producte = 0, $subtipo = 0) {
global $conn;
if($producte > 0) {
$q1 = "SELECT * FROM GFR_paises_modelos WHERE pam_modelo = '".$producte."' AND pam_pais=".$pais_dest;
$sql1 = mysqli_query($conn, $q1);
if($rs1 = mysqli_fetch_assoc($sql1)) {
} else {
return '/';
}
}
if($subtipo > 0) {
$q1 = "SELECT * FROM GFR_paises_stmodelos WHERE pas_stmodelo = '".$subtipo."' AND pas_pais=".$pais_dest;
$sql1 = mysqli_query($conn, $q1);
if($rs1 = mysqli_fetch_assoc($sql1)) {
} else {
return '/';
}
}
$URL = substr($URL, 1); //RUBEN16: pq faig aixó? revisar si cal comprobar el darrer caracter de la URL
$param = '';
if($lang_idioma == 1) {
$URL = substr($URL, 3);
}
$parts = explode("/", $URL);
$level = 0;
foreach($parts as $part) {
$level++;
$q = "SELECT * FROM GFR_menus WHERE URL_".$idioma_from."_menu = '".$part."'";
//$q = "SELECT * FROM GFR_menus m, GFR_paises_menu p WHERE URL_".$idioma_from."_menu = '".$part."' AND m.id_menu = p.id_menu AND pais_menu = ".$pais_dest; //RUBEN17
$sql = mysqli_query($conn, $q);
if($rs = mysqli_fetch_assoc($sql)) {
$new_url .= "/".$rs['URL_'.$idioma_to.'_menu'];
} else {
$q1 = "SELECT * FROM GFR_traduccions WHERE tra_valor LIKE '".$part."' AND tra_idioma = '".$idioma_from."' AND tra_camp = 'url_seo' ORDER BY tra_id ASC";
$sql1 = mysqli_query($conn, $q1);
if($rs1 = mysqli_fetch_assoc($sql1)) {
$q2 = "SELECT * FROM GFR_traduccions WHERE tra_idioma = '".$idioma_to."' AND tra_camp = 'url_seo' AND tra_taula = '".$rs1['tra_taula']."' AND tra_id = '".$rs1['tra_id']."' ORDER BY tra_id ASC";
$sql2 = mysqli_query($conn, $q2);
if($rs2 = mysqli_fetch_assoc($sql2)) {
$new_url .= "/".$rs2['tra_valor'];
}
} elseif ($level == 4) {
$new_url .= "/".$part;
} else {
$param = '/'.$part;
}
}
}
return $new_url.$param;
}
if (strlen($lng) > 1 )
require($RUTA . "lang_" . $lng . ".inc.php");
else
require($RUTA . "lang_eng.inc.php");
$GENS = Get_Text($lng, "GENERAL");
$TXT = Get_Text($lng, "TXT");
//RUBEN16: això no va aquí
$CAP_TITOL_WEB = stripslashes($GENS["TITOL_WEB"]);
$CAP_DESCR_WEB = stripslashes($GENS["DESCR_WEB"]);
$CAP_KEY_WEB = stripslashes($GENS["KEYWORDS_WEB"]);
$CAP_TITOL_WEB .= ' - '.$MENU0;
//RUBEN16: crec que només és de l'index
//$extra_css .= " \n";
$extra .= " \n";
$nav = "".$MENU0."";
//echo $_SERVER['REQUEST_URI'];
//echo tradueix_url($_SERVER['REQUEST_URI'], $lng, "eng", $lang_idioma);
include('router7.php');