comptability if (ereg("<([[:alpha:]]+://)([^<>[:space:]]+)>",$event_text,$matches)) { $full_event_text = $matches[1] . $matches[2]; $event_text = $matches[2]; } else { $full_event_text = $event_text; $event_text = strip_tags($event_text, ''); } if (!empty($event_text)) { if ($lines > 0) { $event_text = word_wrap($event_text, $length, $lines); } if ((!(ereg("([[:alpha:]]+://[^<>[:space:]]+)", $full_event_text, $res))) || ($arr['description'])) { $escaped_date = addslashes($event_date); $escaped_time = addslashes($time); $escaped_uid = addslashes($uid); $event_data = addslashes(serialize ($master_array[$event_date][$time][$uid])); // fix for URL-length bug in IE: populate and submit a hidden form on click static $popup_data_index = 0; $return = " "; $return .= ''; $popup_data_index++; } else { $return .= ''; } $return .= $pre_text.$event_text.$post_text.''."\n"; } 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); $allday =''; #suppress error on returning undef. // 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); $time = ''; $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 = parse_tz($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); } //TZIDs in calendars often contain leading information that should be stripped //Example: TZID=/mozilla.org/20050126_1/Europe/Berlin //Need to return the last part only function parse_tz($data){ $fields = explode("/",$data); $tz = array_pop($fields); $tmp = array_pop($fields); if (isset($tmp) && $tmp != "") $tz = "$tmp/$tz"; return $tz; } ?>