From 9c705dc135dff435c0cb59dec4ebf3d0d1620d2c Mon Sep 17 00:00:00 2001 From: Jim Hu Date: Thu, 11 Dec 2008 21:54:52 +0000 Subject: update lots of files --- rss/index.php | 4 +- rss/rss.php | 303 ++++++++++++-------------------------------------------- rss/rss1.0.php | 305 +++++++++++---------------------------------------------- rss/rss2.0.php | 283 ++++++++++------------------------------------------ 4 files changed, 177 insertions(+), 718 deletions(-) (limited to 'rss') diff --git a/rss/index.php b/rss/index.php index be435b1..1d265db 100644 --- a/rss/index.php +++ b/rss/index.php @@ -7,7 +7,7 @@ define('BASE','../'); require_once(BASE.'functions/ical_parser.php'); require_once(BASE.'functions/calendar_functions.php'); -if ($enable_rss != 'yes') { +if ($phpiCal_config->enable_rss != 'yes') { exit(error($lang['l_rss_notenabled'], $cal, '../')); } @@ -25,7 +25,7 @@ $display_date = "RSS Info"; $rss_list = "\n"; $xml_icon ="xml"; -$filelist = availableCalendars($username, $password, $ALL_CALENDARS_COMBINED); +$filelist = availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED); foreach ($filelist as $file) { // $cal_filename is the filename of the calendar without .ics // $cal is a urlencoded version of $cal_filename diff --git a/rss/rss.php b/rss/rss.php index 65d669c..e6942a4 100644 --- a/rss/rss.php +++ b/rss/rss.php @@ -1,257 +1,78 @@ '."\n"; + +require(BASE.'rss/rss_common.php'); + +function rss_top(){ + global $cal_displayname, $theview, $default_path, $cpath, $lang, $rss_link, $rss_language; + $rss = ""."\n"; + $rss .= ''."\n"; + $rss .= ''."\n"; + $rss .= ''."\n"; + $rss .= ''.$cal_displayname; + if ($theview !=""){$rss .= ' - '.$theview;} + $rss .= "\n"; + + $rss .= ''.htmlspecialchars("$default_path").''."\n"; + if (isset($cpath) && $cpath !='') $rss_link.="?cpath=$cpath"; + $rss .= "$rss_link\n"; + + $rss .= ''.$cal_displayname.' '.$lang['l_calendar'].' - '.$theview.''."\n"; + $rss .= ''.$rss_language.''."\n"; + $rss .= 'Copyright '.date(Y).', '.htmlspecialchars ("$default_path").''."\n"; + return $rss; } -include_once(BASE.'functions/date_functions.php'); - - -//set the range of days to return based on the view chosen -$rssview = $_GET['rssview']; -if (isset($_GET['getdate']) && $_GET['getdate'] !=''){ - $getdate = $_GET['getdate']; -}else{ - $getdate = date("Ymd"); +function rss_li($rss_link, $uid){ + $return = ""; } -# for all views, $fromdate is the first day to be shown and $todate should be the last day. -switch ($rssview){ - case 'day': - $fromdate = $getdate; - $todate = $getdate; - $theview = $lang['l_day']; - break; - case 'week': - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = date("Ymd", strtotime($fromdate) + 6*24*60*60); - $theview = $lang['l_week']." of ".date('n/d/Y',strtotime($fromdate)); - break; - case 'month': - $parse_month = date ("Ym", strtotime($getdate)); - $fromdate = ($parse_month *100) + 1; - $todate = ($parse_month *100) + date("t",strtotime($getdate)); - $theview = date('M Y',strtotime($fromdate)); - break; - case 'year': - if(isset($_GET['year'])){ - $theyear = $_GET['year']; - }else{ - $theyear = substr($getdate,0,4); - } - $fromdate = ($theyear*10000)+101; - $todate = date("Ymd", strtotime($theyear*10000+1231)); - $theview = $theyear; - break; - case 'daysfrom': - $fromdate = $getdate; - $todate = date("Ymd", strtotime($getdate) + $_GET['days']*60*60*24); - $theview = $_GET['days']." days from ".date('n/d/Y',strtotime($fromdate)); - break; - case 'daysto': - $todate = $getdate; - $fromdate = date("Ymd", strtotime($getdate) - $_GET['days']*60*60*24); - $theview = $_GET['days']." days before ".date('n/d/Y',strtotime($todate)); - break; - case 'range': - if(isset($_GET['from'])){ - $fromdate = $_GET['from']; - }else{ - $fromdate = $getdate; - } - $todate = $_GET['to']; - $theview = date('n/d/Y',strtotime($fromdate)).'-'.date('n/d/Y',strtotime($todate)); - break; - default: - #default to week - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = date("Ymd", strtotime($fromdate) + 6*24*60*60); - $theview = ""; +function enclose_items($rss_items){ + return $rss_items; } -#need to give ical_parser the most distant date to correctly set up master_array. -$getdate = $todate; -#echo "from:$fromdate to:$todate"; - -#Note that ical_parser supplies cal_displayname. -include(BASE.'functions/ical_parser.php'); - -$events_count = 0; -// calculate a value for Last Modified and ETag -$cal = implode(",",$cals); - -//get filemtime from master array -$filemod = 0; #default to start of unix era, overwrite with most recent mtime from master array -foreach ($master_array['-4'] as $calinfo){ - if ($calinfo['mtime'] > $filemod) $filemod = $calinfo['mtime']; -} -$filemodtime = date("r", $filemod); - -//send relevant headers -header ("Last-Modified: $filemodtime"); -header ("ETag:\"$filemodtime\""); - -// checks the user agents headers to see if they kept track of our -// stuff, if so be nice and send back a 304 and exit. - -if ( ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $filemodtime) || ($_SERVER['HTTP_IF_NONE_MATCH'] == $filemodtime)){ - header ("HTTP/1.1 304 Not Modified"); - exit; +function rss_item(){ + global $uid,$event_start,$rss_title,$rss_link, $dayofweek, $event_text, $rss_description, $val; + $rss .= ''."\n"; + $rss .= ''.$uid.''."\n"; + $rss .= ''.$event_start.''."\n"; + $rss .= ''.$rss_title.''."\n"; + /* custom stuff for Jim Hu's RSS feeds. Deprecated + $rss .= ''.$dayofweek.''."\n"; + $rss .= ''.$event_text.''."\n"; + $rss .= ''.$description.''."\n"; + $rss .= ''.$val["description"].''."\n"; + $rss .= ''.$val['attendee'].''."\n"; + $rss .= ''.$val['organizer'].''."\n"; + $rss .= ''.$val['status'].''."\n"; + */ + $rss .= ''.$rss_link.''."\n"; + $rss .= ''.$rss_description.''."\n"; + if (isset($val['location']) && $val['location'] !=''){ + $location = str_replace('&','&',$val['location']); + $location = str_replace('&','&',$location); + $rss .= ''.$location."\n"; + } + $rss .= ''."\n"; + return $rss; } - -/* Change languages to ISO 639-1 to validate RSS without changing long version in config.inc.php */ -$user_language = array ("english", "polish", "german", "french", "dutch", "italian", "japanese", "norwegian", "spanish", "swedish", "portuguese", "catalan", "traditional_chinese", "esperanto", "korean"); -$iso_language = array ("en", "pl", "de", "fr", "nl", "da", "it", "ja", "no", "es", "sv", "pt", "ca", "zh-tw", "eo", "ko"); -$rss_language = str_replace($user_language, $iso_language, $language); -/* End language modification */ - -$rss = ""."\n"; -$rss .= ''."\n"; -$rss .= ''."\n"; -$rss .= ''."\n"; -$rss .= ''.$cal_displayname; -if ($theview !=""){$rss .= ' - '.$theview;} -$rss .= "\n"; - -$rss .= ''.htmlspecialchars("$default_path").''."\n"; -if (isset($cpath) && $cpath !='') $rss_link.="?cpath=$cpath"; -$rss .= "$rss_link\n"; - -$rss .= ''.$cal_displayname.' '.$lang['l_calendar'].' - '.$theview.''."\n"; -$rss .= ''.$rss_language.''."\n"; -$rss .= 'Copyright '.date(Y).', '.htmlspecialchars ("$default_path").''."\n"; - -//generate the items -$numdays = round((strtotime($todate) - strtotime($fromdate))/(60*60*24))+1; -$thisdate = $fromdate; # start at beginning of date range, - # note that usage of $thisdate is different from distribution - # I use it as a date, dist uses it as a time -$thistime = strtotime($thisdate); -$i = 1; #day counter -$uid_arr = array(); - do { - $thisdate=date('Ymd', $thistime); -# echo "Date: $thisdate\ti:$i\tnumdays:$numdays
\n"; - $dayofweek = localizeDate ("%a %b %e %Y", strtotime($thisdate)); - if (isset($master_array[($thisdate)]) && sizeof($master_array[($thisdate)]) > 0) { - foreach ($master_array[("$thisdate")] as $event_times) { - foreach ($event_times as $uid=>$val) { - #handle multiday all day events - if(!$val["event_start"]){ - if (isset($uid_arr[$uid])){ - $uid_arr[$uid] .= "+$dayofweek" ; - continue; - }else{ - $uid_arr[$uid] = "$dayofweek" ; - } - $event_start = $lang['l_all_day']; - }else{ - $event_start = @$val["event_start"]; - $event_start = date ($timeFormat, @strtotime ("$event_start")); - } - $event_text = stripslashes(urldecode($val["event_text"])); - $event_text = strip_tags($event_text, ''); - $event_text = str_replace('&','&',$event_text); - $event_text = str_replace('&amp;','&',$event_text); - # $event_text = urlencode($event_text); - #uncomment for shorter event text with ... - # $event_text = word_wrap($event_text, 21, $tomorrows_events_lines); - $description = stripslashes(urldecode($val["description"])); - $description = strip_tags($description, ''); - $description = str_replace('&','&',$description); - $description = str_replace('&amp;','&',$description); - - - $rss_title = urldecode ("$dayofweek: $event_text"); - - $urlcal = rawurlencode ("$cal"); - if (isset($rss_link_to_event) && $rss_link_to_event == 'yes'){ - $event_data = urlencode(serialize($val)); - $rss_link = "$default_path/includes/event.php?getdate=$thisdate&cal=$cal&event_data=$event_data"; - }else{ - $rss_link = ("$default_path/day.php?getdate=$thisdate&cal=$urlcal"); - - } - if (isset($cpath) && $cpath !='') $rss_link.="&cpath=$cpath"; - - $rss_description = htmlspecialchars ("$dayofweek $event_start: $description"); - - $rss .= ''."\n"; - $rss .= ''.$uid.''."\n"; - $rss .= ''.$event_start.''."\n"; - $rss .= ''.$rss_title.''."\n"; - /* custom stuff for Jim Hu's RSS feeds. Deprecated - $rss .= ''.$dayofweek.''."\n"; - $rss .= ''.$event_text.''."\n"; - $rss .= ''.$description.''."\n"; - $rss .= ''.$val["description"].''."\n"; - $rss .= ''.$val['attendee'].''."\n"; - $rss .= ''.$val['organizer'].''."\n"; - $rss .= ''.$val['status'].''."\n"; - */ - $rss .= ''.$rss_link.''."\n"; - $rss .= ''.$rss_description.''."\n"; - if (isset($val['location']) && $val['location'] !=''){ - $location = str_replace('&','&',$val['location']); - $location = str_replace('&amp;','&',$location); - $rss .= ''.$location."\n"; - } - $rss .= ''."\n"; - $events_count++; - } - } - } - if (($events_count < 1) && ($i == $numdays)) { - $rss .= ''."\n"; - $rss .= 'No events found'."\n"; - $rss .= ''.htmlspecialchars ("$default_path").''."\n"; - $rss .= ''."\n"; - } - $thistime = $thistime+(60*60*24); # echo "$thisdate: ".strtotime($thisdate)."->$thistime
\n"; - $i++; - } while ($i <= $numdays); - -$rss .= '
'."\n"; -$rss .= '
'."\n"; - -foreach ($uid_arr as $uid=>$date_range){ - #echo "date_range:$date_range
"; - - if(strpos($date_range,"+")>0){ - #echo "+ in date_range
"; - $temp = explode("+",$date_range); - $date_range = $temp[0].'-'.array_pop($temp); - } - $rss = str_replace("$uid\n".$lang['l_all_day']."","$uid\n$date_range", $rss); - +function rss_noitems(){ + global $default_path; + $rss .= ''."\n"; + $rss .= 'No events found'."\n"; + $rss .= ''.htmlspecialchars ("$default_path").''."\n"; + $rss .= ''."\n"; + return $rss; } -header ("Content-Type: text/xml"); - -echo "$rss"; +function rss_close(){ + return "
\n
\n"; +} ?> diff --git a/rss/rss1.0.php b/rss/rss1.0.php index 9e2a550..265c8ab 100755 --- a/rss/rss1.0.php +++ b/rss/rss1.0.php @@ -1,263 +1,76 @@ "."\n"; + + /* Use 1.0 and strip encoding, use rss_language */ + $rss .= ''."\n"; + + $rss .= ''."\n"; + $rss .= ''.$cal_displayname.' '.$lang['l_calendar'].' - '.$theview.''."\n"; + #$rss .= ''.$rss_language.''."\n"; + return $rss; } - -include_once(BASE.'functions/date_functions.php'); - - -//set the range of days to return based on the view chosen -$rssview = $_GET['rssview']; -if (isset($_GET['getdate']) && $_GET['getdate'] !=''){ - $getdate = $_GET['getdate']; -}else{ - $getdate = date("Ymd"); +function rss_li($rss_link, $uid){ + return ''."\n"; } -# for all views, $fromdate is the first day to be shown and $todate should be the last day. -switch ($rssview){ - case 'day': - $fromdate = $getdate; - $todate = $getdate; - $theview = $lang['l_day']; - break; - case 'week': - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = $fromdate + 6; - $theview = $lang['l_week']." of ".date('n/d/Y',strtotime($fromdate)); - break; - case 'month': - $parse_month = date ("Ym", strtotime($getdate)); - $fromdate = ($parse_month *100) + 1; - $todate = ($parse_month *100) + date("t",strtotime($getdate)); - $theview = date('M Y',strtotime($fromdate)); - break; - case 'year': - if(isset($_GET['year'])){ - $theyear = $_GET['year']; - }else{ - $theyear = substr($getdate,0,4); - } - $fromdate = ($theyear*10000)+101; - $todate = date("Ymd", strtotime($theyear*10000+1231)); - $theview = $theyear; - break; - case 'daysfrom': - $fromdate = $getdate; - $todate = date("Ymd", strtotime($getdate) + $_GET['days']*60*60*24); - $theview = $_GET['days']." days from ".date('n/d/Y',strtotime($fromdate)); - break; - case 'daysto': - $todate = $getdate; - $fromdate = date("Ymd", strtotime($getdate) - $_GET['days']*60*60*24); - $theview = $_GET['days']." days before ".date('n/d/Y',strtotime($todate)); - break; - case 'range': - if(isset($_GET['from'])){ - $fromdate = $_GET['from']; - }else{ - $fromdate = $getdate; - } - $todate = $_GET['to']; - $theview = date('n/d/Y',strtotime($fromdate)).'-'.date('n/d/Y',strtotime($todate)); - break; - default: - #default to week - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = $fromdate + 6; - $theview = ""; +function enclose_items($rss_items){ + return "\n\n".$rss_items."\n\n\n"; } -#need to give ical_parser the most distant date to correctly set up master_array. -$getdate = $todate; -#echo "from:$fromdate to:$todate"; - -#Note that ical_parser supplies cal_displayname. -include(BASE.'functions/ical_parser.php'); - -$events_count = 0; - -// calculate a value for Last Modified and ETag -$cal = implode(",",$cals); - -//get filemtime from master array -$filemod = 0; #default to start of unix era, overwrite with most recent mtime from master array -foreach ($master_array['-4'] as $calinfo){ - if ($calinfo['mtime'] > $filemod) $filemod = $calinfo['mtime']; -} -$filemodtime = date("r", $filemod); -//send relevant headers -header ("Last-Modified: $filemodtime"); -header ("ETag:\"$filemodtime\""); - -// checks the user agents headers to see if they kept track of our -// stuff, if so be nice and send back a 304 and exit. - -if ( ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $filemodtime) || ($_SERVER['HTTP_IF_NONE_MATCH'] == $filemodtime)){ - header ("HTTP/1.1 304 Not Modified"); - exit; +function rss_item(){ + global $uid,$event_start,$rss_title,$rss_link, $dayofweek, $event_text, $rss_description, $val; + $rss_item = ''."\n"; + + /* Create guid, and use uid to make link unique */ +# $rss .= ''.$rss_link.$uid.''."\n"; + /* End guid modification */ + $rss_item .= ''.$rss_title.''."\n"; + $rss_item .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; + $rss_item .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; + + $rss_item .= ''.$rss_link.''."\n"; + $rss_item .= ''.$rss_description.''."\n"; + if (isset($val['location']) && $val['location'] !=''){ + $location = str_replace('&','&',$val['location']); + $location = str_replace('&amp;','&',$location); + $rss_item .= ''.$location."\n"; + } + $rss_item .= ''."\n"; + return $rss_item; } -/* Change languages to ISO 639-1 to validate RSS without changing long version in config.inc.php */ -$user_language = array ("english", "polish", "german", "french", "dutch", "italian", "japanese", "norwegian", "spanish", "swedish", "portuguese", "catalan", "traditional_chinese", "esperanto", "korean"); -$iso_language = array ("en", "pl", "de", "fr", "nl", "da", "it", "ja", "no", "es", "sv", "pt", "ca", "zh-tw", "eo", "ko"); -$rss_language = str_replace($user_language, $iso_language, $language); -/* End language modification */ - -$rss = ""."\n"; - -/* Use 1.0 and strip encoding, use rss_language */ -$rss .= ''."\n"; - -$rss .= ''."\n"; -$rss .= ''.$cal_displayname.' '.$lang['l_calendar'].' - '.$theview.''."\n"; -#$rss .= ''.$rss_language.''."\n"; - - -//generate the items -$numdays = round((strtotime($todate) - strtotime($fromdate))/(60*60*24))+1; -$thisdate = $fromdate; # start at beginning of date range, - # note that usage of $thisdate is different from distribution - # I use it as a date, dist uses it as a time -$i = 1; #day counter - -$rss .= "\n\n"; -$rss_items =''; -$uid_arr = array(); - do { - $thisdate=date('Ymd', strtotime($thisdate)); - #echo "Date: $thisdate
\n"; - $dayofweek = localizeDate ("%a %b %e %Y", strtotime($thisdate)); - if (isset($master_array[($thisdate)]) && sizeof($master_array[($thisdate)]) > 0) { - foreach ($master_array[("$thisdate")] as $event_times) { - foreach ($event_times as $uid=>$val) { - #handle multiday all day events - if(!$val["event_start"]){ - if (isset($uid_arr[$uid])){ - $uid_arr[$uid] .= "+$dayofweek" ; - continue; - }else{ - $uid_arr[$uid] = "$dayofweek" ; - } - $event_start = $lang['l_all_day']; - }else{ - $event_start = @$val["event_start"]; - $event_start = date ($timeFormat, @strtotime ("$event_start")); - } - $event_text = stripslashes(urldecode($val["event_text"])); - $event_text = strip_tags($event_text, ''); - # $event_text = urlencode($event_text); - #uncomment for shorter event text with ... - # $event_text = word_wrap($event_text, 21, $tomorrows_events_lines); - $description = stripslashes(urldecode($val["description"])); - $description = strip_tags($description, ''); - - $rss_title = htmlspecialchars ("$dayofweek: $event_text"); - /* original link, not valid url coding - $rss_link = htmlspecialchars ("$default_path/day.php?getdate=$thisdate&cal=$cal&cpath=$cpath"); - */ - /* Add %20's for spaces for the calendar links to make them valid url's */ - $urlcal = rawurlencode ("$cal"); - - if (isset($rss_link_to_event) && $$rss_link_to_event == 'yes'){ - $event_data = urlencode(serialize($val)); - $rss_link = "$default_path/includes/event.php?getdate=$thisdate&cal=$cal&event_data=$event_data"; - }else{ - $rss_link = ("$default_path/day.php?getdate=$thisdate&cal=$urlcal"); - - } - if (isset($cpath) && $cpath !='') $rss_link.="&cpath=$cpath"; - /* End link modification */ - - $rss_description = htmlspecialchars ("$dayofweek $event_start: $description"); - - $rss .= ''."\n"; - $rss_items .= ''."\n"; - - /* Create guid, and use uid to make link unique */ - # $rss .= ''.$rss_link.$uid.''."\n"; - /* End guid modification */ - $rss_items .= ''.$rss_title.''."\n"; - $rss_items .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; - $rss_items .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; - - $rss_items .= ''.$rss_link.''."\n"; - $rss_items .= ''.$rss_description.''."\n"; - if (isset($val['location']) && $val['location'] !=''){ - $location = str_replace('&','&',$val['location']); - $location = str_replace('&amp;','&',$location); - $rss_items .= ''.$location."\n"; - } - $rss_items .= ''."\n"; - $events_count++; - } - } - } - if (($events_count < 1) && ($i == $numdays)) { - $rss_items .= '\n"; - $rss_items .= 'No events found'."\n"; - $rss_items .= ''.htmlspecialchars ("$default_path").''."\n"; - $rss_items .= ''."\n"; - } - $thisdate++; - $i++; - } while ($i <= $numdays); - -$rss .= "
\n
\n"; -$rss .= "
\n"; -$rss .= $rss_items.'
'."\n"; - -foreach ($uid_arr as $uid=>$date_range){ - #echo "date_range:$date_range
"; - - if(strpos($date_range,"+")>0){ - #echo "+ in date_range
"; - $temp = explode("+",$date_range); - $date_range = $temp[0].'-'.array_pop($temp); - } - $rss = str_replace("$uid\n".$lang['l_all_day']."","$uid\n$date_range", $rss); - +function rss_noitems(){ + $rss_item = '\n"; + $rss_item .= 'No events found'."\n"; + $rss_item .= ''.htmlspecialchars ("$default_path").''."\n"; + $rss_item .= ''."\n"; + return $rss_item; } -header ("Content-Type: text/xml"); - -echo "$rss"; +function rss_close(){ + return "
\n"; +} ?> diff --git a/rss/rss2.0.php b/rss/rss2.0.php index 76d6a59..cd63ad0 100644 --- a/rss/rss2.0.php +++ b/rss/rss2.0.php @@ -22,243 +22,68 @@ */ define('BASE', '../'); -require(BASE.'functions/init.inc.php'); - -if ($enable_rss != 'yes') { - die ("RSS feeds are not enabled on this site."); +require(BASE.'rss/rss_common.php'); +function rss_top(){ + global $cal_displayname, $theview, $default_path, $cpath, $lang, $rss_link, $rss_language; + + $rss = ""."\n"; + /* Use 2.0 and strip encoding, use rss_language */ + $rss .= ''."\n"; + $rss .= ''.$rss_language.''."\n"; + return $rss; } -include_once(BASE.'functions/date_functions.php'); - - -//set the range of days to return based on the view chosen -$rssview = $_GET['rssview']; -if (isset($_GET['getdate']) && $_GET['getdate'] !=''){ - $getdate = $_GET['getdate']; -}else{ - $getdate = date("Ymd"); +function rss_li($rss_link, $uid){ + $return = ""; } -# for all views, $fromdate is the first day to be shown and $todate should be the last day. -switch ($rssview){ - case 'day': - $fromdate = $getdate; - $todate = $getdate; - $theview = $lang['l_day']; - break; - case 'week': - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = $fromdate + 6; - $theview = $lang['l_week']." of ".date('n/d/Y',strtotime($fromdate)); - break; - case 'month': - $parse_month = date ("Ym", strtotime($getdate)); - $fromdate = ($parse_month *100) + 1; - $todate = ($parse_month *100) + date("t",strtotime($getdate)); - $theview = date('M Y',strtotime($fromdate)); - break; - case 'year': - if(isset($_GET['year'])){ - $theyear = $_GET['year']; - }else{ - $theyear = substr($getdate,0,4); - } - $fromdate = ($theyear*10000)+101; - $todate = date("Ymd", strtotime($theyear*10000+1231)); - $theview = $theyear; - break; - case 'daysfrom': - $fromdate = $getdate; - $todate = date("Ymd", strtotime($getdate) + $_GET['days']*60*60*24); - $theview = $_GET['days']." days from ".date('n/d/Y',strtotime($fromdate)); - break; - case 'daysto': - $todate = $getdate; - $fromdate = date("Ymd", strtotime($getdate) - $_GET['days']*60*60*24); - $theview = $_GET['days']." days before ".date('n/d/Y',strtotime($todate)); - break; - case 'range': - if(isset($_GET['from'])){ - $fromdate = $_GET['from']; - }else{ - $fromdate = $getdate; - } - $todate = $_GET['to']; - $theview = date('n/d/Y',strtotime($fromdate)).'-'.date('n/d/Y',strtotime($todate)); - break; - default: - #default to week - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = $fromdate + 6; - $theview = ""; +function enclose_items($rss_items){ + return $rss_items; } -#need to give ical_parser the most distant date to correctly set up master_array. -$getdate = $todate; -#echo "from:$fromdate to:$todate"; - -#Note that ical_parser supplies cal_displayname. -include(BASE.'functions/ical_parser.php'); - -$events_count = 0; - -// calculate a value for Last Modified and ETag -$cal = implode(",",$cals); - -//get filemtime from master array -$filemod = 0; #default to start of unix era, overwrite with most recent mtime from master array -foreach ($master_array['-4'] as $calinfo){ - if ($calinfo['mtime'] > $filemod) $filemod = $calinfo['mtime']; -} -$filemodtime = date("r", $filemod); -//send relevant headers -header ("Last-Modified: $filemodtime"); -header ("ETag:\"$filemodtime\""); - -// checks the user agents headers to see if they kept track of our -// stuff, if so be nice and send back a 304 and exit. - -if ( ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $filemodtime) || ($_SERVER['HTTP_IF_NONE_MATCH'] == $filemodtime)) -{ -# header ("HTTP/1.1 304 Not Modified"); -# exit; +function rss_item(){ + global $uid,$event_start,$rss_title,$rss_link, $dayofweek, $event_text, $rss_description, $val, $thisdate; + $rss = ''."\n"; + /* Create guid, and use uid to make link unique */ + $rss .= ''.$rss_link.'&uid='.$uid.''."\n"; + /* End guid modification */ + $rss .= ''.$rss_title.''."\n"; + $rss .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; + $rss .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; + + $rss .= ''.$rss_link.''."\n"; + $rss .= ''.$rss_description.''."\n"; + if (isset($val['location']) && $val['location'] !=''){ + $location = str_replace('&','&',$val['location']); + $location = str_replace('&amp;','&',$location); + $rss .= ''.$location."\n"; + } + $rss .= ''."\n"; + return $rss; } -/* Change languages to ISO 639-1 to validate RSS without changing long version in config.inc.php */ -$user_language = array ("english", "polish", "german", "french", "dutch", "italian", "japanese", "norwegian", "spanish", "swedish", "portuguese", "catalan", "traditional_chinese", "esperanto", "korean"); -$iso_language = array ("en", "pl", "de", "fr", "nl", "da", "it", "ja", "no", "es", "sv", "pt", "ca", "zh-tw", "eo", "ko"); -$rss_language = str_replace($user_language, $iso_language, $language); -/* End language modification */ - -$rss = ""."\n"; -#$rss .= ''."\n"; - -/* Use 2.0 and strip encoding, use rss_language */ -$rss .= ''."\n"; -$rss .= ''.$rss_language.''."\n"; - - -/* End rss 2.0 modification */ - - -//generate the items -$numdays = round((strtotime($todate) - strtotime($fromdate))/(60*60*24))+1; -$thisdate = $fromdate; # start at beginning of date range, - # note that usage of $thisdate is different from distribution - # I use it as a date, dist uses it as a time -$i = 1; #day counter - -#$rss .= "\n\n"; -$uid_arr = array(); - do { - $thisdate=date('Ymd', strtotime($thisdate)); - #echo "Date: $thisdate
\n"; - $dayofweek = localizeDate ("%a %b %e %Y", strtotime($thisdate)); - if (isset($master_array[($thisdate)]) && sizeof($master_array[($thisdate)]) > 0) { - foreach ($master_array[("$thisdate")] as $event_times) { - foreach ($event_times as $uid=>$val) { - #handle multiday all day events - if(!$val["event_start"]){ - if (isset($uid_arr[$uid])){ - $uid_arr[$uid] .= "+$dayofweek" ; - continue; - }else{ - $uid_arr[$uid] = "$dayofweek" ; - } - $event_start = $lang['l_all_day']; - }else{ - $event_start = @$val["event_start"]; - $event_start = date ($timeFormat, @strtotime ("$event_start")); - } - $event_text = stripslashes(urldecode($val["event_text"])); - $event_text = strip_tags($event_text, ''); - # $event_text = urlencode($event_text); - #uncomment for shorter event text with ... - # $event_text = word_wrap($event_text, 21, $tomorrows_events_lines); - $description = stripslashes(urldecode($val["description"])); - $description = strip_tags($description, ''); - - $rss_title = htmlspecialchars ("$dayofweek: $event_text"); - /* original link, not valid url coding - $rss_link = htmlspecialchars ("$default_path/day.php?getdate=$thisdate&cal=$cal&cpath=$cpath"); - */ - /* Add %20's for spaces for the calendar links to make them valid url's */ - $urlcal = rawurlencode ("$cal"); - if (isset($rss_link_to_event) && $$rss_link_to_event == 'yes'){ - $event_data = urlencode(serialize($val)); - $rss_link = "$default_path/includes/event.php?getdate=$thisdate&cal=$cal&event_data=$event_data"; - }else{ - $rss_link = ("$default_path/day.php?getdate=$thisdate&cal=$urlcal"); - - } - if (isset($cpath) && $cpath !='') $rss_link.="&cpath=$cpath"; - /* End link modification */ - $rss_description = htmlspecialchars ("$dayofweek $event_start: $description"); - - #$rss .= ''."\n"; - $rss .= ''."\n"; - - /* Create guid, and use uid to make link unique */ - $rss .= ''.$rss_link.'&uid='.$uid.''."\n"; - /* End guid modification */ - $rss .= ''.$rss_title.''."\n"; - $rss .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; - $rss .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; - - $rss .= ''.$rss_link.''."\n"; - $rss .= ''.$rss_description.''."\n"; - if (isset($val['location']) && $val['location'] !=''){ - $location = str_replace('&','&',$val['location']); - $location = str_replace('&amp;','&',$location); - $rss .= ''.$location."\n"; - } - $rss .= ''."\n"; - $events_count++; - } - } - } - if (($events_count < 1) && ($i == $numdays)) { - $rss .= ''."\n"; - $rss .= ''.$default_path.'&uid='.$thisdate.''."\n"; - $rss .= 'No events found'."\n"; - $rss .= ''.htmlspecialchars ("$default_path").''."\n"; - $rss .= ''."\n"; - } - $thisdate++; - $i++; - } while ($i <= $numdays); - -#$rss .= "
\n
\n"; -$rss .= "\n\n
\n"; - -foreach ($uid_arr as $uid=>$date_range){ - #echo "date_range:$date_range
"; - - if(strpos($date_range,"+")>0){ - #echo "+ in date_range
"; - $temp = explode("+",$date_range); - $date_range = $temp[0].'-'.array_pop($temp); - } - $rss = str_replace("$uid\n".$lang['l_all_day']."","$uid\n$date_range", $rss); - +function rss_noitems(){ + $rss = ''."\n"; + $rss .= ''.$default_path.'&uid='.$thisdate.''."\n"; + $rss .= 'No events found'."\n"; + $rss .= ''.htmlspecialchars ("$default_path").''."\n"; + $rss .= ''."\n"; + return $rss; } -header ("Content-Type: text/xml"); - -echo "$rss"; +function rss_close(){ + return "\n\n
\n"; +} ?> -- cgit v1.2.3