2011-04-04 15:16:10 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
//si es necesario cambiar la config. del php.ini desde tu script
|
|
|
|
|
|
ini_set("session.use_only_cookies","1");
|
|
|
|
|
|
ini_set("session.use_trans_sid","0");
|
|
|
|
|
|
|
|
|
|
|
|
//iniciamos la sesi<73>n
|
|
|
|
|
|
session_name("loginUsuario");
|
|
|
|
|
|
include_once("Objects/Usuario.php");
|
|
|
|
|
|
include_once("Objects/ListaPedido.php");
|
|
|
|
|
|
include_once("Objects/Semaforo.php");
|
|
|
|
|
|
session_start();
|
|
|
|
|
|
//FICHERO DE IDIOMAS
|
|
|
|
|
|
define("LOCALE", "idiomas/");
|
|
|
|
|
|
define("LOCALESET", "sp/");
|
|
|
|
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
|
|
|
|
include_once("functions_util.php");
|
|
|
|
|
|
|
|
|
|
|
|
// Definimos seg<65>n el sistema operativo la barra para separar rutas
|
|
|
|
|
|
$path = dirname( __FILE__ );
|
|
|
|
|
|
$slash = "\\";
|
|
|
|
|
|
strpos( $path, $slash ) ? '' : $slash = '/';
|
|
|
|
|
|
define("SLASH",$slash );
|
|
|
|
|
|
|
|
|
|
|
|
//Evitamos ataques de sql injection
|
|
|
|
|
|
|
|
|
|
|
|
foreach($_POST as $key => $value){
|
|
|
|
|
|
if(gettype($value) != "array"){
|
|
|
|
|
|
$value = stripinput($value);
|
|
|
|
|
|
}
|
|
|
|
|
|
$_POST[$key] = $value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach($_GET as $key => $value){
|
|
|
|
|
|
if(gettype($value) != "array"){
|
|
|
|
|
|
$value = stripinput($value);
|
|
|
|
|
|
}
|
|
|
|
|
|
$_GET[$key] = $value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-04-06 12:06:00 +00:00
|
|
|
|
session_set_cookie_params(0, "/", $_SERVER["HTTP_HOST"], 0);
|
2011-04-04 15:16:10 +00:00
|
|
|
|
//cambiamos la duraci<63>n a la cookie de la sesi<73>n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//antes de hacer los c<>lculos, compruebo que el usuario est<73> logueado
|
|
|
|
|
|
//utilizamos el mismo script que antes
|
|
|
|
|
|
if ($_SESSION["autentificado"] != "SI") {
|
|
|
|
|
|
//si no est<73> logueado lo env<6E>o a la p<>gina de autentificaci<63>n
|
|
|
|
|
|
header("Location: index.php");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//sino, calculamos el tiempo transcurrido
|
|
|
|
|
|
$fechaGuardada = $_SESSION["ultimoAcceso"];
|
|
|
|
|
|
$duracion = $_SESSION["duracion"];
|
|
|
|
|
|
$usuario = $_SESSION["usuario"];
|
|
|
|
|
|
$idioma = $_SESSION["idioma"];
|
|
|
|
|
|
if($idioma != ""){
|
2011-04-06 12:06:00 +00:00
|
|
|
|
if (!defined("LOCALESET")) {
|
|
|
|
|
|
define("LOCALESET", "$idioma/");
|
|
|
|
|
|
}
|
2011-04-04 15:16:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
$ahora = date("Y-n-j H:i:s");
|
|
|
|
|
|
$tiempo_transcurrido = (strtotime($ahora)-strtotime($fechaGuardada));
|
|
|
|
|
|
$tiempo_transcurrido = $tiempo_transcurrido/60;
|
|
|
|
|
|
|
|
|
|
|
|
//comparamos el tiempo transcurrido
|
|
|
|
|
|
//----------IMPORTANTE A<>ADIR LA CONSTANTE AL SISTEMA---------------//
|
|
|
|
|
|
|
|
|
|
|
|
//echo "-------------------------------------------------- Transcurrido: $tiempo_transcurrido<br>";
|
|
|
|
|
|
//$restante = $duracion - $transcurrido;
|
|
|
|
|
|
//echo "-------------------------------------------------- Tiempo restante: $restante<br>";
|
|
|
|
|
|
//echo "-------------------------------------------------- Duraci<63>n: $duracion<br>";
|
|
|
|
|
|
if($tiempo_transcurrido >= $duracion) {
|
|
|
|
|
|
//si pas<61> el tiempo
|
|
|
|
|
|
session_destroy(); // destruyo la sesi<73>n
|
|
|
|
|
|
header("Location: index.php"); //env<6E>o al usuario a la pag. de autenticaci<63>n
|
|
|
|
|
|
//sino, actualizo la fecha de la sesi<73>n
|
|
|
|
|
|
}else {
|
|
|
|
|
|
$_SESSION["ultimoAcceso"] = $ahora;
|
|
|
|
|
|
}
|
|
|
|
|
|
// Sem<65>foros
|
|
|
|
|
|
$semaforo=new Semaforo($usuario,$locale);
|
|
|
|
|
|
try{
|
|
|
|
|
|
$semaforo->regular($_SERVER['REQUEST_URI']);
|
|
|
|
|
|
}catch (Exception $e){
|
|
|
|
|
|
header("Location: ".$e->getMessage());
|
|
|
|
|
|
exit();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
?>
|