// temporarily Report all PHP errors for debugging //error_reporting(E_ALL); //echo 'testing'; //ini_set('error_reporting', E_ALL); //echo ini_get('display_errors'); //if (!ini_get('display_errors')) { // ini_set('display_errors', 1); //} // echo ini_get('display_errors'); include ("green_connect.php"); green_connect () or exit (); //*******************************************************toggle test/production photo directory //$photo_path = 'https://www.smith.edu/green/calendarphotos/'; $photo_path = 'https://www.smith.edu/ceeds/calendarphotos/'; if (!isset($_GET['weekof']) && !isset($_POST['weekof'])) //determine current week's days { for ($i=0;$i<6;$i++) //count back until monday { $firstdayofweek=date('Y-m-d'); if (date('D',strtotime("$firstdayofweek -$i DAYS"))=='Mon') $firstdayofweek=date('Y-m-d',strtotime("$firstdayofweek -$i DAYS")); } } else //set up other weeks date if request was from page { $tempdate=(!$_GET['weekof']?$_POST['weekof']:$_GET['weekof']); //use either post from dropdown or get from next/prev links $firstdayofweek =htmlentities($tempdate,ENT_QUOTES); //use date from $prevweek or $nextweek get or post, don't allow any html, etc here. } for ($i=0;$i<3;$i++) //fill array with dates of week start and end { $weekdate[$i]=date('Y-m-d',strtotime("$firstdayofweek +$i WEEKS")); //first day (Monday) of current week $weekend[$i]=date('Y-m-d',strtotime("$firstdayofweek +$i WEEKS +6 DAYS")); //last day (Sunday) of current week if (date('F',strtotime("$firstdayofweek +$i WEEKS"))!=date('F',strtotime("$firstdayofweek +$i WEEKS +6 DAYS"))) //second day in new month { $weeklabel[$i]=date('F j',strtotime("$firstdayofweek +$i WEEKS")).'-'.date(' M j',strtotime("$firstdayofweek +$i WEEKS +6 DAYS")); } else //both dates in same month { $weeklabel[$i]=date('F j',strtotime("$firstdayofweek +$i WEEKS")).'-'.date('j',strtotime("$firstdayofweek +$i WEEKS +6 DAYS")); } //query data, order to show item with photo first, match primary or alt dates $query="SELECT item_abstract, headline, url, item_photo, cal_date, alt_date_1, alt_date_2, alt_date_3, alt_date_4, ". " category, location, start_time, end_time, text_date, ". " IF(cal_date >= '".$weekdate[$i]."' AND cal_date <= '".$weekend[$i]."',cal_date,". " IF(alt_date_1 >= '".$weekdate[$i]."' AND alt_date_1 <= '".$weekend[$i]."',alt_date_1,". " IF(alt_date_2 >= '".$weekdate[$i]."' AND alt_date_2 <= '".$weekend[$i]."',alt_date_2,". " IF(alt_date_3 >= '".$weekdate[$i]."' AND alt_date_3 <= '".$weekend[$i]."',alt_date_3,". " IF(alt_date_4 >= '".$weekdate[$i]."' AND alt_date_4 <= '".$weekend[$i]."',alt_date_4,cal_date))))) AS sort_date ". " FROM green_calendar ". " WHERE (cal_date >= '".$weekdate[$i]."' AND cal_date <= '".$weekend[$i]."')". " OR (alt_date_1 >= '".$weekdate[$i]."' AND alt_date_1 <= '".$weekend[$i]."')". " OR (alt_date_2 >= '".$weekdate[$i]."' AND alt_date_2 <= '".$weekend[$i]."')". " OR (alt_date_3 >= '".$weekdate[$i]."' AND alt_date_3 <= '".$weekend[$i]."')". " OR (alt_date_4 >= '".$weekdate[$i]."' AND alt_date_4 <= '".$weekend[$i]."')". " ORDER BY IF(category='Featured Event',0,1), category ASC, sort_date ASC, start_time ASC, headline ASC"; $result=mysql_query($query) or die("Data is not currently available."); $r=0; $html[$i]=''; $curr_header=''; $category=''; while ($row=mysql_fetch_assoc($result)) //cycle through items for this date, add to array { $date_list=''; $temp_date=''; //show photo if there is one if($row['item_photo'])$html[$i].='
'.$row['category'].'
'; $category = $row['category']; } //show headline if($row['headline'])$html[$i].=''.$row['headline'].'
';
//get list of dates in current week for current event
$temp_date=strtotime($row['cal_date']);
if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
';
$temp_date=strtotime($row['alt_date_1']);
if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
';
$temp_date=strtotime($row['alt_date_2']);
if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
';
$temp_date=strtotime($row['alt_date_3']);
if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
';
$temp_date=strtotime($row['alt_date_4']);
if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
';
//show date(s) - use alt text if present
if ($row['text_date'])
{
$html[$i].=''.$row['text_date'].'
';
}
else
{
$html[$i].=''.$date_list.'';
}
//show abstract
$html[$i].=$row['item_abstract'].'
';
//show url link
if($row['url'])$html[$i].='More...
';
//show location
if($row['location'])$html[$i].=''.$row['location'].'
';
//show time
$times=($row['start_time'] && $row['start_time']!='00:00:00'?date("g:i a", strtotime($row['start_time'])):'').($row['end_time'] && $row['end_time']!='00:00:00'?' to '.date("g:i a", strtotime($row['end_time'])):'');
if($times)$html[$i].=''.$times.'
';
$html[$i].='
No events added yet.
View all events.