site_footer(); exit; } // Beginning and end of this month $bom = mktime(0, 0, 1, $cm, 1, $cy); $eom = mktime(0, 0, 1, $cm + 1, 0, $cy); // Link to previous month (but do not link to too early dates) $lm = mktime(0, 0, 1, $cm, 0, $cy); if (valid_year(date("Y", $lm))) { $prev_link = '<a href="/cal.php' . strftime('?cm=%m&cy=%Y">%B, %Y</a>', $lm); } else { $prev_link = ' '; } // Link to next month (but do not link to too early dates) $nm = mktime(0, 0, 1, $cm + 1, 1, $cy); if (valid_year(date("Y", $nm))) { $next_link = '<a href="/cal.php' . strftime('?cm=%m&cy=%Y">%B, %Y</a>', $nm); } else { $next_link = ' '; } // Print out navigation links for previous and next month echo '<br /><table id="calnav" width="100%" border="0" cellspacing="0" cellpadding="3">', "\n<tr>", '<td align="left" width="33%">', $prev_link, '</td>', '<td align="center" width="33%">', strftime('<b>%B, %Y</b></td>', $bom), '<td align="right" width="33%">', $next_link, "</td></tr>\n</table>\n"; // Begin the calendar table echo '<table id="cal" width="100%" border="1" cellspacing="0" cellpadding="3">', "\n", '<tr>', "\n"; // Print out headers for weekdays for ($i = 0; $i < 7; $i++) { echo '<th width="14%">', date("l", mktime(0, 0, 1, 4, $i + 1, 2001)), "</th>\n"; } echo "</tr>\n<tr>"; // Generate the requisite number of blank days to get things started for ($days = $i = date("w", $bom); $i > 0; $i--) {
function format_date($dd, $mm, $yy) { $date = FALSE; $dd = trim($dd); $mm = trim($mm); $yy = trim($yy); if ($dd == '' && $mm == '' && $yy == '') { $date = NULL; } elseif (valid_year($yy) >= $GLOBALS['conf']['lowest_possible_year'] && $mm && $mm < 13 && $dd && $dd < 32) { $yy = valid_year($yy); $mm = $mm < 10 ? substr("0" . $mm, -2) : $mm; $dd = $dd < 10 ? substr("0" . $dd, -2) : $dd; $date = "{$yy}-{$mm}-{$dd}"; } return $date; }