From: Jim Hu <ji...@ta...> - 2005-10-30 07:15:28
|
I haen't been checking in as much as I should...It looks like I did the redefinition in 1.24, and looking at the code, I don't remember why...but note that there was a more complex redefinition of $default_path in earlier versions. Note also that to get the correct URL one also has to change line 140 from $rss_link = htmlspecialchars ("$default_path/day.php?getdate= $getdate&cal=$cal&cpath=$cpath"); to $rss_link = htmlspecialchars ("$default_path/day.php?getdate= $thisdate&cal=$cal&cpath=$cpath"); I'm also not getting the multiple calendar selector to work if the calendars are in a directory specified by cpath. Jim Hu On Oct 29, 2005, at 3:14 PM, phpicalendar-devel- re...@li... wrote: > Send Phpicalendar-devel mailing list submissions to > php...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/phpicalendar-devel > or, via email, send a message with subject or body 'help' to > php...@li... > > You can reach the person managing the list at > php...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Phpicalendar-devel digest..." > > > Today's Topics: > > 1. Support for iCal Databases (Wesley Miaw) > 2. Patch for 1305320/1304709 (Wesley Miaw) > > --__--__-- > > Message: 1 > To: php...@li... > From: Wesley Miaw <we...@we...> > Date: Fri, 28 Oct 2005 23:00:44 -0700 > Subject: [PHPiCalendar-DEV] Support for iCal Databases > Reply-To: php...@li... > > > --Apple-Mail-6--212894681 > Content-Transfer-Encoding: 7bit > Content-Type: text/plain; > charset=US-ASCII; > delsp=yes; > format=flowed > > Hi People, > > Been a long time since I last participated, but I finally did some > work again. :P > > Attached is a diff of my tree that enables support for the new iCal- > type directory structure and independently support for recursively > finding calendars in subdirectories. > > I'd like people to give it a try and see if everything works for them > still. If so, I'll commit the changes to CVS. I've submitted this > diff file as a patch to SourceForge as a backup. > > I also completely removed the redefinition of $default_path from > rss.php. I removed it because it was generating invalid URLs on my > server. Why was it redefined in 1.24 to begin with? > > Later, > -- > Wesley Miaw > we...@we... > > > --Apple-Mail-6--212894681 > Content-Transfer-Encoding: 7bit > Content-Type: application/octet-stream; > x-mac-type=54455854; > x-unix-mode=0644; > name="ical.diff" > Content-Disposition: attachment; > filename=ical.diff > > Index: config.inc.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/config.inc.php,v > retrieving revision 1.168 > diff -u -r1.168 config.inc.php > --- config.inc.php 14 Sep 2005 20:53:53 -0000 1.168 > +++ config.inc.php 29 Oct 2005 05:49:14 -0000 > @@ -39,6 +39,8 @@ > $show_completed = 'yes'; // Show > completed todos on your todo list. > $allow_login = 'no'; // Set to yes to > prompt for login to unlock calendars. > $login_cookies = 'no'; // Set to yes to > store authentication information via (unencrypted) cookies. Set to > no to use sessions. > +$support_ical = 'no'; // Set to yes to > support the Apple iCal calendar database structure. > +$recursive_path = 'no'; // Set to yes to > recurse into subdirectories of the calendar path. > > // Calendar Caching (decreases page load times) > $save_parsed_cals = 'no'; // Saves a copy > of the cal in /tmp after it's been parsed. Improves performence. > Index: functions/calendar_functions.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ > calendar_functions.php,v > retrieving revision 1.10 > diff -u -r1.10 calendar_functions.php > --- functions/calendar_functions.php 27 Oct 2005 17:41:24 > -0000 1.10 > +++ functions/calendar_functions.php 29 Oct 2005 05:49:14 -0000 > @@ -14,7 +14,7 @@ > // returned. > function availableCalendars($username, $password, $cal_filename, > $admin = false) { > // Import globals. > - global $allow_login, $calendar_path, $blacklisted_cals, > $list_webcals, $locked_cals, $locked_map, $apache_map, $lang, > $ALL_CALENDARS_COMBINED, $_SERVER; > + global $allow_login, $calendar_path, $recursive_path, > $support_ical, $blacklisted_cals, $list_webcals, $locked_cals, > $locked_map, $apache_map, $lang, $ALL_CALENDARS_COMBINED, $_SERVER; > > // Create the list of available calendars. > $calendars = array(); > @@ -30,39 +30,20 @@ > if (isset($locked_map["$username:$password"])) { > $unlocked_cals = $locked_map["$username:$password"]; > } > - > - // Include all local and web calendars if asking for all > calendars > - // combined. > - if ($cal_filename == $ALL_CALENDARS_COMBINED || $admin) { > - // Add local calendars. > - $dir_handle = @opendir($calendar_path) > - or die(error(sprintf($lang['l_error_path'], > $calendar_path), $cal_filename)); > - while (($file = readdir($dir_handle)) != false) { > - // Make sure this is not a dot file and it ends > with .ics, > - // and that it is not blacklisted. > - if (!preg_match("/^[^.].*\.ics$/i", $file)) continue; > - $cal_name = substr($file, 0, -4); > - if (in_array($cal_name, $blacklisted_cals)) continue; > + // Make a local copy of the requested calendars. > + if (!is_array($cal_filename)) > + $cal_filename_local = array($cal_filename); > + else > + $cal_filename_local = $cal_filename; > > - // If HTTP authenticated, make sure this calendar is > available > - // to the user. > - if (isset($http_user)) { > - if (!in_array($cal_name, $apache_map[$http_user])) > continue; > - } > - > - // Otherwise exclude locked calendars. > - else if (!$admin && > - in_array($cal_name, $locked_cals) && > - !in_array($cal_name, $unlocked_cals)) > - { > - continue; > - } > - > - // Add this calendar. > - array_push($calendars, "$calendar_path/$file"); > - } > + // Create the list of available calendars. > + $calendars = array(); > + > + // This array keeps track of paths we need to search. > + $search_paths = array($calendar_path); > > - // Add web calendars. > + // Add web calendars. > + if ($cal_filename == $ALL_CALENDARS_COMBINED || $admin) { > if (!isset($http_user) && !$admin) { > foreach ($list_webcals as $file) { > // Make sure the URL ends with .ics. > @@ -74,55 +55,92 @@ > } > } > > - // Otherwise just include the requested calendar. > - else { > - if(!is_array($cal_filename)) { > - $cal_filename_local = array($cal_filename); > - } > - else { > - $cal_filename_local = $cal_filename; > - } > - > - foreach($cal_filename_local as $c) { > - > - // Make sure this is not a blacklisted calendar. We don't > have > - // to remove a .ics suffix because it would not have been > passed > - // in the argument. > - if (in_array($c, $blacklisted_cals)) > - exit(error($lang['l_error_restrictedcal'], $c)); > - > - // If HTTP authenticated, make sure this calendar is > available > - // to the user. > - if (isset($http_user)) { > - if (!in_array($c, $apache_map[$http_user])) { > - // Use the invalid calendar message so that the > user is > - // not made aware of locked calendars. > - exit(error($lang['l_error_invalidcal'], $c)); > + // Set some booleans that will dictate our search. > + $find_all = ($cal_filename == $ALL_CALENDARS_COMBINED || $admin); > + > + // Process all search paths. > + while (!empty($search_paths)) { > + // Read the next search path. > + $search_path = array_pop($search_paths); > + > + // This array keeps track of filenames we need to look at. > + $files = array(); > + > + // Build the list of files we need to check. > + if ($find_all || $recursive_path == 'yes') { > + // Open the directory. > + $dir_handle = @opendir($search_path) > + or die(error(sprintf($lang['l_error_path'], > $search_path), $cal_filename)); > + if ($dir_handle === false) > + die(error(sprintf($lang['l_error_path'], > $search_path), $cal_filename)); > + > + // Add each file in the directory that does not begin > with a dot. > + while (false !== ($file = readdir($dir_handle))) { > + // Make sure this is not a dot file. > + if (preg_match("/^\./", $file)) continue; > + array_push($files, "$search_path/$file"); > + } > + } else { > + foreach ($cal_filename_local as $filename) { > + array_push($files, "$search_path/$filename"); > } > } > > - // Otherwise make sure this calendar is not locked. > - else if (in_array($c, $locked_cals) && > - !in_array($c, $unlocked_cals)) > - { > - // Use the invalid calendar message so that the user is > - // not made aware of locked calendars. > - exit(error($lang['l_error_invalidcal'], $c)); > - } > + // Process files. > + foreach ($files as $file) { > + // Push directories onto the search paths if recursive > paths is > + // turned on. > + if (is_dir($file)) { > + if ($recursive_path == 'yes') { > + array_push($search_paths, $file); > + } > + continue; > + } > + > + // Make sure the file is real. > + if (!is_file($file)) continue; > + > + // Make sure the file ends in .ics. > + if (!preg_match("/^.*\.ics$/i", $file)) continue; > + > + // Make sure this is not a blacklisted calendar. > + $cal_name = getCalendarName($file); > + if (in_array($cal_name, $blacklisted_cals)) continue; > + > + // If HTTP authenticated, make sure this calendar is > available > + // to the user. > + if (isset($http_user)) { > + if (!in_array($cal_name, $apache_map[$http_user])) > continue; > + } > > - // Add this calendar. > - array_push($calendars, "$calendar_path/$c.ics"); > + // Make sure this calendar is not locked. > + if (!$admin && > + in_array($cal_name, $locked_cals) && > + !in_array($cal_name, $unlocked_cals)) > + { > + continue; > + } > + > + // Add this calendar if we're looking for it, and > remove it's name > + // from the local list because we've found it. > + if ($find_all || in_array($cal_name, > $cal_filename_local)) { > + array_push($calendars, $file); > + $cal_filename_local = array_diff > ($cal_filename_local, array($cal_name)); > + > + // If the local list is empty, we're done. > + if (empty($cal_filename_local)) > + break 2; > + } > } > } > - > + > // Return the sorted calendar list. > natcasesort($calendars); > return $calendars; > } > > // This function returns the result of the availableCalendars > function > -// but only includes the calendar filename (including the .ics) > and not > -// the entire path. > +// but only includes the calendar names. > // > // $username = The username. Empty if no username provided. > // $password = The password. Empty if no password provided. > @@ -136,7 +154,7 @@ > > // Strip the paths off the calendars. > foreach (array_keys($calendars) as $key) { > - $calendars[$key] = basename($calendars[$key]); > + $calendars[$key] = getCalendarName($key); > } > > // Return the sorted calendar names. > @@ -144,6 +162,34 @@ > return $calendars; > } > > +// This function returns the calendar name for the specified calendar > +// path. > +// > +// $cal_path = The path to the calendar file. > +function getCalendarName($cal_path) { > + global $support_ical; > + > + // If iCal is supported, check the directory for an Info.plist. > + if ($support_ical == 'yes') { > + // Look for the Info.plist file. > + $plist_filename = dirname($cal_path)."/Info.plist"; > + if (is_file($plist_filename)) { > + // Read the Info.plist. > + $handle = fopen($plist_filename, 'r'); > + $contents = fread($handle, filesize($plist_filename)); > + fclose($handle); > + > + // Pull out the calendar name. > + $num_matches = preg_match("/<key>Title<\/key>\s*? > <string>(.+?)<\/string>/i", $contents, $matches); > + if ($num_matches > 0) > + return $matches[1]; > + } > + } > + > + // At this point, just pull the name off the file. > + return substr(basename($cal_path), 0, -4); > +} > + > // This function prints out the calendars available to the user, for > // selection. Should be enclosed within a <select>...</select>, which > // is not printed out by this function. > @@ -158,9 +204,8 @@ > // > // Only display the calendar name, replace all instances > of "32" with " ", > // and remove the .ics suffix. > - $cal_displayname_tmp = basename($cal_tmp); > + $cal_displayname_tmp = getCalendarName($cal_tmp); > $cal_displayname_tmp = str_replace("32", " ", > $cal_displayname_tmp); > - $cal_displayname_tmp = substr($cal_displayname_tmp, 0, -4); > > // If this is a webcal, add 'Webcal' to the display name. > if (preg_match("/^(https?|webcal):\/\//i", $cal_tmp)) { > @@ -172,8 +217,7 @@ > // label to the display name. > else { > // Strip path and .ics suffix. > - $cal_tmp = basename($cal_tmp); > - $cal_tmp = substr($cal_tmp, 0, -4); > + $cal_tmp = getCalendarName($cal_tmp); > > // Add calendar label. > $cal_displayname_tmp .= " $calendar_lang"; > @@ -212,4 +256,4 @@ > } > } > return $return; > -} > \ No newline at end of file > +} > Index: functions/ical_parser.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ > ical_parser.php,v > retrieving revision 1.196 > diff -u -r1.196 ical_parser.php > --- functions/ical_parser.php 14 Sep 2005 00:42:32 -0000 1.196 > +++ functions/ical_parser.php 29 Oct 2005 05:49:15 -0000 > @@ -99,8 +99,7 @@ > foreach ($cal_filelist as $filename) { > > // Find the real name of the calendar. > - $actual_calname = str_replace($calendar_path, '', $filename); > - $actual_calname = str_replace('/', '', str_replace('.ics', '', > $actual_calname)); > + $actual_calname = getCalendarName($filename); > > if ($parse_file) { > > Index: functions/list_functions.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ > list_functions.php,v > retrieving revision 1.13 > diff -u -r1.13 list_functions.php > --- functions/list_functions.php 21 Oct 2004 20:15:14 -0000 1.13 > +++ functions/list_functions.php 29 Oct 2005 05:49:15 -0000 > @@ -2,12 +2,13 @@ > > function list_jumps() { > global $second_offset, $lang, $cal; > + $calName = getCalendarName($cal); > $today = date('Ymd', strtotime("now + $second_offset seconds")); > $return = '<option value="#">'.$lang['l_jump'].'</option>'; > - $return .= '<option value="day.php?cal='.$cal.'&getdate='. > $today.'">'.$lang['l_goday'].'</option>'; > - $return .= '<option value="week.php?cal='.$cal.'&getdate='. > $today.'">'.$lang['l_goweek'].'</option>'; > - $return .= '<option value="month.php?cal='. > $cal.'&getdate='.$today.'">'.$lang['l_gomonth'].'</option>'; > - $return .= '<option value="year.php?cal='.$cal.'&getdate='. > $today.'">'.$lang['l_goyear'].'</option>'; > + $return .= '<option value="day.php?cal='. > $calName.'&getdate='.$today.'">'.$lang['l_goday'].'</option>'; > + $return .= '<option value="week.php?cal='. > $calName.'&getdate='.$today.'">'.$lang['l_goweek'].'</option>'; > + $return .= '<option value="month.php?cal='. > $calName.'&getdate='.$today.'">'.$lang['l_gomonth'].'</option>'; > + $return .= '<option value="year.php?cal='. > $calName.'&getdate='.$today.'">'.$lang['l_goyear'].'</option>'; > return $return; > } > > Index: functions/template.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/functions/template.php,v > retrieving revision 1.75 > diff -u -r1.75 template.php > --- functions/template.php 15 Sep 2005 22:51:27 -0000 1.75 > +++ functions/template.php 29 Oct 2005 05:49:16 -0000 > @@ -21,7 +21,7 @@ > // Print Calendar Checkboxes > $COLUMNS_TO_PRINT = 3; > $column = 1; > - $filelist = availableCalendarNames('', '', '', true); > + $filelist = availableCalendars('', '', '', true); > foreach ($filelist as $file) { > if ($column > $COLUMNS_TO_PRINT) { > $delete_table .= '</tr>'; > @@ -31,7 +31,7 @@ > $delete_table .= '<tr>'; > } > > - $cal_filename_tmp = substr($file,0,-4); > + $cal_filename_tmp = getCalendarName($file); > $cal_tmp = urlencode($file); > $cal_displayname_tmp = str_replace("32", " ", > $cal_filename_tmp); > > Index: rss/index.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/rss/index.php,v > retrieving revision 1.37 > diff -u -r1.37 index.php > --- rss/index.php 7 Sep 2005 04:48:42 -0000 1.37 > +++ rss/index.php 29 Oct 2005 05:49:16 -0000 > @@ -19,12 +19,12 @@ > $current_view = "rssindex"; > $display_date = "RSS Info"; > > -$filelist = availableCalendarNames($username, $password, > $ALL_CALENDARS_COMBINED); > +$filelist = availableCalendars($username, $password, > $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 > // $cal_displayname is $cal_filename with occurrences of "32" > replaced with " " > - $cal_filename_tmp = substr($file,0,-4); > + $cal_filename_tmp = getCalendarName($file); > $cal_tmp = urlencode($cal_filename_tmp); > $cal_displayname_tmp = str_replace("32", " ", $cal_filename_tmp); > $rss_list .= '<font class="V12" color="blue"><b>'. > $cal_displayname_tmp.' '. $calendar_lang.'</b></font><br />'; > @@ -75,4 +75,4 @@ > $page->output(); > > > -?> > \ No newline at end of file > +?> > Index: rss/rss.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/rss/rss.php,v > retrieving revision 1.27 > diff -u -r1.27 rss.php > --- rss/rss.php 5 Oct 2005 00:29:13 -0000 1.27 > +++ rss/rss.php 29 Oct 2005 05:49:17 -0000 > @@ -15,9 +15,6 @@ > die ("RSS feeds are not enabled on this site."); > } > > -$default_path = 'http://'.$HTTP_SERVER_VARS['SERVER_NAME'].':'. > $HTTP_SERVER_VARS['SERVER_PORT'].substr($HTTP_SERVER_VARS > ['PHP_SELF'],0,strpos($HTTP_SERVER_VARS['PHP_SELF'],'/rss/')); > - > - > //set the range of days to return based on the view chosen > $rssview = $_GET['rssview']; > > > --Apple-Mail-6--212894681 > Content-Transfer-Encoding: 7bit > Content-Type: text/plain; > charset=US-ASCII; > format=flowed > > > > --Apple-Mail-6--212894681-- > > > --__--__-- > > Message: 2 > To: php...@li... > From: Wesley Miaw <we...@we...> > Date: Sat, 29 Oct 2005 13:12:51 -0700 > Subject: [PHPiCalendar-DEV] Patch for 1305320/1304709 > Reply-To: php...@li... > > > --Apple-Mail-7--161767004 > Content-Transfer-Encoding: 7bit > Content-Type: text/plain; > charset=US-ASCII; > delsp=yes; > format=flowed > > Hi People, > > I know these bugs were assigned to Jared, but I wanted to get them > fixed. However, there are a few decisions in the previous code that I > could not figure out the purpose of. So please test this patch to see > if my logic changes have broken anything for you. They seem to be > working fine on my calendars. > > Thanks, > -- > Wesley Miaw > we...@we... > > > --Apple-Mail-7--161767004 > Content-Transfer-Encoding: 7bit > Content-Type: application/octet-stream; > x-mac-type=54455854; > x-unix-mode=0644; > name="todo.diff" > Content-Disposition: attachment; > filename=todo.diff > > Index: ical_parser.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ > ical_parser.php,v > retrieving revision 1.196 > diff -u -r1.196 ical_parser.php > --- ical_parser.php 14 Sep 2005 00:42:32 -0000 1.196 > +++ ical_parser.php 29 Oct 2005 20:12:18 -0000 > @@ -805,101 +804,17 @@ > // Start VTODO Parsing > // > case 'DUE': > - $data = str_replace ('/softwarestudio.org/ > Olson_20011030_5/', '', $data); > - $zulu_time = false; > - if (substr($data,-1) == 'Z') $zulu_time = > true; > - $data = str_replace('T', '', $data); > - $data = str_replace('Z', '', $data); > - if (preg_match("/^DUE;VALUE=DATE/i", > $field)) { > - $allday_start = $data; > - $start_date = $allday_start; > - $start_unixtime = strtotime($data); > - $due_date = date('Ymd', $start_unixtime); > - } else { > - if (preg_match("/^DUE;TZID=/i", > $field)) { > - $tz_tmp = explode('=', $field); > - $tz_due = $tz_tmp[1]; > - unset($tz_tmp); > - } elseif ($zulu_time) { > - $tz_due = 'GMT'; > - } > - > - ereg ('([0-9]{4})([0-9]{2})([0-9]{2}) > ([0-9]{0,2})([0-9]{0,2})', $data, $regs); > - $due_date = $regs[1] . $regs[2] . $regs > [3]; > - $due_time = $regs[4] . $regs[5]; > - $start_unixtime = mktime($regs[4], > $regs[5], 0, $regs[2], $regs[3], $regs[1]); > - > - $dlst = date('I', $start_unixtime); > - $server_offset_tmp = chooseOffset > ($start_unixtime); > - if (isset($tz_due)) { > - if (array_key_exists($tz_due, > $tz_array)) { > - $offset_tmp = $tz_array > [$tz_due][$dlst]; > - } else { > - $offset_tmp = '+0000'; > - } > - } elseif (isset($calendar_tz)) { > - if (array_key_exists($calendar_tz, > $tz_array)) { > - $offset_tmp = $tz_array > [$calendar_tz][$dlst]; > - } else { > - $offset_tmp = '+0000'; > - } > - } else { > - $offset_tmp = $server_offset_tmp; > - } > - $start_unixtime = calcTime > ($offset_tmp, $server_offset_tmp, $start_unixtime); > - $due_date = date('Ymd', $start_unixtime); > - $due_time = date('Hi', $start_unixtime); > - unset($server_offset_tmp); > - } > + $datetime = extractDateTime($data, > $property, $field); > + $due_date = $datetime[1]; > + $due_time = $datetime[2]; > break; > > case 'COMPLETED': > - $data = str_replace ('/softwarestudio.org/ > Olson_20011030_5/', '', $data); > - $zulu_time = false; > - if (substr($data,-1) == 'Z') $zulu_time = > true; > - $data = str_replace('T', '', $data); > - $data = str_replace('Z', '', $data); > - if (preg_match("/^COMPLETED;VALUE=DATE/i", > $field)) { > - $allday_start = $data; > - $start_date = $allday_start; > - } else { > - if (preg_match("/^COMPLETED;TZID=/i", > $field)) { > - $tz_tmp = explode('=', $field); > - $tz_completed = $tz_tmp[1]; > - unset($tz_tmp); > - } elseif ($zulu_time) { > - $tz_completed = 'GMT'; > - } > - > - ereg ('([0-9]{4})([0-9]{2})([0-9]{2}) > ([0-9]{0,2})([0-9]{0,2})', $data, $regs); > - $completed_date = $regs[1] . $regs > [2] . $regs[3]; > - $completed_time = $regs[4] . $regs[5]; > - $start_unixtime = mktime($regs[4], > $regs[5], 0, $regs[2], $regs[3], $regs[1]); > - > - $dlst = date('I', $start_unixtime); > - $server_offset_tmp = chooseOffset > ($start_unixtime); > - if (isset($tz_completed)) { > - if (array_key_exists > ($tz_completed, $tz_array)) { > - $offset_tmp = $tz_array > [$tz_completed][$dlst]; > - } else { > - $offset_tmp = '+0000'; > - } > - } elseif (isset($calendar_tz)) { > - if (array_key_exists($calendar_tz, > $tz_array)) { > - $offset_tmp = $tz_array > [$calendar_tz][$dlst]; > - } else { > - $offset_tmp = '+0000'; > - } > - } else { > - $offset_tmp = $server_offset_tmp; > - } > - $start_unixtime = calcTime > ($offset_tmp, $server_offset_tmp, $start_unixtime); > - $completed_date = date('Ymd', > $start_unixtime); > - $completed_time = date('Hi', > $start_unixtime); > - unset($server_offset_tmp); > - } > - break; > - > + $datetime = extractDateTime($data, > $property, $field); > + $completed_date = $datetime[1]; > + $completed_time = $datetime[2]; > + break; > + > case 'PRIORITY': > $vtodo_priority = "$data"; > break; > @@ -914,111 +829,24 @@ > > case 'CATEGORIES': > $vtodo_categories = "$data"; > - break; > + break; > // > // End VTODO Parsing > > case 'DTSTART': > - $data = str_replace ('/softwarestudio.org/ > Olson_20011030_5/', '', $data); > - $zulu_time = false; > - if (substr($data,-1) == 'Z') $zulu_time = > true; > - $data = str_replace('T', '', $data); > - $data = str_replace('Z', '', $data); > - $field = str_replace(';VALUE=DATE-TIME', > '', $field); > - if ((preg_match("/^DTSTART;VALUE=DATE/i", > $field)) || (ereg ('^([0-9]{4})([0-9]{2})([0-9]{2})$', $data))) { > - ereg ('([0-9]{4})([0-9]{2})([0-9] > {2})', $data, $dtstart_check); > - if ($dtstart_check[1] < 1970) { > - $data = '1971'.$dtstart_check[2]. > $dtstart_check[3]; > - } > - $allday_start = $data; > - $start_date = $allday_start; > - $start_unixtime = strtotime($data); > - } else { > - if (preg_match("/^DTSTART;TZID=/i", > $field)) { > - $tz_tmp = explode('=', $field); > - $tz_dtstart = $tz_tmp[1]; > - unset($tz_tmp); > - } elseif ($zulu_time) { > - $tz_dtstart = 'GMT'; > - } > - > - preg_match ('/([0-9]{4})([0-9]{2}) > ([0-9]{2})([0-9]{0,2})([0-9]{0,2})/', $data, $regs); > - if ($regs[1] < 1970) { > - $regs[1] = '1971'; > - } > - $start_date = $regs[1] . $regs[2] . > $regs[3]; > - $start_time = $regs[4] . $regs[5]; > - $start_unixtime = mktime($regs[4], > $regs[5], 0, $regs[2], $regs[3], $regs[1]); > - > - $dlst = date('I', $start_unixtime); > - $server_offset_tmp = chooseOffset > ($start_unixtime); > - if (isset($tz_dtstart)) { > - if (array_key_exists($tz_dtstart, > $tz_array)) { > - $offset_tmp = $tz_array > [$tz_dtstart][$dlst]; > - } else { > - $offset_tmp = '+0000'; > - } > - } elseif (isset($calendar_tz)) { > - if (array_key_exists($calendar_tz, > $tz_array)) { > - $offset_tmp = $tz_array > [$calendar_tz][$dlst]; > - } else { > - $offset_tmp = '+0000'; > - } > - } else { > - $offset_tmp = $server_offset_tmp; > - } > - $start_unixtime = calcTime > ($offset_tmp, $server_offset_tmp, $start_unixtime); > - $start_date = date('Ymd', > $start_unixtime); > - $start_time = date('Hi', > $start_unixtime); > - unset($server_offset_tmp, $offset_tmp, > $tz_dtstart); > - } > + $datetime = extractDateTime($data, > $property, $field); > + $start_unixtime = $datetime[0]; > + $start_date = $datetime[1]; > + $start_time = $datetime[2]; > + $allday_start = $datetime[3]; > break; > > case 'DTEND': > - $data = str_replace ('/softwarestudio.org/ > Olson_20011030_5/', '', $data); > - $zulu_time = false; > - if (substr($data,-1) == 'Z') $zulu_time = > true; > - $data = str_replace('T', '', $data); > - $data = str_replace('Z', '', $data); > - $field = str_replace(';VALUE=DATE-TIME', > '', $field); > - if (preg_match("/^DTEND;VALUE=DATE/i", > $field)) { > - preg_match ('/([0-9]{4})([0-9]{2}) > ([0-9]{2})/', $data, $dtend_check); > - if ($dtend_check[1] < 1970) { > - $data = '1971'.$dtend_check[2]. > $dtend_check[3]; > - } > - $allday_end = $data; > - } else { > - if (preg_match("/^DTEND;TZID=/i", > $field)) { > - $tz_tmp = explode('=', $field); > - $tz_dtend = $tz_tmp[1]; > - unset($tz_tmp); > - } elseif ($zulu_time) { > - $tz_dtend = 'GMT'; > - } > - > - preg_match ('/([0-9]{4})([0-9]{2}) > ([0-9]{2})([0-9]{0,2})([0-9]{0,2})/', $data, $regs); > - if ($regs[1] < 1970) { > - $regs[1] = '1971'; > - } > - $end_date = $regs[1] . $regs[2] . $regs > [3]; > - $end_time = $regs[4] . $regs[5]; > - $end_unixtime = mktime($regs[4], $regs > [5], 0, $regs[2], $regs[3], $regs[1]); > - > - $dlst = date('I', $end_unixtime); > - $server_offset_tmp = chooseOffset > ($end_unixtime); > - if (isset($tz_dtend)) { > - $offset_tmp = $tz_array[$tz_dtend] > [$dlst]; > - } elseif (isset($calendar_tz)) { > - $offset_tmp = $tz_array > [$calendar_tz][$dlst]; > - } else { > - $offset_tmp = $server_offset_tmp; > - } > - $end_unixtime = calcTime($offset_tmp, > $server_offset_tmp, $end_unixtime); > - $end_date = date('Ymd', $end_unixtime); > - $end_time = date('Hi', $end_unixtime); > - unset($server_offset_tmp, $offset_tmp, > $tz_dtend); > - > - } > + $datetime = extractDateTime($data, > $property, $field); > + $end_unixtime = $datetime[0]; > + $end_date = $datetime[1]; > + $end_time = $datetime[2]; > + $allday_end = $datetime[3]; > break; > > case 'EXDATE': > @@ -1042,6 +870,7 @@ > $data = str_replace("\\t", " ", $data); > $data = str_replace("\\r", "<br />", $data); > $data = str_replace('$', '$', $data); > + $data = stripslashes($data); > $data = htmlentities(urlencode($data)); > if ($valarm_set == FALSE) { > $summary = $data; > @@ -1055,6 +884,7 @@ > $data = str_replace("\\t", " ", $data); > $data = str_replace("\\r", "<br />", $data); > $data = str_replace('$', '$', $data); > + $data = stripslashes($data); > $data = htmlentities(urlencode($data)); > if ($valarm_set == FALSE) { > $description = $data; > @@ -1141,17 +971,18 @@ > case 'ATTENDEE': > $field = str_replace > ("ATTENDEE;CN=", "", $field); > $data = str_replace ("mailto:", > "", $data); > - $attendee[] = array ('name' => $field, > 'email' => $data); > + $attendee[] = array ('name' => stripslashes > ($field), 'email' => stripslashes($data)); > break; > case 'ORGANIZER': > $field = str_replace > ("ORGANIZER;CN=", "", $field); > $data = str_replace ("mailto:", > "", $data); > - $organizer[] = array ('name' => $field, > 'email' => $data); > + $organizer[] = array ('name' => > stripslashes($field), 'email' => stripslashes($data)); > break; > case 'LOCATION': > $data = str_replace("\\n", "<br />", $data); > $data = str_replace("\\t", " ", $data); > $data = str_replace("\\r", "<br />", $data); > + $data = stripslashes($data); > $location = $data; > break; > case 'URL': > Index: date_functions.php > =================================================================== > RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ > date_functions.php,v > retrieving revision 1.29 > diff -u -r1.29 date_functions.php > --- date_functions.php 15 Sep 2005 22:51:27 -0000 1.29 > +++ date_functions.php 29 Oct 2005 20:12:18 -0000 > @@ -206,4 +206,91 @@ > > return $return; > } > + > +// Returns an array of the date and time extracted from the data > +// passed in. This array contains (unixtime, date, time, allday). > +// > +// $data = A string representing a date-time per RFC2445. > +// $property = The property being examined, e.g. DTSTART, DTEND. > +// $field = The full field being examined, e.g. > DTSTART;TZID=US/Pacific > +function extractDateTime($data, $property, $field) { > + global $tz_array; > + > + // Initialize values. > + unset($unixtime, $date, $time, $allday); > + > + // What the heck is this doing in here? > + $data = str_replace ('/softwarestudio.org/Olson_20011030_5/', > '', $data); > + > + // Check for zulu time. > + $zulu_time = false; > + if (substr($data,-1) == 'Z') $zulu_time = true; > + $data = str_replace('Z', '', $data); > + > + // Remove some substrings we don't want to look at. > + $data = str_replace('T', '', $data); > + $field = str_replace(';VALUE=DATE-TIME', '', $field); > + > + // Extract date-only values. > + if ((preg_match('/^'.$property.';VALUE=DATE/i', $field)) || > (ereg ('^([0-9]{4})([0-9]{2})([0-9]{2})$', $data))) { > + // Pull out the date value. Minimum year is 1970. > + ereg ('([0-9]{4})([0-9]{2})([0-9]{2})', $data, $dt_check); > + if ($dt_check[1] < 1970) { > + $data = '1971'.$dt_check[2].$dt_check[3]; > + } > + > + // Set the values. > + $unixtime = strtotime($data); > + $date = date('Ymd', $unixtime); > + $allday = $data; > + } > + > + // Extract date-time values. > + else { > + // Pull out the timezone, or use GMT if zulu time was > indicated. > + if (preg_match('/^'.$property.';TZID=/i', $field)) { > + $tz_tmp = explode('=', $field); > + $tz_dt = $tz_tmp[1]; > + unset($tz_tmp); > + } elseif ($zulu_time) { > + $tz_dt = 'GMT'; > + } > + > + // Pull out the date and time values. Minimum year is 1970. > + preg_match ('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2}) > ([0-9]{0,2})/', $data, $regs); > + if ($regs[1] < 1970) { > + $regs[1] = '1971'; > + } > + $date = $regs[1] . $regs[2] . $regs[3]; > + $time = $regs[4] . $regs[5]; > + $unixtime = mktime($regs[4], $regs[5], 0, $regs[2], $regs > [3], $regs[1]); > + > + // Check for daylight savings time. > + $dlst = date('I', $unixtime); > + $server_offset_tmp = chooseOffset($unixtime); > + if (isset($tz_dt)) { > + if (array_key_exists($tz_dt, $tz_array)) { > + $offset_tmp = $tz_array[$tz_dt][$dlst]; > + } else { > + $offset_tmp = '+0000'; > + } > + } elseif (isset($calendar_tz)) { > + if (array_key_exists($calendar_tz, $tz_array)) { > + $offset_tmp = $tz_array[$calendar_tz][$dlst]; > + } else { > + $offset_tmp = '+0000'; > + } > + } else { > + $offset_tmp = $server_offset_tmp; > + } > + > + // Set the values. > + $unixtime = calcTime($offset_tmp, $server_offset_tmp, > $unixtime); > + $date = date('Ymd', $unixtime); > + $time = date('Hi', $unixtime); > + } > + > + // Return the results. > + return array($unixtime, $date, $time, $allday); > +} > ?> > > --Apple-Mail-7--161767004-- > > > > --__--__-- > > _______________________________________________ > Phpicalendar-devel mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpicalendar-devel > > > End of Phpicalendar-devel Digest > |