extract($_POST); if ($username == '' || $password == '') { header('Location: login.php'); } $usuario = $usuario_controller->login($username, sha1($password)); //$usuario = $usuario_controller->login( $username , $password ); if (isset($remember)) { setcookie("login", $username, time() + 60 * 60 * 24 * 365); setcookie("pass", $password, time() + 60 * 60 * 24 * 365); } else { $expire = time() - 300; setcookie("login", '', $expire); setcookie("pass", '', $expire); } if (REQUIERE_CONFIGURACION_INICIAL) { $sistema_configurado = $standar_controller->sistema_configurado(); if (!is_null($usuario) && $sistema_configurado == 'INSTALADO') { $array = array('id' => $usuario->id, 'nombre' => $usuario->nombre, 'apellidos' => $usuario->apellidos, 'token' => $usuario->token); $_SESSION['usuario'] = $array; header('Location: index.php'); exit; } else { if (!is_null($usuario) && $sistema_configurado == 'NO_INSTALADO') { $array = array('id' => $usuario->id, 'nombre' => $usuario->nombre, 'apellidos' => $usuario->apellidos, 'token' => $usuario->token); $_SESSION['usuario'] = $array; header('Location: configuracion.php?configurado=no'); } else { if (!is_null($usuario) && $sistema_configurado == 'PENDIENTE') { $array = array('id' => $usuario->id, 'nombre' => $usuario->nombre, 'apellidos' => $usuario->apellidos, 'token' => $usuario->token); $_SESSION['usuario'] = $array; header('Location: configuracion.php?configurado=pendiente');
<?php session_start(); require_once '../config.php'; require_once RUTA_CONTROLLERS . '/Usuario_controller.php'; require_once RUTA_CONTROLLERS . '/Standar_controller.php'; $usuario_controller = new Usuario_controller(); $standar_controller = new Standar_controller(); if (isset($_SESSION['usuario'])) { $id = $_SESSION['usuario']['id']; $usuario_logueado = $usuario_controller->esta_logeado($id); $configurado = $standar_controller->sistema_configurado() != 'INSTALADO' ? false : true; } else { $usuario_logueado = NULL; $configurado = false; } // hay que comprobar que aparte de que este logueado tenga el sistema configurado sino es asi aunque escriba // en la url index.php sino tiene el sistema configurado hay que redireccionarlo a configuracion.php //var_dump($usuario_logueado); if (is_null($usuario_logueado)) { header('Location: login.php'); } //else if( !is_null( $usuario_logueado ) && !$configurado ) { // // header( 'Location: configuracion.php?configurado=no' ); //}