function formatearFecha($fecha)
{
$meses = array("Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic");
$anio = substr($fecha,2,2);
$mes = substr($fecha,4,2);
$dia = substr($fecha,6,2);
$fecForma = $dia."/".$meses[$mes-1]."/".$anio;
return $fecForma;
}
?>
$pagina = $_REQUEST["pagina"];
if ($_REQUEST["pagina"])
{
if ($pagina == 1){
$titulo = "TORNEOS NACIONALES";
$pagina_actual = "ver_torneos.php?pagina=$pagina";
}
else{
$titulo = "TORNEOS INTERNACIONALES";
$pagina_actual = "ver_torneos.php?pagina=$pagina";
}
}else{
$titulo = "PROXIMOS TORNEOS INTERNACIONALES";
$pagina_actual = "ver_torneos.php?pagina=$pagina";
}
include 'torneossup.php' ?>
$date = date("Ymd");
$year = date("Y");
$anioTorn_ini = $year;
$anioTorn_fin = $year;
$years = array($year-7,$year-6,$year-5,$year-4,$year-3,$year-2,$year-1,$year,$year+1);
$dias_meses = array(31,28,31,30,31,30,31,31,30,31,30,31);
$mesTorn_ini = 0;
$mesTorn_fin = 0;
$diaTorn_ini = 0;
$diaTorn_fin = 0;
$inf = 101;
$sup = 630;
$page_info = null;
$mesAct = date("m");
$diaAct = date("d");
$diaQry = 0;
$mesQry = 0;
$yearQry = 0;
$fecha_actual= $date;
$DIAS_CONSULTA = 15;
$sw_anio =false;
$flag_inicio=false;
$cont_filas = 0;
$anioSelect=$year;
$semSelect=1;
$paisSelect=1;
$torn=false;
$t_mod=3;
include 'conexion.php';
?>
echo $titulo ?>
if($mesAct > 1 && $mesAct < 7)
{
$inf = 101;
$sup = 630;
}else{
$inf = 701;
$sup = 1231;
}
if($semSelect == 2)
{
$inf = 701;
$sup = 1231;
echo "Torneos del segundo semestre del año $anioSelect
";
}
if($semSelect == 1)
{
$inf = 101;
$sup = 630;
echo "Torneos del primer semestre del año $anioSelect
";
}
if($_REQUEST["pais"])
{
$paisSelect = $_REQUEST["pais"];
}
if ($_REQUEST["asc"]=="ASC")
{
$asc = "ASC";
$asce = "DESC";
$image = "arrow.gif";
}
else if ($_REQUEST["asc"]=="DESC")
{
$asc = "DESC";
$asce = "ASC";
$image = "arrow1.gif";
}else
{
$asc = "ASC";
$asce = "DESC";
$image = "arrow.gif";
}
?>
Fecha |
Nombre |
Pais/Ciudad |
Página Web |
Resultados |
Partidas |
Fotos |
$order = "fecha_ini";
if($_REQUEST["order"])
{
$order = $_REQUEST["order"];
}else
{
$order = "fecha_ini";
}
$yearQry = $year;
if ($diaAct > $DIAS_CONSULTA)
{
$diaQry = $diaAct-$DIAS_CONSULTA;
$mesQry = $mesAct;
}
else
{
$tdia = $diaAct-$DIAS_CONSULTA;
if ($mesAct>1)
{
$diaQry = $dias_meses[$mesAct-2]+$tdia;
}
else
{
$diaQry = $dias_meses[11]+$tdia;
}
$mesQry = $mesAct-1;
if ($mesQry==0)
{
$mesQry = 12;
$yearQry = $year-1;
}
}
$suma= (($yearQry*10000)+($mesQry*100)+$diaQry);
if ($pagina == 1)
{
if ($sw_anio == true)
{
$result = mysql_query("SELECT p.nombre, p.id, t.id, t.id_pais, t.nombre, t.ciudad, t.id_departamento, t.fecha_ini, t.fecha_fin,
t.pgn, t.fotos, t.page, t.page_resul, t.id_entidad, t.fechamodificacion FROM torneo as t INNER JOIN pais as p ON p.id = t.id_pais WHERE (id_pais LIKE '$paisSelect' AND fecha_fin > '$suma' AND logo LIKE '') ORDER BY $order $asc", $link);
}else
{
$result = mysql_query("SELECT p.nombre, p.id, t.id, t.id_pais, t.nombre, t.ciudad, t.id_departamento, t.fecha_ini, t.fecha_fin,
t.pgn, t.fotos, t.page, t.page_resul, t.id_entidad, t.fechamodificacion FROM torneo as t INNER JOIN pais as p ON p.id = t.id_pais WHERE (id_pais LIKE '$paisSelect' AND logo LIKE '') ORDER BY $order $asc", $link);
}
}else{
if ($sw_anio == true)
{
$result = mysql_query("SELECT p.nombre, p.id, t.id, t.id_pais, t.nombre, t.ciudad, t.id_departamento, t.fecha_ini, t.fecha_fin,
t.pgn, t.fotos, t.page, t.page_resul, t.id_entidad, t.fechamodificacion FROM torneo as t INNER JOIN pais as p ON p.id = t.id_pais
WHERE (internacional LIKE '1' AND fecha_fin > '$suma') ORDER BY t.fecha_ini $asc", $link);
}
else
{
$result = mysql_query("SELECT p.nombre, p.id, t.id, t.id_pais, t.nombre, t.ciudad, t.id_departamento, t.fecha_ini, t.fecha_fin,
t.pgn, t.fotos, t.page, t.page_resul, t.id_entidad, t.fechamodificacion FROM torneo as t INNER JOIN pais as p ON p.id = t.id_pais
WHERE internacional LIKE '1' ORDER BY t.fecha_ini $asc", $link);
}
}
while ($row = mysql_fetch_array($result))
{
if (mysql_affected_rows() == 0)
{
echo "No hay torneos registrados
";
}else{
$fechaIni = $row["fecha_ini"];
$fechaFin = $row["fecha_fin"];
$anioTorn_ini = substr("$row[fecha_ini]",0,4);
$anioTorn_fin = substr("$row[fecha_fin]",0,4);
$mesTorn_ini = substr("$row[fecha_ini]",4,8);
$mesTorn_fin = substr("$row[fecha_fin]",4,8);
$diaTorn_ini = substr("$row[fecha_ini]",6,8);
$diaTorn_fin = substr("$row[fecha_fin]",6,8);
$anioTorn_mod = substr("$row[fechamodificacion]",0,4);
$mesTorn_mod = substr("$row[fechamodificacion]",4,8);
$diaTorn_mod = substr("$row[fechamodificacion]",6,8);
$paisSelect = $row["0"];
$sw_torneo = false;
$ind_verde = false;
$i_tDia = 0;
if($anioTorn_fin == $year)
{
if($mesAct-(substr($mesTorn_fin,0,2)) == 0)
{
if(((($mesAct*100+$diaAct)-$mesTorn_fin) <= 15) && ((($mesAct*100+$diaAct)-$mesTorn_fin) > 0))
$ind_verde = true;
}
else if($mesAct-(substr($mesTorn_fin,0,2)) == 1)
{
$i_tDia = (30-$diaTorn_fin) + $diaAct;
if( $i_tDia <= 15 && $i_tDia > 0)
$ind_verde = true;
}
}
else if(($year-$anioTorn_fin) == 1)
{
if((substr($mesTorn_ini,0,2)==1) && ($mesAct==12))
{
$i_tDia = (30-$diaTorn_fin) + $diaAct;
if($i_tDia <= 15 && $i_tDia > 0)
$ind_verde = true;
}
}
$ind_rojo = false;
if (($row["fecha_ini"] <= $fecha_actual) && ($fecha_actual <= $row["fecha_fin"]))
{
$ind_rojo = true;
}
$ind_amarillo = false;
$i_tDia = 0;
if($anioTorn_ini == $year)
{
if((substr($mesTorn_ini,0,2)-$mesAct) == 0)
{
if((($mesTorn_ini-($mesAct*100+$diaAct)) < 9) && (($mesTorn_ini-($mesAct*100+$diaAct)) > 0))
$ind_amarillo = true;
}
else if((substr($mesTorn_ini,0,2)-$mesAct) == 1)
{
$i_tDia = (30-$diaAct) + $diaTorn_ini;
if( $i_tDia <= 9 && $i_tDia > 0)
$ind_amarillo = true;
}
}
else if(($anioTorn_ini - $year) == 1)
{
if((substr($mesTorn_ini,0,2)==1) && ($mesAct==12))
{
$i_tDia = (30-$diaAct) + $diaTorn_ini;
if( $i_tDia <= 9 && $i_tDia > 0)
$ind_amarillo = true;
}
}
$ind_new = false;
$i_tDia = 0;
if($anioTorn_mod == $year)
{
if($mesAct-(substr($mesTorn_mod,0,2)) == 0)
{
if(((($mesAct*100+$diaAct)-$mesTorn_mod) <= $t_mod) && ((($mesAct*100+$diaAct)-$mesTorn_mod) >= 0))
$ind_new = true;
}
else if($mesAct-(substr($mesTorn_mod,0,2)) == 1)
{
$i_tDia = (30-$diaTorn_mod) + $diaAct;
if( $i_tDia <= $t_mod && $i_tDia > 0)
$ind_new = true;
}
}
else if(($year-$anioTorn_mod) == 1)
{
if((substr($mesTorn_mod,0,2)==12) && ($mesAct==1))
{
$i_tDia = (30-$diaTorn_mod) + $diaAct;
if($i_tDia <= $t_mod && $i_tDia > 0)
$ind_new = true;
}
}
if ($sw_anio!=true)
{
if((($anioTorn_ini == $anioSelect) && ($mesTorn_ini >= $inf) && ($mesTorn_ini <= $sup)) ||
(($anioTorn_fin == $anioSelect) && ($mesTorn_fin >= $inf) && ($mesTorn_fin <= $sup)))
{
$torn=true;
}
}
if (($sw_anio==true) && ($torn==false))
{
if (sw_anio == true)
{
$torn = true;
}
else
{
if ($cont_filas < 5)
{
$torn=true;
}
}
}
if ($torn==true)
{
$torn_corto = false;
if (($row["fecha_fin"] - $row["fecha_ini"]) <= 101 ){
$torn_corto=true;
}
if (($ind_verde == true) && ($torn_corto == true)){
$sw_torneo = true;
echo "";
$fechaI = formatearFecha($fechaIni);
$fechaF = formatearFecha($fechaFin);
echo "| $fechaI a $fechaF | ";
if ($ind_new == true)
{
echo " $row[nombre] | ";
}
else
echo " $row[nombre] | ";
echo "$paisSelect - $row[ciudad] | ";
}
else if (($torn_corto == true) && ($ind_rojo == true))
{
$sw_torneo = true;
echo "
";
$fechaI = formatearFecha($fechaIni);
$fechaF = formatearFecha($fechaFin);
echo "| $fechaI a $fechaF | ";
if ($ind_new == true)
{
echo " $row[nombre] | ";
}
else
echo " $row[nombre] | ";
//echo "$row[ciudad] | ";
echo "$paisSelect - $row[ciudad] | ";
// torneos que empiezan en los próximos 8 días
}else if (($ind_amarillo) && ($torn_corto == true))
{
$sw_torneo = true;
echo "
";
$fechaI = formatearFecha($fechaIni);
$fechaF = formatearFecha($fechaFin);
echo "| $fechaI a $fechaF | ";
if ($ind_new == true)
{
echo " $row[nombre] | ";
}
else
echo " $row[nombre] | ";
echo "$paisSelect - $row[ciudad] | ";
}
// El resto de torneos cuando se ingresan parametros
else if (($sw_anio == true) && ($torn_corto==true))
{
$cont_filas = $cont_filas + 1;
echo "
";
$sw_torneo = true;
$fechaI = formatearFecha($fechaIni);
$fechaF = formatearFecha($fechaFin);
echo "| $fechaI a $fechaF | ";
if ($ind_new == true)
{
echo " $row[nombre] | ";
}
else
echo " $row[nombre] | ";
echo "$paisSelect - $row[ciudad] | ";
}else if ($sw_anio == false)
{
$sw_torneo = true;
echo "
";
$fechaI = formatearFecha($fechaIni);
$fechaF = formatearFecha($fechaFin);
echo "| $fechaI a $fechaF | ";
if ($ind_new == true)
{
echo " $row[nombre] | ";
}
else
{
echo " $row[nombre] | ";
}
echo "$paisSelect - $row[ciudad] | ";
}
if ($sw_torneo == true)
{
if($row["page"] == "")
{
echo " | ";
}else if((substr("$row[page]",0,4)== "www.") || (substr("$row[page]",0, 4) == "http"))
{
echo " Página | ";
}else{
echo " Ver | ";
}
if($row["page_resul"] == "")
{
echo " | ";
}else if((substr("$row[page_resul]",0, 4) == "www.") || (substr("$row[page_resul]",0,4) == "http"))
{
echo " Resultados | ";
}else{
echo " Resultados | ";
}
if($row["pgn"] == ""){
echo " | ";
}else{
echo " Ver | ";
}
if($row["fotos"] == ""){
echo " | ";
}else{
if(strstr($row["fotos"], "http://")){
echo " Ver | ";
}
else{
echo " Ver | ";
}
}
echo "
";
}// Fin if sw_torneo == true
$torn=false;
}//Fin de fecha semestre torn==true
}//Fin while query.next()
}//Fin else query == null
mysql_close ($link);
?>
Torneos terminados
Torneos que se estan jugando
Próximos torneos
include 'torneosinf.php' ?>