<?php
Class calendar{
/*
* Calendar
*
* @ Author: sports98
* email:flyruns@hotmail.com
* @ Version: V1.0
*/
var $YEAR, $MONTH, $DAY;
var $WEEK =array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var $_month=array (
"=>", "January",
"=>", "February",
"=>", "March",
"=>", "April",
"=>", "May",
"=>", "June",
"=>", "July",
"=>", "August",
"=>", "September",
"Ten" => "October",
"One" => "November",
"=>", "December"
);
Set year
function Setyear ($year) {
$this->year= $year;
}
Get year
function getyear () {
return $this->year;
}
Set month
function Setmonth ($month) {
$this->month= $month;
}
Get month
function GetMonth () {
return $this->month;
}
Set Date
function Setday ($day) {
$this->day= $day;
}
Date of acquisition
function Getday () {
return $this->day;
}
Print Calendar
function out () {
$this->_env ();
$week = $this->getweek ($this->year, $this->month, $this->day);//date of day of day (for example, 2003-07-18, Friday)
$fweek = $this->getweek ($this->year, $this->month,1);//Get the first day of the month for the week
echo "<div style=\" margin:0;border:1 solid black;width:300;font:9pt\ ">
<form action=$_server[php_self] method=\ "post\" style=\ "margin:0\" >
<select name=\ "month\" onchange=\ "This.form.submit ();" > ";
For ($ttmpa =1 $ttmpa <13; $ttmpa + +) {//print 12 months
$TTMPB =sprintf ("%02d", $ttmpa);
if (strcmp ($TTMPB, $this->month) ==0) {
$select = "Selected Style=\" Background-color: #c0c0c0 \ "";
}else{
$select = "";
}
echo "<option value=\" $TTMPB \ "$select >". $this->_month[$TTMPB]. " </option>\r\n ";
}
echo "</select> <select name=\" year\ "onchange=\" this.form.submit (); \ ">";//print year, 10 years before and after
for ($ctmpa = $this->year-10; $ctmpa < $this->year+10; $ctmpa + +) {
if ($ctmpa >2037) {
Break
}
if ($ctmpa <1970) {
Continue
}
if (strcmp ($ctmpa, $this->year) ==0) {
$select = "Selected Style=\" Background-color: #c0c0c0 \ "";
}else{
$select = "";
}
echo "<option value=\" $ctmpa \ "$select > $ctmpa </option>\r\n";
}
echo "</select>
</form>
<table border=0 align=center> ";
For ($Tmpa =0 $Tmpa <count ($this->week); $Tmpa + +) {//Print week header
echo "<td>" $this->week[$Tmpa];
}
For ($TMPB =1 $Tmpb <=date ("T", Mktime (0,0,0, $this->month, $this->day, $this->year)); $TMPB + +) {//Print all dates
if (strcmp ($TMPB, $this->day) ==0) {//Get current date, Mark
$flag = "bgcolor= ' #ff0000 '";
}else{
$flag = ' bgcolor= #ffffff ';
}
if ($TMPB ==1) {
echo "<tr>"; Supplemental printing
for ($TMPC =0; $Tmpc < $fweek; $TMPC + +) {
echo "<td>";
}
}
if (strcmp ($this->getweek ($this->year, $this->month, $TMPB), 0) ==0) {
echo "<tr><td align=center $flag > $TMPB";
}else{
echo "<td align=center $flag > $TMPB";
}
}
echo "</table></div>";
}
Gets the number of weeks of the date specified in the method
function Getweek ($year, $month, $day) {
$week =date ("W", Mktime (0,0,0, $month, $day, $year));/Get Week
return $week//Get a week
}
function _env () {
if (Isset ($_post[month])) {//There is a specified month
$month =$_post[month];
}else{
$month =date ("M"); Default for this month
}
if (Isset ($_post[year])) {//There is an indication of the year
$year =$_post[year];
}else{
$year =date ("Y"); Default for this year
}
$this->setyear ($year);
$this->setmonth ($month);
$this->setday (Date ("D"));
}
}
$D =new Calendar;
$D->out ();
?>