Viewing file: block_calendar.php (4.38 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/***********************************************************************
- MemHT Portal -
Copyright (c) 2007 by Miltenovik Manojlo
http://www.memht.com
License:
Creative Commons Attribution-ShareAlike 3.0 License
http://creativecommons.org/licenses/by-sa/3.0/
***********************************************************************/
if (stristr(htmlentities($_SERVER['PHP_SELF']), "block_calendar.php")) {
header("Location: ../index.php");
die();
}
global $dblink,$tzNOW;
$dblink->query("DELETE FROM memht_calendar_events WHERE date < ($tzNOW - INTERVAL 30 DAY)");
?>
<style type="text/css">
.cal_uni { color:#333333; }
.cal_sat { color:#FF9900; }
.cal_sun { color:#FF6600; }
.cal_now { color:#FFFFFF; font-weight:bold; background-color:#FF9900; }
.cal_now a { color:#FFFFFF; }
.cal_now a:visited { color:#FFFFFF;}
.cal_evt { background-color:#DDDDDD; }
</style>
<?php
$n_day = date('j'); //Day
$n_month = (isset($_POST['calmonth'])) ? intval($_POST['calmonth']) : date('n') ; //Month
$n_year = (isset($_POST['calyear'])) ? intval($_POST['calyear']) : date('Y') ; //Year
$fdm_stamp = mktime(0,0,0,$n_month,1,$n_year); //First day of the month stamp
$fdm_day = date('w',$fdm_stamp); //Week number day of the first day of the month (1=Mon,2=Tue,3=Wed,4=Thu,5=Fri,6=Sat,0=Sun)
switch ($fdm_day) {
case 1: $offset = 0; break;
case 2: $offset = 1; break;
case 3: $offset = 2; break;
case 4: $offset = 3; break;
case 5: $offset = 4; break;
case 6: $offset = 5; break;
case 0: $offset = 6; break;
}
$now_stamp = mktime(0,0,0,$n_month,$n_day,$n_year); //Actual stamp
$days = date('t',$now_stamp); //Days in this month
$prev_year = ($n_month==1) ? $n_year-1 : $n_year ;
$next_year = ($n_month==12) ? $n_year+1 : $n_year ;
$prev_month = $n_month-1;
if ($prev_month<1) { $prev_month = 12; }
$next_month = $n_month+1;
if ($next_month>12) { $next_month = 1; }
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0' class='box'>\n";
echo "<td width='1'><form name='prev' action='#calendarevents' method='post'><input type='image' src='images/left.gif'><input type='hidden' name='calmonth' value='$prev_month'><input type='hidden' name='calyear' value='$prev_year'></form></td>\n";
echo "<td align='center'><a name='calendarevents'><b>".numToMonth($n_month)." $n_year</b></a></td>\n";
echo "<td width='1'><form name='next' action='#calendarevents' method='post'><input type='image' src='images/right.gif'><input type='hidden' name='calmonth' value='$next_month'><input type='hidden' name='calyear' value='$next_year'></form></td>\n";
echo "</table>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='center' width='14%'><b>".substr(_MON_,0,1)."</b></td>\n";
echo "<td align='center' width='14%'><b>".substr(_TUE_,0,1)."</b></td>\n";
echo "<td align='center' width='14%'><b>".substr(_WED_,0,1)."</b></td>\n";
echo "<td align='center' width='14%'><b>".substr(_THU_,0,1)."</b></td>\n";
echo "<td align='center' width='14%'><b>".substr(_FRI_,0,1)."</b></td>\n";
echo "<td align='center' width='14%' class='cal_sat'><b>".substr(_SAT_,0,1)."</b></td>\n";
echo "<td align='center' width='14%' class='cal_sun'><b>".substr(_SUN_,0,1)."</b></td>\n";
echo "</tr>\n";
for ($i=1;$i<=$days;$i++) {
$w_stamp = mktime(0,0,0,$n_month,$i,$n_year);
$w_day = date('w',$w_stamp);
if ($w_day==1) { echo "<tr>\n"; }
while ($offset>0) {
$offset--;
echo "<td> </td>\n";
}
switch ($w_day) {
case 6: $class = "cal_sat"; break;
case 0: $class = "cal_sun"; break;
default: $class = "cal_uni"; break;
}
$itxt = $i;
if ($result = $dblink->get_list("SELECT title FROM memht_calendar_events WHERE YEAR(date)=$n_year AND MONTH(date) = $n_month AND DAYOFMONTH(date) = $i")) {
$class = "cal_evt";
$events = "";
foreach ($result as $row) { $events .= "<div>".outCode($row['title'])."</div>"; }
$itxt = "<a href='index.php?page=calendar&op=events&year=$n_year&month=$n_month&day=$i' title=\"header=[Events] body=[$events]\">$itxt</a>";
}
if ($n_year==date('Y') AND $n_month==date('n') AND $i==$n_day) { $class = "cal_now"; }
echo "<td align='center' class='$class'>$itxt</td>\n";
if ($w_day==0) { echo "</tr>\n"; }
}
echo "</table>";
?>
|