12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- /* AJAX
- * Selecciona los datos de la carrera
- * Recibe:
- * id - ID de la carrera
- * Return:
- * resultado o cadena de error
- */
- require_once("../include/nocache.php");
- require_once("../include/bd_pdo.php");
- //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
- session_start();
- $session_life = 1*60*60;//convertido a segundos
- if (isset($_SESSION["timeout"])) {
- // calculate the session's "time to live"
- $sessionTTL = time() - $_SESSION["timeout"];
- if ($sessionTTL > $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();
- //--- Valida que el usuaro tenga permisos de superadministrador
- if(!$_SESSION["sgi_administrador"]){
- $return["error"] = "Error! No tienes permisos para realizar esta acción.";
- }else if(!isset($_POST["id"]) || $_POST["id"] == "" || !isset($_POST["sist"]) || $_POST["sist"] == ""){
- $return["error"] = "Error! No se recibió la información del menú.";
- }else{
- $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $sist = filter_input(INPUT_POST, "sist", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $stmt = $pdo->prepare('Select * from fs_submenu(:id, :sist)');
- $stmt->bindParam(":id", $id);
- $stmt->bindParam(":sist", $sist);
- if(!$stmt->execute()){
- $return["error"] = "Ocurrió un error al leer los datos del submenú.";
- }else{
- $rs = $stmt->fetch();
- $stmt->closeCursor();
- $stmt = null;
-
- $return["desc"] = $rs["Submenu_desc"];
- $return["pag"] = $rs["Submenu_pag_base"];
- $return["menu"] = $rs["Menu_id"];
- $return["activo"] = ($rs["Submenu_mostrar"] ? 1:0);
- $return["icono"] = $rs["Submenu_icono"];
- }
- }
- $return["json"] = json_encode($return);
- echo json_encode($return);
- ?>
|