1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- /*
- * Inserta los datos de un nuevo Menú. El orden es por default al último
- * Recibe:
- * id - ID del submenú
- * desc - Descripción del menú
- * pagina - Si se muestra en la barra o no
- * icono - Icono de FA
- * Error:
- * 0 - No se recibieron los datos
- * 1 - Error de base de datos
- * Success:
- */
- require_once("../include/bd_pdo.php");
- require_once("../classes/ValidaSesion.php");
- $pag = "../menus.php";
- 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"]){
- header("Location: ".$pag);
- exit();
- }
- unset($objValida);
- if(!isset($_POST["id"]) || !isset($_POST["desc"]) || !isset($_POST["pag"]) ){
- header("Location: ".$pag."?error=0");
- exit();
- }
- $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $desc = trim(filter_input(INPUT_POST, "desc", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
- //$icono = trim(filter_input(INPUT_POST, "icono", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
- $pagina = trim(filter_input(INPUT_POST, "pag", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
- $activo = filter_input(INPUT_POST, "activo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $sist = filter_input(INPUT_POST, "sist", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $query = "";
- $query .= ($activo == 1 ? "true" : "false");
- $stmt = $pdo->prepare('Select * from fu_submenu(:id, :desc, :pag, NULL,'.$query.')');
- $stmt->bindParam(":id", $id);
- $stmt->bindParam(":desc", $desc);
- $stmt->bindParam(":pag", $pagina);
- //$stmt->bindParam(":ico", $icono);
- if(!$stmt->execute()){
- //print_r($stmt->errorInfo());
- header("Location:".$pag."?sist=".$sist."&error=1");
- exit();
- }
- $stmt->closeCursor();
- $stmt = null;
- header("Location: ".$pag."?sist=".$sist);
- exit();
- ?>
|