12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- /* AJAX
- * Selecciona los datos de la carrera
- * Recibe:
- * id - ID de grupo,
- * json
- * Return:
- * resultado o cadena de error
- */
- require_once("../../include/constantes.php");
- require_once("../../include/nocache.php");
- require_once("../../include/util.php");
- require_once("../../include/bd_pdo.php");
- require_once("../../classes/ValidaSesion.php");
- //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
- $objSesion = new ValidaSesion($pdo, 51, APSA);
- if($objSesion->tieneAcceso() && isset($_POST["id"]) && $_POST["id"]!="" && isset($_POST["check"]) && $_POST["check"]!=""){
- $grupo = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $str_check = trim(filter_input(INPUT_POST, "check", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
-
- $stmt = $pdo->prepare('Select * from fs_horariogrupo(:gpo, NULL, NULL)');
- $stmt->bindParam(":gpo", $grupo);
-
- $error = false;
-
- if(!$stmt->execute()){
- $t = $stmt->errorInfo();
- $return["error"] = "Ocurrió un error al obtener los horarios del grupo ".$t[2];
- $error = true;
- }
- $horario_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- $horario_hash = "";
-
- foreach($horario_rs as $horario){//crea objeto json
- $tipo = 0;
- if(isset($horario["TipoSubmateria_id"]) && $horario["TipoSubmateria_id"] != "")
- $tipo = $horario["TipoSubmateria_id"];
- $horario_hash .= $horario["Dia_id"].substr($horario["Horario_hora"], 0, 5).$horario["Materia_id"].$horario["Horario_duracion"].fechaSlash($horario["fecha_inicial"]).fechaSlash($horario["fecha_final"]).$tipo;
- }
-
- if(!$error){
- $return["reload"] = !(md5($horario_hash) == $str_check);
- $return["compare"] = md5($horario_hash)." == ".$str_check;
- }
- }else{
- $return["reload"] = false;
- $return["error"] = "No se recibieron los parámetros esperados.";
- }
- $return["json"] = json_encode($return);
- echo json_encode($return);
- ?>
|