Вот тебе код, все как нужно сделано, как просил. Только еще раз прийдется адаптировать под свои нужды, т.к. это по модуль календарь.
Код:
<?php
if (eregi("block-Kalendar.php", $_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
global $prefix, $currentlang, $calsetmonth, $calsetyear;
$module_name = "Kalendar";
/*
set $requestcomp to indicate the page on which you want the
javascript menu to appear
*/
$Date = Date("m/d/Y");
/* today's date */
$Date_Array1 = explode("/", $Date);
/* code for requested month or day */
$Date_Array = explode("/", $Date);
if (isset($calsetyear)) {
$Date_Array[2] = $calsetyear;
}
if (isset($calsetmonth)) {
$Date_Array[0] = $calsetmonth;
}
/**** Specific front display variables */
/*EDIT THESE TO SPECIFY COLORS BELOW*/
// Colores para personalizar se pueden usar los colores del tema $bgcolorX y $textcolorX
$hoy = "#FFFF00"; // Цвет текста текущей даты
$pas = "#000000"; // Цвет текста прошедших дней
$nue = "#FFFFFF"; // Цвет текста будущих дней дней
$ant = "#F5F5FF"; // Цвет фона обычных прошедших дней
$bgh = "#000000"; // Цвет фона текущего дня
$fes = "#FF0000"; // Цвет фона воскресных дней
$nor = "#666D75"; // Цвет фона обычных будущих дней
$content = "";
$selmon = array();
for ($i=1; $i <=12; $i++) {
$selmon[$i] = "";
}
$month = $Date_Array[0];
if ($month == "01" || $month =="1")
{
$monthname = _CALJAN;
$selmon[1] = "selected";
} elseif ($month == "02")
{
$monthname = _CALFEB;
$selmon[2] = "selected";
} elseif ($month == "03")
{
$monthname = _CALMAR;
$selmon[3] = "selected";
} elseif ($month == "04")
{
$monthname = _CALAPR;
$selmon[4] = "selected";
} elseif ($month == "05")
{
$monthname = _CALMAY;
$selmon[5] = "selected";
} elseif ($month == "06")
{
$monthname = _CALJUN;
$selmon[6] = "selected";
} elseif ($month == "07")
{
$monthname = _CALJUL;
$selmon[7] = "selected";
} elseif ($month == "08")
{
$monthname = _CALAUG;
$selmon[8] = "selected";
} elseif ($month == "09")
{
$monthname = _CALSEP;
$selmon[9] = "selected";
} elseif ($month == "10")
{
$monthname = _CALOCT;
$selmon[10] = "selected";
} elseif ($month == "11")
{
$monthname = _CALNOV;
$selmon[11] = "selected";
} elseif ($month == "12")
{
$monthname = _CALDEC;
$selmon[12] = "selected";
}
/* Determine selected year */
$selyear = array();
for ($i=1; $i <=10; $i++) {
$selyear[$i] = "";
if ($Date_Array[2] == ($i+2005)) {
$selyear[$i] = "selected";
}
}
/**** Get the Day (Integer) for the first day in the month */
$First_Day_of_Month_Date = mktime("", "", "", $Date_Array[0], 1, $Date_Array[2]);
$Date = $First_Day_of_Month_Date;
$Day_of_First_Week = Date("w",$First_Day_of_Month_Date);
/**** Find the last day of the month */
$Month = Date("m",$Date);
$day = 27;
do {
$End_of_Month_Date = mktime("", "", "", $Date_Array[0], $day, $Date_Array[2]);
$Test_Month = Date("m",$End_of_Month_Date);
$day += 1;
} while ( $Month == $Test_Month );
$Last_Day = $day - 1;
/**** Get todays date */
$Today_d = Date("d");
$Today_m = Date("m");
$Today_y = Date("Y");
/**** Build Month */
$content .= "\n<BR><center><TABLE border=0 cellspacing=1 cellpadding=2>";
$content .= "\n<TR>\n<TH colspan=7><FORM Name = \"selectcalendar\" action = \"index.php\">\n<center><FONT class=\"tiny\">";
//if (eregi($requestcomp,$_SERVER['REQUEST_URI'])) {
$content .="<B><SELECT Name = \"calsetmonth\" onChange=\"javascript:document.selectcalendar.submit()\">
<OPTION $selmon[1] VALUE='01'>Январь</OPTION>
<OPTION $selmon[2] VALUE='02'>Февраль</OPTION>
<OPTION $selmon[3] VALUE='03'>Март</OPTION>
<OPTION $selmon[4] VALUE='04'>Апрель</OPTION>
<OPTION $selmon[5] VALUE='05'>Май</OPTION>
<OPTION $selmon[6] VALUE='06'>Июнь</OPTION>
<OPTION $selmon[7] VALUE='07'>Июль</OPTION>
<OPTION $selmon[8] VALUE='08'>Август</OPTION>
<OPTION $selmon[9] VALUE='09'>Сентебрь</OPTION>
<OPTION $selmon[10] VALUE='10'>Октябрь</OPTION>
<OPTION $selmon[11] VALUE='11'>Ноябрь</OPTION>
<OPTION $selmon[12] VALUE='12'>Декабрь</OPTION>
</SELECT>
</b></font></center>\n</form>\n</th>\n</tr>\n";
//}
// $content .= "</TH>\n</TR>";
/**** Build Month */
$content .= "\n<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"1\">";
$day_of_week = 2;
$content .= "<TR bgcolor=\"$bgcolor2\">
<TD width=\"20\" align=\"center\"><FONT color=\"$textcolor1\" SIZE=\"1\"><b>Пн</b></font></TD>
<TD width=\"20\" align=\"center\"><FONT color=\"$textcolor1\" SIZE=\"1\"><b>Вт</b></font></TD>
<TD width=\"20\" align=\"center\"><FONT color=\"$textcolor1\" SIZE=\"1\"><b>Ср</b></font></TD>
<TD width=\"20\" align=\"center\"><FONT color=\"$textcolor1\" SIZE=\"1\"><b>Чт</b></font></TD>
<TD width=\"20\" align=\"center\"><FONT color=\"$textcolor1\" SIZE=\"1\"><b>Пт</b></font></TD>
<TD width=\"20\" align=\"center\"><FONT color=\"$textcolor1\" SIZE=\"1\"><b>Сб</b></font></TD>
<TD width=\"20\" align=\"center\"><FONT color=\"$textcolor1\" SIZE=\"1\"><b>Вс</b></font></TD>
</TR>";
if ($Day_of_First_Week == 0) $Day_of_First_Week = 7;
/**** Previous Greyed month days */
While ($day_of_week < ($Day_of_First_Week + 1)) {
if ($day_of_week == 2) {
$content .= "\n<TR>";
}
if ($day_of_week == 8)
$content .= "<TD valign=top><TABLE width=100% cellpadding=0 cellspacing=0 bgcolor=$bgcolor4 border=0><TR><TD align=center><FONT SIZE=2><b> </b></TR></TABLE></td>";
else
$content .= "<TD valign=top><TABLE width=100% cellpadding=0 cellspacing=0 border=0><TR><TD align=center><FONT SIZE=2><b> </b></TR></TABLE></td>";
$day_of_week += 1;
}
$usedcount = 0;
$cellcount = 0;
/**** Build Current Month */
for ($day = 1 ; $day <= $Last_Day ; $day++) {
if ($day_of_week == 2) $content .= "\n<TR>";
if ($day_of_week == 8) {
$bgnew = $fes;
$bgold = $fes;
}
else {
$bgnew = $nor;
$bgold = $ant;
}
$result = mysql_query("SELECT eid,title,eventDate,endDate,startTime,endTime,barc olor FROM $prefix"._events." WHERE (eventDate <= '$Date_Array[2]-$Date_Array[0]-$day' AND endDate >= '$Date_Array[2]-$Date_Array[0]-$day');");
if (($day == $Today_d) && ($Date_Array[0] == $Today_m) && ($Date_Array[2] == $Today_y))
$content .= "\n\t<TD valign=top><TABLE width=100% cellpadding=0 cellspacing=0 bgcolor=$bgh border=0><TR><TD align=center><b><a href=\"modules.php?name=Kalendar&data=0$day.$Date_Array[0].$Date_Array[2]\"><FONT color=$hoy SIZE=2>$day</font></a></b>";
elseif (($day < $Today_d) && ($Date_Array[0] == $Today_m) && ($Date_Array[2] == $Today_y))
$content .= "\n\t<TD valign=top><TABLE width=100% cellpadding=0 cellspacing=0 bgcolor=$bgold border=0><TR><TD align=center><b><a href=\"modules.php?name=Kalendar&data=0$day.$Date_Array[0].$Date_Array[2]\"><FONT color=$pas SIZE=2>$day</font></a></b>";
elseif (($Date_Array[0] < $Today_m) && ($Date_Array[2] == $Today_y) || ($Date_Array[2] < $Today_y))
$content .= "\n\t<TD valign=top><TABLE width=100% cellpadding=0 cellspacing=0 bgcolor=$bgold border=0><TR><TD align=center><b><a href=\"modules.php?name=Kalendar&data=0$day.$Date_Array[0].$Date_Array[2]\"><FONT color=$pas SIZE=2>$day</font></a></b>";
else
$content .= "\n\t<TD valign=top><TABLE width=100% cellpadding=0 cellspacing=0 bgcolor=$bgnew border=0><TR><TD align=center><b><FONT color=$nue SIZE=2>$day</font></b>";
if (mysql_num_rows($result) == 0)
$content .= "<br></TR></TABLE>";
elseif (mysql_num_rows($result) >= 4)
$content .= "<br></TR></TABLE>";
elseif (mysql_num_rows($result) >= 3)
$content .= "<br></TR></TABLE>";
elseif (mysql_num_rows($result) >= 2)
$content .= "<br></TR></TABLE>";
else
$content .= "<br></TR></TABLE>";
$content .= "</td>";
if ($day_of_week == 8) {
$day_of_week = 1;
$content .= "\n</TR>";
}
$day_of_week += 1;
}
/**** Next Greyed month days */
$day = 1;
if ($day_of_week != 1)
{
$tmp = 8 - $day_of_week;
$content .= "<TD colspan=$tmp><font class=\"tiny\"></font></TD>";
}
$Date = implode("/", $Date_Array);
$content .= "\n</td></tr></table><BR>";
?>