<html>
<head> <title>日历程序</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF">
<table border=0 cellspacing=0 cellpadding=0 width="100%">
<tr>
<td width="12%" valign="top" align="center" bgcolor="#FFCC00">
<center>
<form name="calendar" action="<? echo $PHP_SELP; ?>">
<?php
/* Init Define */ $fontface = "Arial"; $fontsize = "-1"; $today_is = "Today is";
$ca_day0 = "Sun"; $ca_day1 = "Mon"; $ca_day2 = "Tue"; $ca_day3 = "Wed"; $ca_day4 = "Thu"; $ca_day5 = "Fri"; $ca_day6 = "Sat";
/* If year is not given, set to current year */
if(!isset($cl_y) || $cl_y=="")
$cl_y = date("Y");
/* If month is not given, set to current month */
if(!isset($cl_m) || $cl_m=="")
$cl_m = date("n"); $cl_prev = $cl_m - 1; $cl_next = $cl_m + 1;
/* Check the Day of the week of 1st of the Month */
$cl_dow = date("w", mktime(0,0,0,$cl_m,1,$cl_y));
/* Generate Header */ echo "<table border=0 cellspacing=0 cellpadding=1>\n"; echo "<tr><td align=center bgcolor=#FFECBF><a href=\"$PHP_SELF?cl_m=$cl_prev\"> << </a><font face=$fontface size=$fontsize>".date("F Y", mktime(0,0,0,$cl_m,1,$cl_y))."</font><a href=\"$PHP_SELF?cl_m=$cl_next\"> >> </a></td></tr>\n"; echo "<tr><td align=center>\n";
/* Start the calendar */
echo "<table border=0 cellspacing=2 cellpadding=0 width=100% bgcolor=#FFFFFF>\n"; echo "<tr align=center>
<td><font face=$fontface size=$fontsize color=red>$ca_day0</font></td>
<td><font face=$fontface size=$fontsize>$ca_day1</font></td>
<td><font face=$fontface size=$fontsize>$ca_day2</font></td>
<td><font face=$fontface size=$fontsize>$ca_day3</font></td>
<td><font face=$fontface size=$fontsize>$ca_day4</font></td>
<td><font face=$fontface size=$fontsize>$ca_day5</font></td>
<td><font face=$fontface size=$fontsize color=red>$ca_day6</font></td>
</tr>\n";
echo "<tr align=center>\n";
$dcount = 0;
for($i=$cl_dow; $i > 0; $i--) {
echo "\t<td><font face=$fontface size=$fontsize color=#C0C0C0><b>".date("j",mktime(0,0,0,$cl_m,1-$i,$cl_y))."</b></font></td>\n"; $dcount++; }
for($i=0; $i < 32; $i++) { $thisDate = date("j",mktime(0,0,0,$cl_m,1+$i,$cl_y));
/* When come to next month, quit */
if($thisDate < $prevDate) break;
/* else put into $preDate */
$prevDate = $thisDate;
if($dcount > 6):
echo "</tr>\n<tr align=center>\n";
$dcount = 0; endif;
/* Highlight Today */
if($thisDate==date("j") && $cl_m==date("n") && $cl_y==date("Y"))
//if($thisData == date("j"))
{
$thisDate = "<B>$thisDate</B>";
$cl_d=$thisDate;
}
echo "\t<td><font face=$fontface size=$fontsize><a href=\"$PHP_SELF?cl_m=$cl_m&cl_y=$cl_y&cl_d=$thisDate\">".$thisDate."</a></font></td>\n"; $dcount++;
}
for($j=$i; $dcount < 7; $j++ ) {
echo "\t<td><font face=$fontface size=$fontsize color=#C0C0C0><b>".date("j",mktime(0,0,0,$cl_m,1+$j,$cl_y))."</b></font></td>\n"; $dcount++; }
echo "</tr>";
echo "</table>";
/* Generate Footer */ echo "</td></tr>\n";
echo "<tr><td align=center bgcolor=#FFECBF nowrap><font face=$fontface size=$fontsize><a href=\"$PHP_SELF?cl_m=&cl_y=\" style=\"color: blue\">$today_is</a> ".date("D j F, Y")."</font></td></tr>\n"; echo "</table>\n";
?>
</body> </html> 还有不足的地方请大家多多指教!
|
|