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"); ?>