From 63711a896333caf6a2cc0a7ee593c6a4b1eb84c5 Mon Sep 17 00:00:00 2001 From: Jim Hu Date: Sun, 15 May 2005 07:17:49 +0000 Subject: Bug fix for date range crossing year boundary. Other tweaks for XML validation of special chars --- rss/rss.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'rss') diff --git a/rss/rss.php b/rss/rss.php index a15195c..84e0de2 100644 --- a/rss/rss.php +++ b/rss/rss.php @@ -30,7 +30,7 @@ switch ($rssview){ $theview = $day_lang; break; case 'month': -$parse_month = date ("Ym", strtotime($getdate)); + $parse_month = date ("Ym", strtotime($getdate)); $fromdate = ($parse_month *100) + 1; $nextmonth = ($parse_month +1) * 100; #should give the 0th day of following month $todate = date('Ymd',strtotime($nextmonth)); @@ -64,7 +64,7 @@ $parse_month = date ("Ym", strtotime($getdate)); //Note that this depends on other modifications I've made to //allow phpicalendar to use calendar subdirectories - see bbs -$cal_displayname = str_replace("32", " ", $cal); +$cal_displayname = str_replace("32", " ", $cal); if ($cal == $ALL_CALENDARS_COMBINED) { $temp = explode("/",$calendar_path); $cal_displayname = str_replace("32"," ",ucfirst(array_pop($temp))); @@ -105,7 +105,7 @@ $rss .= ''.$rss_language.''."\n"; $rss .= 'Copyright '.date(Y).', '.htmlspecialchars ("$default_path").''."\n"; //generate the items -$numdays = $todate - $fromdate; +$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 @@ -126,12 +126,18 @@ $i = 0; #day counter } $event_text = stripslashes(urldecode($val["event_text"])); $event_text = strip_tags($event_text, ''); - $event_text = str_replace("& ","&", $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, ''); - $rss_title = htmlspecialchars ("$dayofweek: $event_text"); + $description = stripslashes(urldecode($val["description"])); + $description = strip_tags($description, ''); + $description = str_replace('&','&',$description); + $description = str_replace('&amp;','&',$description); + + + $rss_title = htmlspecialchars ("$dayofweek: $event_text"); $rss_link = htmlspecialchars ("$default_path/day.php?getdate=$getdate&cal=$cal&cpath=$cpath"); $rss_description = htmlspecialchars ("$dayofweek $event_start: $description"); @@ -149,7 +155,11 @@ $i = 0; #day counter $rss .= ''.$rss_link.''."\n"; $rss .= ''.$rss_description.''."\n"; - $rss .= ''.$val['location'].''; + $location = str_replace('&','&',$val['location']); + $location = str_replace('&amp;','&',$location); + + + $rss .= ''.$location.''; $rss .= ''."\n"; $events_count++; } @@ -162,7 +172,7 @@ $i = 0; #day counter $rss .= ''."\n"; } $thisdate++; - $i++; + $i++; } while ($i <= $numdays); $rss .= ''."\n"; -- cgit v1.2.3