<?php
header("content-Type: text/html; charset=utf-8");
function calendar($MM='',$YYYY='',$id=''){
if($MM=="") $MM = date("m");
if($YYYY=="") $YYYY = date("Y");
if(checkdate($MM,1,$YYYY)){
$stringDate = strftime("%d %b %Y",mktime (0,0,0,$MM,1,$YYYY));
$days = strftime("%d",mktime (0,0,0,$MM+1,0,$YYYY));
$firstDay = strftime("%w",mktime (0,0,0,$MM,1,$YYYY));
$lastDay = strftime("%w",mktime (0,0,0,$MM,$days,$YYYY));
$printDays = $days;
$preMonth = strftime("%m",mktime (0,0,0,$MM-1,1,$YYYY));
$preYear = strftime("%Y",mktime (0,0,0,$MM-1,1,$YYYY));
$nextMonth = strftime("%m",mktime (0,0,0,$MM+1,1,$YYYY));
$nextYear = strftime("%Y",mktime (0,0,0,$MM+1,1,$YYYY));
$nowmm=$_GET["MM"]?$_GET["MM"]:date("m");
$nowyy=$_GET["YY"]?$_GET["YY"]:date("Y");
$nowday=$_GET["day"]?$_GET["day"]:date("d");
print("<table style=\"border:2px #4C82BE solid;border-radius:8px 8px 8px 8px; padding:5px;\" cellspacing=\"0\" cellpadding=\"0\">");
print("<tr><th valign=\"top\"><a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&MM=".$preMonth."&YY=".$preYear."&day=".$nowday."\">?</a></th>");
print("<th colspan=\"5\" valign=\"top\">".date("Y年m月",mktime (0,0,0,$MM,1,$YYYY))."</th>");
print("<th valign=\"top\"><a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&MM=".$nextMonth."&YY=".$nextYear."&day=".$nowday."\">?</a></th></tr>");
print("<tr style=\"font-family: Verdana; font-size:x-small\">");
print("<th> 日</th><th>一</th><th>二</th><th>三< /th><th>四</th><th>五</th><th>六< /th></tr>");
$currentDays = 1;
for($a=1;$a<=5;$a++){
print("<tr align=\"left\" valign=\"top\" style=\"font-family: Verdana; font-size:x-small\">");
$diffDays = $firstDay-$lastDay;
if($firstDay>$lastDay && $currentDays ==1 && ($diffDays<>1)){
for($x=$lastDay;$x>=0;$x--){
$printDays = $days-$x;
print("<td> $printDays 1</td>");
}
for($z=1;$z<$firstDay-$lastDay;$z++){
print("<td> </td>");
}
for($y=$firstDay;$y<7;$y++){
print("<td>$currentDays</td>");
$currentDays++;
}
} elseif($firstDay!=0 && $currentDays==1){
for($z=1;$z<=$firstDay;$z++){
print("<td> </td>");
}
for($y=$firstDay;$y<7;$y++){
print("<td><a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&MM=".$nowmm."&YY=".$nowyy."&day=".$currentDays."\">");
if($nowday==$currentDays){print("<strong>".$currentDays."</strong>");}else{print($currentDays);}
print("</a></td>");
$currentDays++;
}
} else {
for($u=1;$u<=7 && $currentDays<=$days;$u++){
print("<td><a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&MM=".$nowmm."&YY=".$nowyy."&day=".$currentDays."\">");
if($nowday==$currentDays){print("<strong>".$currentDays."</strong>");}else{print($currentDays);}
print("</a></td>");
$currentDays++;
}
}
print("</tr>");
}
print("</table>");
}
}
calendar($_GET['MM'],$_GET['YY']);
?>
header("content-Type: text/html; charset=utf-8");
function calendar($MM='',$YYYY='',$id=''){
if($MM=="") $MM = date("m");
if($YYYY=="") $YYYY = date("Y");
if(checkdate($MM,1,$YYYY)){
$stringDate = strftime("%d %b %Y",mktime (0,0,0,$MM,1,$YYYY));
$days = strftime("%d",mktime (0,0,0,$MM+1,0,$YYYY));
$firstDay = strftime("%w",mktime (0,0,0,$MM,1,$YYYY));
$lastDay = strftime("%w",mktime (0,0,0,$MM,$days,$YYYY));
$printDays = $days;
$preMonth = strftime("%m",mktime (0,0,0,$MM-1,1,$YYYY));
$preYear = strftime("%Y",mktime (0,0,0,$MM-1,1,$YYYY));
$nextMonth = strftime("%m",mktime (0,0,0,$MM+1,1,$YYYY));
$nextYear = strftime("%Y",mktime (0,0,0,$MM+1,1,$YYYY));
$nowmm=$_GET["MM"]?$_GET["MM"]:date("m");
$nowyy=$_GET["YY"]?$_GET["YY"]:date("Y");
$nowday=$_GET["day"]?$_GET["day"]:date("d");
print("<table style=\"border:2px #4C82BE solid;border-radius:8px 8px 8px 8px; padding:5px;\" cellspacing=\"0\" cellpadding=\"0\">");
print("<tr><th valign=\"top\"><a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&MM=".$preMonth."&YY=".$preYear."&day=".$nowday."\">?</a></th>");
print("<th colspan=\"5\" valign=\"top\">".date("Y年m月",mktime (0,0,0,$MM,1,$YYYY))."</th>");
print("<th valign=\"top\"><a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&MM=".$nextMonth."&YY=".$nextYear."&day=".$nowday."\">?</a></th></tr>");
print("<tr style=\"font-family: Verdana; font-size:x-small\">");
print("<th> 日</th><th>一</th><th>二</th><th>三< /th><th>四</th><th>五</th><th>六< /th></tr>");
$currentDays = 1;
for($a=1;$a<=5;$a++){
print("<tr align=\"left\" valign=\"top\" style=\"font-family: Verdana; font-size:x-small\">");
$diffDays = $firstDay-$lastDay;
if($firstDay>$lastDay && $currentDays ==1 && ($diffDays<>1)){
for($x=$lastDay;$x>=0;$x--){
$printDays = $days-$x;
print("<td> $printDays 1</td>");
}
for($z=1;$z<$firstDay-$lastDay;$z++){
print("<td> </td>");
}
for($y=$firstDay;$y<7;$y++){
print("<td>$currentDays</td>");
$currentDays++;
}
} elseif($firstDay!=0 && $currentDays==1){
for($z=1;$z<=$firstDay;$z++){
print("<td> </td>");
}
for($y=$firstDay;$y<7;$y++){
print("<td><a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&MM=".$nowmm."&YY=".$nowyy."&day=".$currentDays."\">");
if($nowday==$currentDays){print("<strong>".$currentDays."</strong>");}else{print($currentDays);}
print("</a></td>");
$currentDays++;
}
} else {
for($u=1;$u<=7 && $currentDays<=$days;$u++){
print("<td><a href=\"".$_SERVER['PHP_SELF']."?id=".$id."&MM=".$nowmm."&YY=".$nowyy."&day=".$currentDays."\">");
if($nowday==$currentDays){print("<strong>".$currentDays."</strong>");}else{print($currentDays);}
print("</a></td>");
$currentDays++;
}
}
print("</tr>");
}
print("</table>");
}
}
calendar($_GET['MM'],$_GET['YY']);
?>