$session_life) { $_SESSION = array(); session_destroy(); $pag = $_SERVER['SERVER_NAME']."/salir.php?expired=1"; header("Location: http://".$pag); exit(); } }else{ $_SESSION = array(); session_destroy(); $pag = $_SERVER['SERVER_NAME']."/salir.php?expired=1"; header("Location: http://".$pag); exit(); } $_SESSION["timeout"] = time(); $pag="../apsa/main.php"; if(isset($_POST["nombre"], $_POST["apellidos"], $_POST["cambio"]) && isset($_POST["contactos"], $_POST["curp"], $_POST["contactos"], $_POST["emergencia"]) && trim($_POST["nombre"]) != "" && trim($_POST["apellidos"]) != ""){ $nombre = trim(filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto $apellidos = trim(filter_input(INPUT_POST, "apellidos", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto $grado = trim(filter_input(INPUT_POST, "grado", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto $id = $_SESSION["usuario_id"]; $cambio = filter_input(INPUT_POST, "cambio", FILTER_SANITIZE_NUMBER_INT);//limpia texto $curp = mb_strtoupper(trim(filter_input(INPUT_POST, "curp", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $rfc = mb_strtoupper(trim(filter_input(INPUT_POST, "rfc", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $dir = trim(filter_input(INPUT_POST, "direccion", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto try{ $pdo->beginTransaction(); if($cambio == 1) $stmt = $pdo->prepare('Select * from fi_checkusuario(:id, true, :grado, :nom, :apell, :curp, :rfc, :dir)'); else $stmt = $pdo->prepare('Select * from fi_checkusuario(:id, false, :grado, :nom, :apell, :curp, :rfc, :dir)'); $stmt->bindParam(":id", $id); $stmt->bindParam(":grado", $grado); $stmt->bindParam(":nom", $nombre); $stmt->bindParam(":apell", $apellidos); $stmt->bindParam(":curp", $curp); $stmt->bindParam(":rfc", $rfc); $stmt->bindParam(":dir", $dir); if(!$stmt->execute()){ $pdo->rollBack(); header("Location: ".$pag."?error=1"); exit(); } $hasLasalle = false; $hasLasallistas = false; $error = false; $contactoObj = json_decode($_POST["contactos"], true); foreach($contactoObj as $contacto){ $stmt = $pdo->prepare('Select * from fd_checkcontacto(:id, :num)'); $stmt->bindParam(":id", $id); $stmt->bindParam(":num", $contacto["num"]); $stmt->execute(); if(!empty($contacto["contacto_valor"])){ $query = ":id, :num, "; if(!empty($contacto["contacto_id"])){ $query .= ":contacto_id, "; }else{ $query .= "NULL,"; } $query .= ":contacto,"; $query .= ":perfil, :tipo, "; if(!empty($contacto["subtipo"])){ $query .= ":subtipo"; }else{ $query .= "NULL"; } //echo $query."
"; $stmt = $pdo->prepare('Select * from fi_checkcontacto('.$query.')'); if(!empty($contacto["contacto_id"])){ $stmt->bindParam(":contacto_id", $contacto["contacto_id"]); } if(!empty($contacto["subtipo"])){ $stmt->bindParam(":subtipo", $contacto["subtipo"]); } $stmt->bindParam(":id", $id); $stmt->bindParam(":num", $contacto["num"]); $stmt->bindParam(":contacto", $contacto["contacto_valor"]); $stmt->bindParam(":perfil", $contacto["perfil"]); $stmt->bindParam(":tipo", $contacto["tipo"]); if(!$stmt->execute()){ $error=true; } } } $emergenciaObj = json_decode($_POST["emergencia"], true); //echo $emergenciaObj; //echo "

".!$error." ".!empty($emergenciaObj["emergencia_nombre"])."

"; if(!$error && !empty($emergenciaObj["emergencia_nombre"])){ $stmt = $pdo->prepare('Select * from fi_checkemergencia(:id, :nom, :tel)'); $stmt->bindParam(":id", $id); $stmt->bindParam(":nom", $emergenciaObj["emergencia_nombre"]); $stmt->bindParam(":tel", $emergenciaObj["emergencia_tel"]); if(!$stmt->execute()){ $error=true; } } if(!$error){ $pdo->commit(); }else{ $pdo->rollBack(); //header("Location: ".$pag."?error=4"); echo "else"; print_r($e); exit(); } } catch(PDOException $e) { $pdo->rollBack(); //header("Location:".$pag."?error=4"); print_r($e); exit(); } }else{ header("Location: ".$pag."?error=3"); exit(); } header("Location: ".$pag."?ok=1"); ?>