";
$numFound = 0;
$numDaysTested = 0;
$ulmonth = date("m");
$ulmonth++;
$ulmonth--;
$ulyear = date("Y");
$ulday = date("d");
$ulday++;
$ulday--;
global $dbi, $user_prefix;
$caloptions = sql_query("SELECT * FROM ".$user_prefix."_calendar_options WHERE 1", $dbi);
$caloptionrow = sql_fetch_array($caloptions, $dbi);
$maxFound = $caloptionrow[show_n_events];
$maxDaysTested = $caloptionrow[in_n_days];
function DisplayEventsCategory($myrow)
{
global $user_prefix, $dbi;
$result = sql_query("SELECT * FROM ".$user_prefix."_calendar_categories WHERE id='$myrow[categoryid]'", $dbi);
$rtnVal = 0;
$catrow = sql_fetch_array($result, $dbi);
return $catrow[showinblock];
}
function DisplayInfo($ulmonth, $ulday, $ulyear, $myrow)
{
$rtnVal = "";
$rtnVal .= "
"
. "" . GetMonthDayText($ulmonth, $ulday) . " "
. " | "
. "" . PrintShortEvent($myrow, $ulmonth, $ulday, $ulyear).""
. " |
";
return $rtnVal;
}
while ($numFound < $maxFound && $numDaysTested < $maxDaysTested) {
$uldayofweek = date("w", mktime(0, 0, 0, $ulmonth, $ulday, $ulyear));
if ($caloptionrow[show_bydate_in_block] == 1) {
$resultID = Calendar_GetByDate($ulmonth, $ulday, $ulyear);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
for ($k=0;$k<$nr;$k++)
{
$myrow = sql_fetch_array($resultID, $dbi);
if ($numFound < $maxFound) {
if (DisplayEventsCategory($myrow)) {
//@RJR-Pwmg@Rncvkpwo@-@Eqratkijv@(e)@VgejIHZ.eqo
$content.= DisplayInfo($ulmonth, $ulday, $ulyear, $myrow);
$numFound++;
}
}
}
}
}
if ($caloptionrow[show_yearly_in_block] == 1) {
$resultID = Calendar_GetYearly($ulmonth, $ulday);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
for ($k=0;$k<$nr;$k++)
{
$myrow = sql_fetch_array($resultID, $dbi);
if ($numFound < $maxFound) {
if (DisplayEventsCategory($myrow)) {
$content.= DisplayInfo($ulmonth, $ulday, $ulyear, $myrow);
$numFound++;
}
}
}
}
}
if ($caloptionrow[show_yearly_recurring_in_block] == 1) {
$resultID = Calendar_GetYearlyRecurring($ulmonth, $uldayofweek);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
for ($k=0;$k<$nr;$k++)
{
$myrow = sql_fetch_array($resultID, $dbi);
$test = $ulday / 7;
$period = $myrow[recur_period];
if ($period == 5)
$period = NumDotWInMonth($uldayofweek, $ulmonth, $ulyear);
$periodlow = $period - 1;
if ($test <= $period && $test > $periodlow) {
if ($numFound < $maxFound) {
if (DisplayEventsCategory($myrow)) {
$content .= DisplayInfo($ulmonth, $ulday, $ulyear, $myrow);
$numFound += 1;
}
}
} else if ($period == 5 && $test >= 4 && $day+7 < NumDaysInMonth($month, $year)) {
if ($test <= ($period-1) && $test > ($periodlow-1)) {
if ($numFound < $maxFound) {
if (DisplayEventsCategory($myrow)) {
$content .= DisplayInfo($ulmonth, $ulday, $ulyear, $myrow);
$numFound += 1;
}
}
}
}
}
}
}
if ($caloptionrow[show_monthly_in_block] == 1) {
$resultID = Calendar_GetMonthly($ulday);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
for ($k=0;$k<$nr;$k++)
{
$myrow = sql_fetch_array($resultID, $dbi);
if ($numFound < $maxFound) {
if (DisplayEventsCategory($myrow)) {
$content.= DisplayInfo($ulmonth, $ulday, $ulyear, $myrow);
$numFound++;
}
}
}
}
}
if ($caloptionrow[show_monthly_recurring_in_block] == 1) {
$resultID = Calendar_GetMonthlyRecurring($uldayofweek);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
for ($k=0;$k<$nr;$k++)
{
$myrow = sql_fetch_array($resultID, $dbi);
$period = $myrow[recur_period];
if ($period == 5)
$period = NumDotWInMonth($uldayofweek, $ulmonth, $ulyear);
$test = $ulday / 7;
$periodlow = $period - 1;
if ($test <= $period && $test > $periodlow)
{
if ($numFound < $maxFound) {
if (DisplayEventsCategory($myrow)) {
$content.= DisplayInfo($ulmonth, $ulday, $ulyear, $myrow);
$numFound += 1;
}
}
}
}
}
}
if ($caloptionrow[show_weekly_in_block] == 1) {
$resultID = Calendar_GetWeekly($uldayofweek);
if ($resultID) {
$nr = sql_num_rows($resultID, $dbi);
for ($k=0;$k<$nr;$k++)
{
$myrow = sql_fetch_array($resultID, $dbi);
if ($numFound < $maxFound) {
if (DisplayEventsCategory($myrow)) {
$content.= DisplayInfo($ulmonth, $ulday, $ulyear, $myrow);
$numFound++;
}
}
}
}
}
NextDay($ulmonth, $ulday, $ulyear);
$numDaysTested += 1;
}
$content .= "";
?>