"; print_r ($_SESSION); echo ""; */ error_reporting(0); /*error_reporting(E_ALL); ini_set("display_errors", 1); //ini_set("error_log", $errorPath); /**/ require_once('Connections/con_db.php'); require_once('config.php'); require_once('style/stylefunc.php'); include('classes/clsencrypt.php'); /* echo "
";
echo $_COOKIE['nwxUID'];
echo "
";

echo "
";
print_r($_POST);
echo "
";

echo "
";
print_r($_SESSION);
echo "
";
*/

//////// Security update

if(isset($_GET['q'])){ $q=intval($_GET['q']); }
if(isset($_GET['adcart'])){ $adcart=intval($_GET['adcart']); }
if(isset($_GET['elfam'])){ $elfam=intval($_GET['elfam']); }
if(isset($_GET['elprod'])){ $elprod=intval($_GET['elprod']); }
if(isset($_GET['remitem'])){ $remitem=intval($_GET['remitem']); }
if(isset($_GET['vcart'])){ $vcart=intval($_GET['vcart']); }
if(isset($_GET['mw'])){ $mw=intval($_GET['mw']); }
if(isset($_GET['mc'])){ $mc=intval($_GET['mc']); }
if(isset($_GET['cconta'])){ $cconta=intval($_GET['cconta']); }
if(isset($_GET['recpass'])){ $recpass=intval($_GET['recpass']); }
if(isset($_GET['ccontaalt'])){ $ccontaalt=intval($_GET['ccontaalt']); }
if(isset($_GET['clienteLogout'])){ $clienteLogout=intval($_GET['clienteLogout']); }

/////////////////////CLIENT LOGIN

function limitaString($word,$limit) {

   if (strlen($word) > $limit)
      $word = substr($word, 0, strrpos(substr($word, 0, $limit), ' ')) . '...';
      return $word;
}

if(isset($_COOKIE['nwxUID'])){
	$nwxUID = addslashes($_COOKIE['nwxUID']);	
	mysql_select_db($database_db, $db);
	$query_cookieUser = "SELECT * FROM td_clientes where cookie = '$nwxUID'";
	$cookieUser = mysql_query($query_cookieUser, $db);
	$row_cookieUser = mysql_fetch_assoc($cookieUser);	
	$ipCli = getenv("REMOTE_ADDR"); 
	if($row_cookieUser['id'] != null) {
		$_SESSION['clienteID'] = $row_cookieUser['id'];
		$_SESSION['clienteNome'] = $row_cookieUser['nome'];
		$_SESSION['secureCliHash'] = md5($row_cookieUser['nome'].$securePass.$ipCli);
		$query_updateLastLogin = "update td_clientes set lastlogin = NOW() where id = ".$row_cookieUser['id'];
		mysql_query($query_updateLastLogin, $db);
	}
}

if (isset($clienteLogout)) { 
$_SESSION = array();
session_destroy();
}

if(isset($_POST['uname']) and isset($_POST['pword'])) { 
	$uname = addslashes($_POST['uname']);
	$pword = md5($_POST['pword']);
	$lembrar = $_POST['lembrar'];
	mysql_select_db($database_db, $db);
	$query_checkUsr = "SELECT * FROM td_clientes where username = '$uname'";
	$checkUsr = mysql_query($query_checkUsr, $db);
	$row_checkUsr = mysql_fetch_assoc($checkUsr);
	if($row_checkUsr['id'] == NULL){ $erroLogin = "Utilizador Inválido"; }
	elseif($row_checkUsr['status'] == 1){ $erroLogin = "Conta ainda não activada"; }
	elseif($row_checkUsr['password'] == $pword){
		$_SESSION['clienteID'] = $row_checkUsr['id'];
		$_SESSION['clienteNome'] = $row_checkUsr['nome'];
		$_SESSION['secureCliHash'] = md5($row_checkUsr['nome'].$securePass.$ipCli);
		$query_updateLastLogin = "update td_clientes set lastlogin = NOW(), session ='".session_id()."', cookie = '".$_SESSION['secureCliHash']."' where id = ".$row_checkUsr['id'];
		mysql_query($query_updateLastLogin, $db);
		if($lembrar=="sim") { $defineCookie = $_SESSION['secureCliHash']; }
	} else {
		$erroLogin = "Password Inválida";
	}

} 

if(isset($defineCookie)) {
	setcookie("nwxUID", $defineCookie, time()+3600*24*30);////, "/", ".miguellouro.com"
	//echo "entrei";
	//echo $_COOKIE['nwxUID'];
}


//@extract($_GET);

//@extract($_POST);
if(isset($_GET['ctipo'])) { $ctipo = $_GET['ctipo']; }else { $ctipo = ""; }
$ctipo=intval($ctipo);
if(!isset($ctipo)) { $ctipo = ""; }

if(isset($logout)){ unset($_SESSION['iduser']); }

if(isset($_GET['tlang'])){
	 $_SESSION['langid']= (int)($_GET['tlang']); 
	}
include('admin/config_vars.php');
//require_once('funcs/functions.php'); 
	//echo strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
	$flang=explode("-",strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]));
	if(!isset($_SESSION['langid'])){
		mysql_select_db($database_db, $db);
		$query_idioma = "SELECT * FROM td_idiomas where code = '".$flang[0]."'";
		$idioma = mysql_query($query_idioma, $db);
		$row_idioma = mysql_fetch_assoc($idioma);		
		if($row_idioma['id'] == NULL) {
			mysql_select_db($database_db, $db);
			$query_cidioma = "SELECT * FROM td_conf where nomefunc = 'idioma'";
			$cidioma = mysql_query($query_cidioma, $db);
			$row_cidioma = mysql_fetch_assoc($cidioma);
			$_SESSION['langid'] = $row_cidioma['var'];
			}else{ $_SESSION['langid'] = $row_idioma['id']; } 
	}
		mysql_select_db($database_db, $db);
		$query_idioma2 = "SELECT * FROM td_idiomas where id = ".$_SESSION['langid'];
		$idioma2 = mysql_query($query_idioma2, $db);
		$row_idioma2 = mysql_fetch_assoc($idioma2);
//@extract($_SESSION);
	
require_once('lang/'.$row_idioma2['code'].'.php');
	
////////
mysql_select_db($database_db, $db);
$query_ctitulo = "SELECT * FROM td_conf where nomefunc = 'titulo' and idioma = ".$_SESSION['langid'];
$ctitulo = mysql_query($query_ctitulo, $db);
$row_ctitulo = mysql_fetch_assoc($ctitulo);	

mysql_select_db($database_db, $db);
$query_cdesc = "SELECT * FROM td_conf where nomefunc = 'descricao' and idioma = ".$_SESSION['langid'];
$cdesc = mysql_query($query_cdesc, $db);
$row_cdesc = mysql_fetch_assoc($cdesc);	

mysql_select_db($database_db, $db);
$query_ckeys = "SELECT * FROM td_conf where nomefunc = 'keywords' and idioma = ".$_SESSION['langid'];
$ckeys = mysql_query($query_ckeys, $db);
$row_ckeys = mysql_fetch_assoc($ckeys);	

include("siteFuncs.php");
//include_once('classes/thumb/thumbnail.inc.php');
//include('includes/base_funcs.php');

?>




 -