function makecal($stmonth, $styear) {
## define variables-little cleaner
## than mucking over the code to
## change stuff
##
$face = "verdana"; ## font face for all text
$size = "1"; ## font size for all text
$height = "22"; ## cell height
$width = "22"; ## cell width
$todaycolor = "#CC0000"; ## font color for the current date
$inmonthface = "#000000"; ## font color for days in the display month
$outmonthface = "#666666"; ## font color for days not in the display month
$inbgcolor = "#FFFFCC"; ## cell bgcolor for days in the display month
$outbgcolor = "#FFCCFF"; ## cell bgcolor for days not in display month
## make workie code stuph
##
$stdate = mktime(0,0,0,$stmonth,1,$styear);
$startdate = $currdate = mktime(0,0,0,$stmonth,1 - date("w", mktime(0,0,0,$stmonth,1,$styear)),$styear);
$enddate = mktime(0,0,0,date("m",$stdate) + 1,7 - date("w", mktime(0,0,0,$stmonth + 1,0,$styear)),$styear);
echo "\n";
echo "\n" . date("F",$stdate) . " " . date
("Y",$stdate) . " \n \n";
echo "\nsize=\"$size\">Su \n";
echo "size=\"$size\">Mo \n";
echo "size=\"$size\">Tu \n";
echo "size=\"$size\">We \n";
echo "size=\"$size\">Th \n";
echo "size=\"$size\">Fr \n";
echo "size=\"$size\">Sa \n \n";
$i=0;
while ($currdate < $enddate) {
echo "\n";
for ($c = 0; $c < 7; $c++) {
if (date("m",$stdate) == date("m",$currdate)) {
$bgcolor = $inbgcolor;
} else {
$bgcolor = $outbgcolor;
}
if (date("d",$currdate) == date("d") && date("m",$currdate) == date("m") && date("Y",$currdate) == date
("Y")) {
$fcolor = $todaycolor;
} elseif (date("m",$currdate) == date("m",$stdate) && date("Y",$currdate) == date("Y",$stdate)) {
$fcolor = $inmonthface;
} else {
$fcolor = $outmonthface;
}
echo "face=\"$face\" size=\"$size\"
color=\"$fcolor\">";
echo date ("j",$currdate);
echo " \n";
$i++;
$currdate = mktime(0,0,0,date("m",$startdate),date("d",$startdate) + $i,date("Y",$startdate));
}
echo " \n";
}
echo "
";
}
## example usage
##
echo "\n\n";
echo "\n\n";
echo "
\n\n";
if ($stmonth && $styear && empty($source)) {
echo makecal($stmonth,$styear);
} elseif (empty($source)) {
echo makecal(date("m"),date("Y"));
} else {
echo "\n";
show_source("cal.php3");
echo "
\n";
}
echo "\n";
?>