Calendar

Sweet Briar Master Events Calendar go to current month | print

[php]
session_start();
header(“Expires: Mon, 26 Jul 1997 05:00:00 GMT”);
header(“Last-Modified: ” . gmdate(“D, d M Y H:i:s”) . ” GMT”);
header(“Cache-Control: no-store, no-cache, must-revalidate”);
header(“Cache-Control: post-check=0, pre-check=0″, false);
header(“Cache-control: private”); // IE 6 Fix.
header(“Pragma: no-cache”);

$_SESSION['cats'] = (isset($_SESSION['cats']))? $_SESSION['cats'] : array();

$db = mysql_connect(“198.28.37.150:3306″, “ccohen”, “ta11a55ee”);
mysql_select_db(‘sbc_events2′,$db);

$daip = getenv(“REMOTE_ADDR”);
$ip = explode(“.”, $daip);
$oncampus = (($ip[0] = “198″ && $ip[1] = “28″) && ($ip[2] >= “32″ && $ip[2] <= "63"))? 1 : 0;
$audience =(!$oncampus)? "(audience NOT LIKE '%private%' AND audience LIKE '%public%') " : "audience NOT LIKE '%private%' ";
$search = (isset($_GET['search']))? "AND (title LIKE '%".$_GET['search']."%' OR summary LIKE '%".$_GET['search']."%') " : "";

$thedate = (isset($_GET['date']) && $_GET['date'] >= time()) ? date(“Y-m”, $_GET['date']): date(“Y-m”, time());
$unixdate = (isset($_GET['date']))? $_GET['date'] : time() ;

$searchdate = (!isset($_GET['search']))? “AND (day like ‘$thedate%’ AND day >= ‘”.date(“Y-m-d”, time()).”‘)” : ” AND day >= ‘”.date(“Y-m-d”, time()).”‘ “;
//$searchdate = (isset($_GET['calendar']))? “AND day >= ‘$thedate’” : “AND day BETWEEN ‘$thedate’ AND DATE_ADD(‘$thedate’, INTERVAL 30 DAY)”;
$calendar = (isset($_GET['calendar']))? ” AND calendar_id =’”.$_GET['calendar'].”‘” : “” ;
$FROM = (count($_SESSION['cats']))? ” FROM events, event_times, rooms, categories_events” : ” FROM events, event_times, rooms”;
$sql = “SELECT distinct events.id,title,summary,img_exists, unix_timestamp(event_times.day), TIME_FORMAT(start_time, ‘%l:%i %p’),TIME_FORMAT(end_time, ‘%l:%i %p’), rooms.id, rooms.name, map_number,status,userid $FROM WHERE events.id = event_times.event_id AND rooms.id = event_times.room_id AND admin_ok AND $audience$calendar$searchdate$search ORDER BY event_times.day, event_times.start_time”;
//echo $sql;
//die();
$result = mysql_query($sql,$db);

if (mysql_num_rows($result))
{
$caldata = array();
while ($myrow = mysql_fetch_row($result)) {
array_push($caldata,$myrow);
}
mysql_free_result($result);

/*foreach ($caldata as $i) {
print_r($i);
}*/
$theLastMonth = “”;
$theLastDay = “”;
echo “

\n”;

foreach ($caldata as $i)
{
$imgTag = ($i[3] != 0)? “” : ““;
$theDay = ““.date(‘d’, $i[4]).” | ”.strtoupper(date(‘D’, $i[4]));
$theMonth = ““.date(‘F’, $i[4]).”, ‘”.date(‘y’, $i[4]);
if ($theMonth != $theLastMonth)
{

echo “

\n”;
}
if ($theDay != $theLastDay)
{
echo “

\n”;
}
$theDescription = ($i[2])? strip_tags($i[2], ‘‘).”
” : “”;
$starttime = ($i[5] && ($i[7] != 1))? $i[5] : “”;
$endtime = ($i[6] && ($i[7] != 1))? ” – “.$i[6] : “”;
$endtime = (($i[6] == “36:00 AM”) && $endtime != “”)? ” – 12:00 AM” : $endtime;
$location = (($i[8] != “”) && ($i[7] != 1))? ” | “.$i[8] : “”;
$title = ($i[10] == 3)? “*** CANCELLED *** “.$i[1].”” : “$i[1]“;

$contact = (($i[11] != “”) && ($i[7] != 1))? ” | Contact“: “”;
if ($i[9] && $location != “”)
{
$location = ” | $i[8]“;
}
echo “

\n”;
$theLastMonth = ““.date(‘F’, $i[4]).”, ‘”.date(‘y’, $i[4]);
$theLastDay = ““.date(‘d’, $i[4]).” | ”.strtoupper(date(‘D’, $i[4]));
}
echo “

“.$theMonth.”
$theDay
$imgTag $title$theDescription$starttime$endtime$location$contact

\n”;
}
else
{
if (!isset($_GET['search']))
{
echo “

\n”;
echo “

\n”;
echo “

“.date(‘F’, $unixdate).”, ‘”.date(‘y’, $unixdate).”
There are no events scheduled for “.date(‘F’, $unixdate).”. Try paging through to another month using the calendar to the left or selecting a calendar in the \”other calendars\” list.

“;
}
else
{
echo “

\n”;
echo “

\n”;
echo “

 
Sorry, we didn’t find any events matching that search string. Try another search string, paging through to another month using the calendar to the left, or selecting a calendar in the \”other calendars\” list.

“;

}
}

[/php]