<?php
/*
*
* @package phpBB3
* @version 3.0
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @Original MOD Authors: John Peskens
* @http://john-peskens.nl
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// Datum in het verleden
header("Last-Modified: " .
gmdate("D, d M Y H:i:s") .
" GMT");
// Altijd veranderd
header("Cache-Control: no-store, no-cache, must-revalidate");
// HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0",
false);
header("Pragma: no-cache");
// HTTP/1.0
$output = '';
if ((!isset($_GET['month']) ||
$_GET['month'] ==
'') && (!isset($_GET['year']) ||
$_GET['year'] ==
''))
{
$maand =
date('n',
$time);
} else
{
$maand =
intval($_GET['month']);
$jaar =
intval($_GET['year']);
}
$phpbb_root_path =
(defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH :
'../forum/';
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$user->setup();
function getMonthlyEvents($jaar, $maand)
{
$sql = "SELECT cid, color FROM ".$table_prefix."calendar_categories ORDER BY cid ASC";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$categorie[] = $row;
}
$theFirst = "$jaar-$maand-01"; // the first of the month in YYYY-MM-01 format for SQL
$theFirstTs =
mktime(0, 0, 0,
$maand,
1,
$jaar);
// the first as a UNIX timestamp
$firstInfo =
getdate($theFirstTs);
// date info for the first
$nDays =
date('t',
$theFirstTs);
// how many days this month
$lastDay =
sprintf('%04d-%02d-%02d',
$jaar,
$maand,
$nDays);
$sql = "SELECT eid, title, startdate, days, categorie FROM ".$table_prefix."calendar_events WHERE
(startdate >= '".$theFirst."' AND startdate <= '".$lastDay."' AND activ = 1)
order by startdate asc, days desc";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if (isset($start) && $start ==
$row['startdate'])
{
$title .= "\n\r".$row['title'];
} else
{
$title = $row['title'];
}
$start = $row['startdate'];
$startDay = $startInfo['mday'];
$eventId =
intval($row['eid']);
for($i = 0; $i < $row['days']; $i++)
{
$ts =
mktime(0, 0, 0,
$maand,
$startDay +
$i,
$jaar);
if ($ts == $startTs)
{
$events[$startDay + $i]['title'] = $title;
$events[$startDay + $i]['color'] = $categorie[$row['categorie']-1]['color'];
$events[$startDay + $i]['eid'] = $row['eid'];
$startTs =
mktime(0, 0, 0,
$maand,
($startDay +
$i +
1),
$jaar);
}
}
}
return $events;
}
if (1 == 1)
{
$start = $date['wday']+1;
for ($i = 1; $i <= 12; $i++)
{
$month_aray +=
array($i =
> $user-
>lang['datetime'][date('F',
mktime(1, 0, 0,
(int
)$i,
1,
2008))]);
}
$name = $month_aray[$maand];
$year2 = $date['year'];
$offset = $days + $start - 1;
if($maand == 12)
{
$next = 1;
$nexty = $jaar + 1;
} else
{
$next = $maand + 1;
$nexty = $jaar;
}
if ($maand == 1)
{
$prev = 12;
$prevy = $jaar - 1;
} else
{
$prev = $maand - 1;
$prevy = $jaar;
}
if ($offset <= 28) $weeks = 28;
elseif ($offset > 35) $weeks = 42;
else $weeks = 35;
$output .= '<table cellpadding="2" cellspacing="1" align="center" style="width: 140px; height: 110px"><tr><td colspan="7"><table border="0" width="100%"><tr><td valign="middle"><a href="javascript:navigate('.$prev.','.$prevy.')"><img src="/Calendar/left.gif" border="0"></a><a href="javascript:navigate("","")"><img src="/Calendar/center.gif" hspace="3" border="0"></a><a href="javascript:navigate('.$next.','.$nexty.')"><img src="/Calendar/right.gif" border="0"></a></td><td align="right"><div id="heading">'.$name.' '.$year2.'</div></td></tr></table></td></tr><tr>';
$weekday =
date('w',
mktime(4, 0, 0,
2 ,
21,
2008));
for ($i = -$weekday; $i < 7 - $weekday; $i++)
{
$day_aray +=
array($i +
$weekday =
> $user-
>lang['datetime'][date('D',
mktime(4, 0, 0,
2,
(21 +
$i),
2008))]);
}
for ($i = 0; $i < 7; $i++)
{
$output .= '<td align="center" style="width: 14%">'.$day_aray[$i].'</td>';
}
$output .= '</tr>';
$col=1;
$cur=1;
$next=0;
$events = getMonthlyEvents($jaar, $maand);
for ($i = 1; $i <= $weeks; $i++)
{
if ($next == 3) $next = 0;
if ($col == 1) $output .= '<tr>';
$output .= '<td valign="top" align="center" ';
if (isset($events[$cur]['title'])) $output .=
'title="'.
$events[$cur]['title'].
' "';
$output .= '>';
if ($i <= ($days+($start-1)) && $i >= $start)
{
$output .='<div';
if (($cur == $today['mday']) && ($maand == $today['mon']) && ($jaar == $today['year']))
{
$output .= ' style="color:#FF0000;';
if (isset($events[$cur]['title']) && $cur ==
$today['mday']) $output .=
' border-width: 1px; border-style: solid; border-color: #737475;';
if (isset($events[$cur]['title']) && $cur !=
$today['mday']) $output .=
' style="border-width: 1px; border-style: solid; border-color: #737475;';
$output .= '"';
}
$output .= '>';
$output .= '<b';
if (isset($events[$cur]['title'])) $output .=
' style="cursor: hand; color: #'.
$events[$cur]['color'].
';"';
$output .= '>';
$output .= $cur;
$output .= '</b>';
$output .= '</div></td>';
$cur++;
$col++;
} else
{
$output .= ' </td>';
$col++;
}
if ($col == 8)
{
$output .= '</tr>';
$col = 1;
}
}
$output .= '</table>';
}
?>