session_start();
error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors", 1);
//Chequeamos si esta conectado el usuario
if (isset($_SESSION["sexid"])) $conectado=true;
else $conectado=false;
/*
// ----- set mb_http_output encoding to UTF-8 -----
mb_http_output('UTF-8');
// ----- setup php for working with Unicode data -----
mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
mb_http_input('UTF-8');
mb_language('uni');
mb_regex_encoding('UTF-8');
ob_start('mb_output_handler');
*/
// Recibe parametros
$idgrte = $_GET["idgrte"]; // grupo de noticias a mostrar
$idtema = $_GET["idtema"]; // tema de noticas a mostrar
//Seleccionamo la opcion de menu
//Noticias -> idgrte=1
//Conocenos_proyecto educativo -> idtema=21
//Conocenos_equipo -> idtema=22
//Conocenos_calendario escolar -> idtema=25
//Conocenos_consejo escolar -> idtema=23
//Conocenos_instalaciones ->
//Conocenos_matriculaciones -> idtema=26
//Conocenos_reglamento interno -> idtema=27
//Conocenos_como llegar -> contactar.php
//Actividades -> idgrte=3
//Biblioteca -> idtema=40
//Que comemos -> idtema=50
//Registrarse -> registrarse.php
//Contactar -> contactar.php
if ($idgrte=='' and $idtema == '') {
$idgrte = 1;
}
//iniciamos la variables del menu activo
$opmenu[1]=($idgrte=="1"?"active":"");
$opmenu[2]=(substr($idtema,0,1)=="2"?"active":"");
$opmenu[21]=($idtema=="21"?"active":"");
$opmenu[22]=($idtema=="22"?"active":"");
$opmenu[23]=($idtema=="23"?"active":"");
$opmenu[24]=($idtema=="24"?"active":"");
$opmenu[25]=($idtema=="25"?"active":"");
$opmenu[26]=($idtema=="26"?"active":"");
$opmenu[27]=($idtema=="27"?"active":"");
$opmenu[3]=($idgrte=="3"?"active":"");
$opmenu[4]=($idtema=="40"?"active":"");
$opmenu[5]=($idtema=="50"?"active":"");
$opmenu[6]="";
$opmenu[7]="";
$opmenu[8]="";
?>
if (!isset($opmenu)) {
header('Location: http://'.$_SERVER['SERVER_NAME']);
exit();
}
?>
if (!isset($opmenu)) {
header('Location: http://'.$_SERVER['SERVER_NAME']);
exit();
}
session_start();
/*
// ----- set mb_http_output encoding to UTF-8 -----
mb_http_output('UTF-8');
// ----- setup php for working with Unicode data -----
mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
mb_http_input('UTF-8');
mb_language('uni');
mb_regex_encoding('UTF-8');
ob_start('mb_output_handler');
*/
// Cargar funciones
include ("cfg/funciones.php");
// Conecta con la BBDD
Conecta_BBDD ();
// Recibe parametros
$idgrte = $_GET["idgrte"]; // grupo de noticias a mostrar
$idtema = $_GET["idtema"]; // tema de noticas a mostrar
$titulo = $_GET["t"]; // mostrar titulo de grupo
$volver = $_GET["v"]; // direccion de vuelta para enlace
$pagina = $_GET["p"]; // pagina a mostrar
$buscar = $_GET["buscar"]; // buscar una noticia
//Chequeamos si esta conectado el usuario
if($_SESSION["sexid"]!='') $conectado=true;
else $conectado=false;
// if estamos buscando un texto entre todas las noticias
if ($buscar !='') {
//Configuramos los marcadores
$ponfecha = 'S';
//Construir condiciones
$swhere = " and (no_titulo LIKE '%".$buscar."%'"
. " OR no_mensaje LIKE '%".$buscar."%')"
. " and no_fecha <= '".substr($hoy,0,10). "' and no_confir = 'S' and no_idtema<99";
// Obtener noticias que cumplen el criterio de busqueda
$sql = 'SELECT count(*) as numsg '
. 'FROM tb_noticias '
. " WHERE 1 ".$swhere;
$resultado = mysqli_query($conn,$sql);
$row = mysqli_fetch_array($resultado);
$numsg = $row["numsg"];
$numpaginas = ceil ($numsg/_NUNOTICIAS);
$limi_desde = ($pagina-1) * _NUNOTICIAS;
$limi_hasta = $limi_desde + _NUNOTICIAS;
if ($limi_hasta > $numsg) $limi_hasta = $numsg;
// Obtener noticias
$sql = "SELECT a.*, b.te_destema, "
. ' (select count(*) from tb_adjuntos where pa_ref = id_noticia) as numadj'
. " FROM tb_noticias a"
. " LEFT JOIN tb_temasnoti b on b.te_idtema=a.no_idtema"
. " WHERE 1 ".$swhere
. " ORDER BY no_fecha DESC, id_noticia DESC";
$resultado = mysqli_query($conn,$sql);
$num_resultados = mysqli_num_rows($resultado);
} else {
//chequear parametros
if ($idgrte=='' and $idtema == '') $idgrte = 1;
if ($pagina == '') $pagina = 1;
//Where de temas a mostrar
if ($idgrte != '') {
$swhere = "no_idtema IN (select te_idtema from tb_temasnoti where te_grupo = ".$idgrte.")";
} else {
$swhere = "no_idtema = ".$idtema;
}
// Obtener datos del tema
if ($idgrte != '') {
$sql = 'SELECT * FROM tb_temasnoti '
. ' WHERE te_grupo ='.$idgrte
. ' ORDER BY te_idtema LIMIT 1';
} else {
$sql = 'SELECT * FROM tb_temasnoti '
. ' WHERE te_idtema =\''.$idtema.'\'';
}
$resultado = mysqli_query($conn, $sql);
$num_resultados = mysqli_num_rows($resultado);
$row = mysqli_fetch_array($resultado);
$urlvolver = $row["te_urlvolver"];
$nomtitulo = $row["te_destema"];
$ponfecha = $row["te_ponfecha"];
if ($urlvolver == '') $urlvolver ='gruponoti.php';
// Obtener el numero de mensajes
$ssql = 'SELECT count(*) as numsg '
. 'FROM tb_noticias '
. " WHERE (".$swhere;
if ($idgrte == 1){
$ssql .= ' or no_portada =\'S\')';
} else {
$ssql .= ')';
}
$ssql.= " and no_fecha <= '".substr($hoy,0,10). "' and no_confir = 'S' and no_idtema<99";
$resultado = mysqli_query($conn, $ssql);
$row = mysqli_fetch_array($resultado);
$numsg = $row["numsg"];
$numpaginas = ceil ($numsg/_NUNOTICIAS);
$limi_desde = ($pagina-1) * _NUNOTICIAS;
$limi_hasta = $limi_desde + _NUNOTICIAS;
if ($limi_hasta > $numsg) $limi_hasta = $numsg;
// Obtener noticias
$consulta = "SELECT a.*, b.te_destema, "
. ' (select count(*) from tb_adjuntos where pa_ref = id_noticia) as numadj'
. " FROM tb_noticias a, tb_temasnoti b"
. " WHERE (".$swhere;
if ($idgrte == 1){
$consulta .= ' or no_portada =\'S\')';
} else {
$consulta .= ')';
}
$consulta .= " and no_fecha <= '".substr($hoy,0,10). "' and no_confir = 'S' and no_idtema<99";
$consulta .= " and no_idtema = te_idtema";
$consulta .= " ORDER BY no_fecha DESC, id_noticia DESC"
. " LIMIT ".$limi_desde.",". _NUNOTICIAS;
$resultado = mysqli_query($conn,$consulta);
$num_resultados = mysqli_num_rows($resultado);
}
$p_width = 100;
for ($i=0; $i <$num_resultados; $i++) {
$row = mysqli_fetch_array($resultado);
$mensaje = strip_tags($row["no_mensaje"],"");
$mensaje = $row["no_mensaje"];
/*
$change = array("
","", "
");
$busca = array("\r\n","
", "
");
$mensaje = str_replace($busca, $change, $mensaje);
*/
if (strlen($mensaje) > 1000 and $num_resultados >1) $readmore=true;
else $readmore=false;
//Recuperamos los ficheros adjuntos
if ($row["numadj"]>0) {
// obtener adjuntos
$sql = "SELECT *"
. " FROM tb_adjuntos"
. " WHERE pa_ref = ".$row["id_noticia"]
. " ORDER BY pa_orden, pa_id";
$rst_adj = mysqli_query($conn,$sql);
$num_adjuntos = mysqli_num_rows($rst_adj);
}
?>