/*
* ©2002 Proverbs, LLC. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it with the following stipulations:
* Changes or modifications must retain all Copyright statements, including, but not limited to the Copyright statement
* and Proverbs, LLC homepage link provided at the bottom of this page.
*/
require "layout.inc.php";
require ".dbaccess.inc";
if (!isset($month) || $month == "" || $month > 12 || $month < 1)
{
$month = date("m");
}
if (!isset($year) || $year == "" || $year < 1972 || $year > 2036)
{
$year = date("Y");
}
$timestamp = mktime(0, 0, 0, $month, 1, $year);
$current = date("F Y", $timestamp);
if ($month < 2)
{
$prevmonth = 12;
$prevyear = $year - 1;
}
else
{
$prevmonth = $month - 1;
$prevyear = $year;
}
if ($month > 11)
{
$nextmonth = 1;
$nextyear = $year + 1;
}
else
{
$nextmonth = $month + 1;
$nextyear = $year;
}
$backward = date("F Y", mktime(0, 0, 0, $prevmonth, 1, $prevyear));
$forward = date("F Y", mktime(0, 0, 0, $nextmonth, 1, $nextyear));
$first = date("w", mktime(0, 0, 0, $month, 1, $year));
$lastday = 28;
for ($i=$lastday;$i<32;$i++)
{
if (checkdate($month, $i, $year))
{
$lastday = $i;
}
}
function AddDay($fday, $fmonth, $fyear, $fvar)
{
if (!isset($fday) || $fday == "")
{
echo '
';
}
else
{
$schurl = 'schedule.php?day='.$fday.'&month='.$fmonth.'&year='.$fyear;
if (date("m") == $fmonth && date("Y") == $fyear && date("j") == $fday)
{
echo ' |
';
}
else
{
echo ' |
';
}
echo ' '.$fday.'
';
if (isset($fvar) && $fvar != "")
{
echo '
';
echo ' '.$fvar.'
';
}
}
echo ' |
';
}
function FillDay($caldb, $dayofweek, $dayofmonth, $thismonth, $thisyear)
{
$textbody = '';
$nr = $caldb->GetByDate($thismonth, $dayofmonth, $thisyear);
for ($k=0;$k<$nr;$k++)
{
$caldb->next_record();
$textbody.= $caldb->f('shortevent').'
';
}
$nr = $caldb->GetYearly($thismonth, $dayofmonth);
for ($k=0;$k<$nr;$k++)
{
$caldb->next_record();
$textbody.= $caldb->f('shortevent').'
';
}
$nr = $caldb->GetYearlyRecurring($thismonth, $dayofweek);
for ($k=0;$k<$nr;$k++)
{
$caldb->next_record();
$test = $dayofmonth / 7;
$periodlow = $caldb->f('period') - 1;
if ($test <= $caldb->f('period') && $test > $periodlow)
{
$textbody.= $caldb->f('shortevent').'
';
}
}
$nr = $caldb->GetMonthly($dayofmonth);
for ($k=0;$k<$nr;$k++)
{
$caldb->next_record();
$textbody.= $caldb->f('shortevent').'
';
}
$nr = $caldb->GetMonthlyRecurring($dayofweek);
for ($k=0;$k<$nr;$k++)
{
$caldb->next_record();
$test = $dayofmonth / 7;
$periodlow = $caldb->f('period') - 1;
if ($test <= $caldb->f('period') && $test > $periodlow)
{
$textbody.= $caldb->f('shortevent').'
';
}
}
$nr = $caldb->GetWeekly($dayofweek);
for ($k=0;$k<$nr;$k++)
{
$caldb->next_record();
$textbody.= $caldb->f('shortevent').'
';
}
return $textbody;
}
echo '
'.$calender_title.'
';
echo '
';
echo '
';
echo '
';
echo '
|
<< '.$backward.'
|
';
if (isset($calender_title_image) && $calender_title_image != '')
{
echo ' ';
}
else
{
echo ' '.$calender_title;
}
echo ' '.$current.'
|
'.$forward.' >>
|
|
';
if (isset($start_day) && $start_day <= 6 && $start_day >= 0)
{
$n = $start_day;
}
else
{
$n = 0;
}
for ($i=0;$i<7;$i++)
{
if ($n > 6)
{
$n = 0;
}
if ($n == 0)
{
echo '
Sunday
| ';
}
if ($n == 1)
{
echo '
Monday
| ';
}
if ($n == 2)
{
echo '
Tuesday
| ';
}
if ($n == 3)
{
echo '
Wednesday
| ';
}
if ($n == 4)
{
echo '
Thursday
| ';
}
if ($n == 5)
{
echo '
Friday
| ';
}
if ($n == 6)
{
echo '
Saturday
| ';
}
$n++;
}
echo'
';
$calday = 1;
while ($calday <= $lastday)
{
/* Alternate beginning day of the week for calendar view was created by Marion Heider of clixworx.net. */
echo '';
for ($j=0;$j<7;$j++)
{
if ($j == 0)
{
$n = $start_day;
}
else
{
if ($n < 6)
{
$n = $n + 1;
}
else
{
$n = 0;
}
}
if ($calday == 1)
{
if ($first == $n)
{
$info = FillDay($db, $n, $calday, $month, $year);
AddDay($calday, $month, $year, $info);
$calday++;
}
else
{
AddDay('', '', '', '');
}
}
else
{
if ($calday > $lastday)
{
AddDay('', '', '', '');
}
else
{
$info = FillDay($db, $n, $calday, $month, $year);
AddDay($calday, $month, $year, $info);
$calday++;
}
}
}
echo '
';
}
echo '
©2002 Proverbs, LLC. All rights reserved.
';
?>