Location: PHPKode > projects > SiteX > calendar.php
<?PHP
ob_start();
session_start();
include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");
protectComponentPage(8);

if(!$sxMonth)
{
	$sxMonth = date("m");
	$sxYear = date("Y");
}
if($sxMonth < 12)
{
	$sxNextMonth = $sxMonth + 1;
	$sxNextYear = $sxYear;
}
else
{
	$sxNextMonth = 1;
	$sxNextYear = $sxYear + 1;
}

if($sxMonth == 1)
{
	$sxLastMonth = 12;
	$sxLastYear = $sxYear - 1;
}
else
{
	$sxLastMonth = $sxMonth - 1;
	$sxLastYear = $sxYear;
}

$sxTitleAddendum = getComponentName("8");
include("themes/$THEME_FOLDER/header.php");
?>
  <div class="bodyWrapper">
	<h1><?PHP echo getComponentName("8"); ?></h1>
	<?PHP if((userAdmin()) OR ((userEditor()) AND ($sxSetup['EditorRightsEventsAdd'])))
	echo '<div class="journalAdd"><a href="admin/event_add.php">' .$sxLang['EventButtonAddEventNew'] . '</a></div>'; 
	?>
	<table border="0" cellpadding="5" cellspacing="2" width="<?PHP echo $sxThemeConfig['ContentWidth']-20; ?>" align="center">
	  <tr>
		<td align="left" width="<?PHP echo $sxThemeConfig['ContentWidth']-20/4; ?>"><a href="<?PHP echo $PHP_SELF."?sxMonth=$sxLastMonth&sxYear=$sxLastYear"; ?>">< <?PHP echo $sxLang['Prev']; ?></a></td>
		<td align="center" width="<?PHP echo $sxThemeConfig['ContentWidth']-20/2; ?>"><strong><?PHP

		$sxMonthString = date("F", mktime(0,0,0,$sxMonth,1,$sxYear));
		foreach($sxMonths as $sxKey => $sxValue)
			$sxMonthString = str_replace($sxKey, $sxValue, $sxMonthString);
		
		echo $sxMonthString.' '.$sxYear;

		?></strong></td>
		<td align="right" width="<?PHP echo $sxThemeConfig['ContentWidth']-20/4; ?>"><a href="<?PHP echo $PHP_SELF."?sxMonth=$sxNextMonth&sxYear=$sxNextYear"; ?>"><?PHP echo $sxLang['Next']; ?> ></a></td>
	  </tr>
	  <tr>
		<td colspan="3">
		  <table border="0" cellpadding="5" cellspacing="1" width="100%" class="eventCalendar">
			<tr>
			  <?PHP if($sxSetup['FirstDayOfWeek'] == 0) echo '<td class="tableColumn">'.$sxDaysShort['Sun'].'</td>'; ?>
			  <td class="tableColumn"><?PHP echo $sxDaysShort['Mon']; ?></td>
			  <td class="tableColumn"><?PHP echo $sxDaysShort['Tue']; ?></td>
			  <td class="tableColumn"><?PHP echo $sxDaysShort['Wed']; ?></td>
			  <td class="tableColumn"><?PHP echo $sxDaysShort['Thu']; ?></td>
			  <td class="tableColumn"><?PHP echo $sxDaysShort['Fri']; ?></td>
			  <td class="tableColumn"><?PHP echo $sxDaysShort['Sat']; ?></td>
			  <?PHP if($sxSetup['FirstDayOfWeek'] == 1) echo '<td class="tableColumn">'.$sxDaysShort['Sun'].'</td>'; ?>
			</tr>
			<?PHP
			echo '<tr>';
			
			$sxFirstDay = date("w", mktime(0, 0, 0, $sxMonth, 1, $sxYear));
			if($sxSetup['FirstDayOfWeek'] == 1)
			{
				if($sxFirstDay > 0)
					$sxFirstDay = $sxFirstDay-1;
				else
					$sxFirstDay = 6;
			}

			$sxCounter = 0;
			if ($sxCounter < $sxFirstDay)
				echo '<tr>'."\n";
			while ($sxCounter < $sxFirstDay)
			{
				echo '<td class="eventBlankDays" valign="top" height="100" width="' . (($sxThemeConfig['ContentWidth']-20)/7) . '" align="center">&nbsp;</td>' . "\n";
				$sxCounter++;
			}
			$sxDay = 1;
			$sxDayWeekCount = 1;
			$sxContinue = true;
			while($sxContinue)
			{
				if(checkdate($sxMonth, $sxDay, $sxYear))
				{
					$sxDayStart = mktime(0,0,0,$sxMonth,$sxDay,$sxYear);
					$sxDayEnd = mktime(23,59,59,$sxMonth,$sxDay,$sxYear);
					
					if($sxSetup['FirstDayOfWeek'] == 1)
					{
						if(date("w", mktime(0,0,0,$sxMonth,$sxDay,$sxYear)) == 1)
							echo '<tr>';
					}
					else
					{
						if(date("w", mktime(0,0,0,$sxMonth,$sxDay,$sxYear)) == 0)
							echo '<tr>';
					}
					
					echo '<td valign="top" height="100" width="' . (($sxThemeConfig['ContentWidth']-20)/7) . '" class="';
					if($sxDayStart == mktime(0,0,0,date("m"),date("d"),date("y")))
						echo 'eventTodayColor';
					else
						echo 'eventOffdayColor';
					echo '"><a href="calendar_day.php?sxTimestamp=' . $sxDayStart . '">' . $sxDay . '</a><br />';
					
					$query = "SELECT * FROM $DB_Events 
							  WHERE ((start_timestamp >= '$sxDayStart' AND end_timestamp <= '$sxDayEnd') OR 
									(start_timestamp <= '$sxDayEnd' AND end_timestamp >= '$sxDayEnd') OR 
									(end_timestamp >= '$sxDayStart' AND end_timestamp <= '$sxDayEnd')) AND
									active='1'
							  ORDER BY start_timestamp ASC";
					$result = mysql_query($query, $Link) or queryError("71", mysql_error());			
					while($ROW = mysql_fetch_object($result))
					{
						if(eventAccess($ROW->id))
							echo '-<a href="calendar_day.php?sxTimestamp=' . $sxDayStart . '#' . $ROW->id . '" style="font-size:9px;">' . $ROW->shortname.'</a><br />';
					}
					
					echo '</td>' . "\n";
					
					if($sxSetup['FirstDayOfWeek'] == 1)
					{
						if(date("w", mktime(0,0,0,$sxMonth,$sxDay,$sxYear)) == 0)
						{
							echo '</tr>';
							$sxDayWeekCount = 0;
						}
					}
					else
					{
						if(date("w", mktime(0,0,0,$sxMonth,$sxDay,$sxYear)) == 6)
						{
							echo '</tr>';
							$sxDayWeekCount = 0;
						}
					}
					
					$sxDay++;
					$sxDayWeekCount++;
				}
				else
				{
					$sxContinue = false;
					if($sxDayWeekCount > 1)
					{
						while($sxDayWeekCount <= 7)
						{
							echo '<td class="eventBlankDays" align="center">&nbsp;</td>'."\n";
							$sxDayWeekCount++;
						}
						echo '</tr>'."\n";
					}
				}
			}
			?>
		  </table>
		</td>
	  </tr>
	  <tr>
		<td><a href="calendar_events.php"><?PHP echo $sxLang['EventSwitchToList']; ?></a></td>
	  </tr>
	</table>
  </div>
<?PHP
include("themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX