1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header('Cache-Control: no-store, no-cache, must-revalidate');
- header('Cache-Control: post-check=0, pre-check=0', false);
- header('Pragma: no-cache');
- require_once("./include/bd_pdo.php");//die on error
- require_once("./include/nusoap/nusoap.php");
- require_once("./include/util.php");
- define("COOKIE_N", "checador");
- //Valida usuario en windows, regresa falso con error, 1 si es aceptado, 0 si es rechazado
- function validaUsuario($user, $pass){
-
- $client = new nusoap_client('http://200.13.89.2/validacion.php?wsdl', 'wsdl');
- //$client = new nusoap_client('http://validacion.lci.ulsa.mx/validacion.php?wsdl', 'wsdl');#Azure
- $error = $client->getError();
- if ($error) {
- return false;
- }
- $pass = utf8_decode($pass);
- $result = $client->call("valida_user_addo", array($user, $pass));
- if ($client->fault) {
- return false;
- } else {
- $error = $client->getError();
- if ($error) {
- return false;
- } else {
- if($result) return 1;
- else return 0;
- }
- }
- }
- $auth = false;
- if (!isset($_COOKIE[COOKIE_N])){
- if(!empty($_POST["username"]) && !empty($_POST["passwd"])){
- //Existe usuario y contraseña
- $usr = trim(filter_input(INPUT_POST, "username"));//limpia texto
- $usr_db = limpiaClave($usr);
- $pass = $_POST["passwd"]; //trim(filter_input(INPUT_POST, "passwd"));//limpia texto
- $stmt = $pdo->prepare('Select * from fs_validaclaveulsa(:usr) AS "Usuario_id"');
- $stmt->bindParam(":usr", $usr_db);
- if(!$stmt->execute()){
- //print_r($stmt->errorInfo());
- header("Location: index.php?error=2");
- exit();
- }
- $usr_rs = $stmt->fetch();//Devuelve sólo 1 resultado
- $stmt->closeCursor(); // cierra conexion de resultado
- $stmt = null; // cierra conexion
- $usr_id = $usr_rs["Usuario_id"];
- if(!empty($usr_id)){//Si existe el usuario
- $valido = validaUsuario($usr, $pass);//false = error, 0 = sin permiso, 1 = con permiso
- if($valido === false){
- //$errorDesc = "El usuario/contraseña son incorrectos";
- header("Location: index.php?error=0");
- exit();
- }else if($valido === 1){
- $auth = true;
- setcookie(COOKIE_N, encripta($usr_id), strtotime('today 23:59'), "/");
- }else{
- //$errorDesc = "El usuario/contraseña son incorrectos";
- header("Location: index.php?error=0");
- exit();
- }
- }else{
- //$errorDesc = "El usuario no está registrado en el sistema";
- header("Location: index.php?error=1");
- exit();
- }
- }else{
- header("Location: index.php?error=0");
- exit();
- }
- }
- header("Location: index.php");
- ?>
|