<?php
if(!isset($_SESSION)) session_start();
include('clases/clase.conexion.php'); 
include('funciones/variables.php');
$VarCon = VarServer("MYSQLI");
$obj = new clsConexion($VarCon[0],$VarCon[1],$VarCon[2],$VarCon[3],$VarCon[4]);
$obj-> AbrirConexion();
$sql = "call spLogin_Usuario('$_POST[user]','$_POST[pass]', $_POST[sist]);";
$rs = $obj->Query($sql);
$obj->CerrarConexion();
if($row = $obj->FetchArray($rs))  {
   	$_SESSION["_CUSE"] = $row["CUSE"];
	$_SESSION["_NUSE"] = $row["USUARIO"];
	$_SESSION["_CTRA"] = $row["CTRA"];
	$_SESSION["_NTRA"] = $row["TRABAJADOR"];
	$_SESSION["_CSYS"] = $row["CSIS"];
	$_SESSION["_NSYS"] = $row["SISTEMA"];
	$_SESSION["_CABR"] = $row["ABREV"];
	$_SESSION["_SDIR"] = $row["DIRECTORIO"];
	$_SESSION["_SMEN"] = $row["MENU"];
	$_SESSION["_FINS"] = "S";
	$_SESSION["_FUPD"] = "S";
	$_SESSION["_FDEL"] = "S";
	$varDir = $row["DIRECTORIO"];
	echo "<script language='Javascript'>";
	echo "window.location='$varDir/index.php'";
	echo "</script>";
  }
else  {
   echo "<script language='Javascript'>";
   echo "Mensaje=\"Ud. No tiene Autorizacion Para Ingresar\\nVerifique los Datos por favor....\"\n";
   echo "alert(Mensaje);\n";
   echo "window.location='index.php'";
   echo "</script>\n";
  }  
?>