if ((!isset($_GET['month'])) && (!isset($_GET['buscar']))){
$date = getdate(time());
if (!isset($day))
$day = $date['mday'];
$month = $date['mon'];
$year = $date['year'];
$url = $_SERVER['PHP_SELF'].'?day='.$day.'&month='.$month.'&year='.$year.'&week=true';
header('location:'.$url);
}
else{
$day = $_GET['day'];
$month = $_GET['month'];
$year = $_GET['year'];
}
$week = $_GET['week'];
require_once 'calendar.php';
echo ''."\n";
echo ''."\n";
echo ''."\n";
class MyCalendar extends Calendar
{
var $spanishMonths = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
var $spanishDays = array ("dom", "lun", "mar", "mié", "jue", "vie", "sáb");
var $dias;
var $diasMirados = false;
var $SERVER = "localhost";
var $USER = "popes80_popes80";
var $PASSWORD = "opera";
var $DATABASE = "popes80_panelcontrol";
var $TABLE = "agenda";
function MyCalendar(){
$this->setMonthNames($this->spanishMonths);
$this->setDayNames($this->spanishDays);
$this->setStartDay(1); //Establecemos el inicio de la semana en el lunes
}
function getMonthName($i){
return $this->spanishMonths[$i-1];
}
function getDias($month, $year){
if (!($this->diasMirados)){
$dias1[0] = "0";
$link = mysql_connect($this->SERVER, $this->USER, $this->PASSWORD);
mysql_select_db($this->DATABASE, $link);
$sql = "SELECT * FROM ".$this->TABLE." WHERE (month=$month) AND (year=$year)";
//echo $sql;
$result = mysql_query($sql, $link);
$encontrados = mysql_num_rows($result);
//echo "encontrados= ".$encontrados;
$j=0;
while ($row = mysql_fetch_array($result))
{
if (!mysql_data_seek ($result, $j))
{
printf ("Cannot seek to row %d\n", $j);
continue;
}
if(!($row = mysql_fetch_object ($result)))
continue;
$dias1[$j] = $row->day;
$j++;
}
mysql_free_result ($result);
//print_r($dias1);
//echo "
".array_values($dias1);
$this->set_dias($dias1);
$this->diasMirados = true;
}
}
function set_dias($arrayDias){
$this->dias = $arrayDias;
}
function getDateLink($day, $month, $year)
{
if (!$this->diasMirados)
$this->getDias($month,$year);
$link = "";
//Comprobamos si el día está en el array de días con links del mes.
if (in_array ($day,$this->dias))
{
$s = getenv('SCRIPT_NAME');
$link = "$s?day=$day&month=$month&year=$year";
}
return $link;
}
function getCalendarLink($month, $year)
{
// Redisplay the current page, but with some parameters
// to set the new month and year
$s = getenv('SCRIPT_NAME');
return "$s?month=$month&year=$year";
}
function mostrarBuscador(){
echo '
'."\n"; echo ' | BUSCADOR | '."\n"; echo ''."\n"; echo ' |
'."\n"; echo ' |
'; //include ("izq.php"); //echo ' | '; echo '';
include("notaagenda.php");
function mostrarResultados($cal, $sql, $buscador, $week){
$link = mysql_connect($cal->SERVER, $cal->USER, $cal->PASSWORD);
mysql_select_db($cal->DATABASE, $link);
//echo $sql;
$result = mysql_query($sql, $link);
$encontrados = mysql_num_rows($result);
//echo "encontrados= ".$encontrados;
echo '
"; //echo $select." "; $sql = "SELECT * FROM ".$cal->TABLE." WHERE (".$select." LIKE '%$buscar%') AND (year=$year)"; mostrarResultados($cal, $sql, true, false); } else if ($day != NULL){ if ($week != true){ $sql = "SELECT * FROM ".$cal->TABLE." WHERE (day=$day) AND (month=$month) AND (year=$year)"; mostrarResultados($cal, $sql, false, false); } else { $temp = $day+7; $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if ($temp > $daysInMonth[$month-1]){ $day1 = $temp - ($daysInMonth[$month-1]); $sql = "SELECT * FROM ".$cal->TABLE." WHERE ((day BETWEEN $day AND ".$daysInMonth[$month-1].") AND (month=".($month).") AND (year=$year)) UNION SELECT * FROM ".$cal->TABLE." WHERE ((day BETWEEN 1 AND $day1 AND (month=".($month+1).")) AND (year=$year)) order by month,year,day"; } else { //$day += 7; $sql = "SELECT * FROM ".$cal->TABLE." WHERE (day BETWEEN $day AND $temp) AND (month=$month) AND (year=$year) ORDER BY day, month, year"; } //$sql = "SELECT * FROM ".$cal->TABLE." WHERE (day BETWEEN ($day - 7) AND ($day)) AND (month=$month) AND (year=$year) ORDER BY day, month, year"; //echo $sql." "; mostrarResultados($cal, $sql, false, true); // continue 1; } } else{ echo '
| ';
echo '