aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjwangen <jwangen>2002-11-02 04:20:37 +0000
committerjwangen <jwangen>2002-11-02 04:20:37 +0000
commitc1b79428e7e0ce1c094457932e1941fd397768ce (patch)
tree3acda09508243f442203adafeb23657b6f81c13b
parent405e76ca59ed46f0af3a7e518c62cda469c1519c (diff)
downloadphpicalendar-c1b79428e7e0ce1c094457932e1941fd397768ce.tar.gz
phpicalendar-c1b79428e7e0ce1c094457932e1941fd397768ce.tar.bz2
phpicalendar-c1b79428e7e0ce1c094457932e1941fd397768ce.zip
cutting down on some of the repeating regexp in effort to speed parser
-rw-r--r--calendars/School.ics104
-rw-r--r--calendars/default.ics4
-rw-r--r--config.inc.php6
-rw-r--r--functions/ical_parser.php377
-rw-r--r--functions/init.inc.php2
5 files changed, 260 insertions, 233 deletions
diff --git a/calendars/School.ics b/calendars/School.ics
index 20c6a0f..c0d3dfa 100644
--- a/calendars/School.ics
+++ b/calendars/School.ics
@@ -3,83 +3,83 @@ CALSCALE:GREGORIAN
X-WR-TIMEZONE;VALUE=TEXT:US/Central
PRODID:-//Apple Computer\, Inc//iCal 1.0//EN
X-WR-CALNAME;VALUE=TEXT:School
-X-WR-RELCALID;VALUE=TEXT:7400C75A-EC34-11D6-B2E3-0050E4E60429
+X-WR-RELCALID;VALUE=TEXT:179767CA-EE1A-11D6-A6EB-0050E4E60429
VERSION:2.0
BEGIN:VEVENT
-DTSTART;TZID=US/Central:20020904T080000
+UID:179653BA-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T235007Z
SUMMARY:Computer Organization
-EXDATE;TZID=US/Central:20021010T080000
-EXDATE;TZID=US/Central:20021129T080000
-EXDATE;TZID=US/Central:20021001T080000
EXDATE;TZID=US/Central:20021018T080000
-EXDATE;TZID=US/Central:20021128T080000
-EXDATE;TZID=US/Central:20021021T080000
EXDATE;TZID=US/Central:20021112T080000
EXDATE;TZID=US/Central:20021002T080000
-UID:73FFD768-EC34-11D6-B2E3-0050E4E60429
+EXDATE;TZID=US/Central:20021129T080000
+EXDATE;TZID=US/Central:20021010T080000
+EXDATE;TZID=US/Central:20021128T080000
+EXDATE;TZID=US/Central:20021001T080000
+EXDATE;TZID=US/Central:20021021T080000
+DTSTART;TZID=US/Central:20020904T080000
DTEND;TZID=US/Central:20020904T090000
RRULE:FREQ=WEEKLY;UNTIL=20021214T055959;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR
END:VEVENT
BEGIN:VEVENT
-DTSTART;TZID=US/Central:20020904T090000
+UID:17965C2C-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021030T181835Z
SUMMARY:Linguistics
-EXDATE;TZID=US/Central:20021018T090000
-EXDATE;TZID=US/Central:20021108T090000
EXDATE;TZID=US/Central:20021002T090000
-EXDATE;TZID=US/Central:20021021T090000
+EXDATE;TZID=US/Central:20021108T090000
EXDATE;TZID=US/Central:20021129T090000
-UID:73FFE032-EC34-11D6-B2E3-0050E4E60429
+EXDATE;TZID=US/Central:20021018T090000
+EXDATE;TZID=US/Central:20021021T090000
+DTSTART;TZID=US/Central:20020904T090000
DTEND;TZID=US/Central:20020904T100000
RRULE:FREQ=WEEKLY;UNTIL=20021214T055959;INTERVAL=1;BYDAY=MO,WE,FR
END:VEVENT
BEGIN:VEVENT
-DTSTART;TZID=US/Central:20020904T103000
+UID:17966D68-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T233307Z
SUMMARY:First Aid & CPR
EXDATE;TZID=US/Central:20021021T103000
EXDATE;TZID=US/Central:20021002T103000
-UID:73FFEF46-EC34-11D6-B2E3-0050E4E60429
+DTSTART;TZID=US/Central:20020904T103000
DTEND;TZID=US/Central:20020904T113000
RRULE:FREQ=WEEKLY;UNTIL=20021214T055959;INTERVAL=1;BYDAY=MO,WE
END:VEVENT
BEGIN:VEVENT
-DTSTART;TZID=US/Central:20020904T133000
+UID:179672EC-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T235015Z
SUMMARY:Japanese
-EXDATE;TZID=US/Central:20021129T133000
-EXDATE;TZID=US/Central:20021021T133000
-EXDATE;TZID=US/Central:20021001T133000
EXDATE;TZID=US/Central:20021002T133000
+EXDATE;TZID=US/Central:20021021T133000
EXDATE;TZID=US/Central:20021018T133000
-UID:73FFF408-EC34-11D6-B2E3-0050E4E60429
+EXDATE;TZID=US/Central:20021129T133000
+EXDATE;TZID=US/Central:20021001T133000
+DTSTART;TZID=US/Central:20020904T133000
DTEND;TZID=US/Central:20020904T143000
RRULE:FREQ=WEEKLY;UNTIL=20021214T055959;INTERVAL=1;BYDAY=MO,TU,WE,FR
END:VEVENT
BEGIN:VEVENT
-DTSTART;TZID=US/Central:20020905T143000
+UID:17967888-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021030T180513Z
SUMMARY:The Bible
EXDATE;TZID=US/Central:20021001T143000
EXDATE;TZID=US/Central:20021024T143000
EXDATE;TZID=US/Central:20021128T143000
-UID:73FFF8D5-EC34-11D6-B2E3-0050E4E60429
+DTSTART;TZID=US/Central:20020905T143000
DTEND;TZID=US/Central:20020905T163000
RRULE:FREQ=WEEKLY;UNTIL=20021216T055959;INTERVAL=1;BYDAY=TU,TH
END:VEVENT
BEGIN:VEVENT
-UID:73FFFD56-EC34-11D6-B2E3-0050E4E60429
+UID:17967E06-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20020919T031814Z
SUMMARY:Reading Day
DTSTART;VALUE=DATE:20021214
DTEND;VALUE=DATE:20021215
END:VEVENT
BEGIN:VEVENT
-DTSTART;TZID=US/Central:20021219T153000
+UID:17968370-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20020919T042240Z
SUMMARY:Japanese Final
-UID:74003E05-EC34-11D6-B2E3-0050E4E60429
+DTSTART;TZID=US/Central:20021219T153000
ORGANIZER;CN=Jared Wangen:mailto:jwangen@gac.edu
DTEND;TZID=US/Central:20021219T173000
DESCRIPTION:VH 301
@@ -87,59 +87,59 @@ END:VEVENT
BEGIN:VEVENT
DTSTAMP:20020919T041543Z
SUMMARY:The Bible Final
-DTSTART;TZID=US/Central:20021217T103000
+UID:179688FE-EE1A-11D6-A6EB-0050E4E60429
ORGANIZER;CN=Jared Wangen:mailto:jwangen@gac.edu
-DESCRIPTION:NHS Auditorium
-UID:740044D2-EC34-11D6-B2E3-0050E4E60429
+DTSTART;TZID=US/Central:20021217T103000
DURATION:PT2H
+DESCRIPTION:NHS Auditorium
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20020919T033447Z
SUMMARY:Computer Organization Final
+UID:17968E62-EE1A-11D6-A6EB-0050E4E60429
DTSTART;TZID=US/Central:20021218T080000
-UID:7400494D-EC34-11D6-B2E3-0050E4E60429
DURATION:PT2H
DESCRIPTION:Olin 321 (Classroom)
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20020919T033454Z
SUMMARY:Linguistics Final
+UID:179693B0-EE1A-11D6-A6EB-0050E4E60429
DTSTART;TZID=US/Central:20021217T130000
-UID:74004DD2-EC34-11D6-B2E3-0050E4E60429
DURATION:PT2H
DESCRIPTION:VH 202 (Classroom)
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20020919T033438Z
SUMMARY:CPR & First Aid Final
+UID:17969902-EE1A-11D6-A6EB-0050E4E60429
DTSTART;TZID=US/Central:20021217T080000
-UID:74005246-EC34-11D6-B2E3-0050E4E60429
DURATION:PT2H
DESCRIPTION:Lund 109 (Classroom)
END:VEVENT
BEGIN:VEVENT
-UID:740056C2-EC34-11D6-B2E3-0050E4E60429
+UID:1796EDF6-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T233220Z
SUMMARY:Fall Break
DTSTART;VALUE=DATE:20021018
DTEND;VALUE=DATE:20021022
END:VEVENT
BEGIN:VEVENT
-UID:74005BC7-EC34-11D6-B2E3-0050E4E60429
+UID:1796F4B8-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T233332Z
SUMMARY:Nobel Conference
DTSTART;VALUE=DATE:20021001
DTEND;VALUE=DATE:20021003
END:VEVENT
BEGIN:VEVENT
-UID:74006098-EC34-11D6-B2E3-0050E4E60429
+UID:17970B20-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T234504Z
SUMMARY:CS - Lab 1 Due
DTSTART;VALUE=DATE:20021003
DTEND;VALUE=DATE:20021004
END:VEVENT
BEGIN:VEVENT
-UID:74006524-EC34-11D6-B2E3-0050E4E60429
+UID:179711DA-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T234552Z
SUMMARY:CS - HW Ch 1-4\,A\,B Due
DTSTART;VALUE=DATE:20021008
@@ -149,18 +149,18 @@ BEGIN:VEVENT
DTSTAMP:20021024T234631Z
SUMMARY:Computer Organization Test 1
DTEND;TZID=US/Central:20021010T203000
-UID:74007B3B-EC34-11D6-B2E3-0050E4E60429
DTSTART;TZID=US/Central:20021010T190000
+UID:1797176E-EE1A-11D6-A6EB-0050E4E60429
END:VEVENT
BEGIN:VEVENT
-UID:7400805F-EC34-11D6-B2E3-0050E4E60429
+UID:17971CB6-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T234720Z
SUMMARY:CS - Lab 2 Due
DTSTART;VALUE=DATE:20021101
DTEND;VALUE=DATE:20021102
END:VEVENT
BEGIN:VEVENT
-UID:74008510-EC34-11D6-B2E3-0050E4E60429
+UID:17972228-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T234754Z
SUMMARY:CS - HW Ch 5-6 Due
DTSTART;VALUE=DATE:20021111
@@ -170,39 +170,39 @@ BEGIN:VEVENT
DTSTAMP:20021024T234841Z
SUMMARY:Computer Organization Test 2
DTEND;TZID=US/Central:20021112T203000
-UID:740089B4-EC34-11D6-B2E3-0050E4E60429
DTSTART;TZID=US/Central:20021112T190000
+UID:17972788-EE1A-11D6-A6EB-0050E4E60429
END:VEVENT
BEGIN:VEVENT
-DTSTAMP:20021024T234904Z
+DTSTAMP:20021102T041802Z
SUMMARY:CS - Lab 3 Due
-UID:74008E30-EC34-11D6-B2E3-0050E4E60429
-DTSTART;TZID=US/Central:20021118T150000
-DURATION:PT1H45M
+UID:17972CDC-EE1A-11D6-A6EB-0050E4E60429
+DTSTART;VALUE=DATE:20021118
+DTEND;VALUE=DATE:20021119
END:VEVENT
BEGIN:VEVENT
-UID:740092C0-EC34-11D6-B2E3-0050E4E60429
+UID:1797323A-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T235055Z
SUMMARY:Thanksgiving Break
DTSTART;VALUE=DATE:20021128
DTEND;VALUE=DATE:20021202
END:VEVENT
BEGIN:VEVENT
-UID:740098ED-EC34-11D6-B2E3-0050E4E60429
+UID:179737BE-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T235244Z
SUMMARY:CS - Lab 4 Due
DTSTART;VALUE=DATE:20021209
DTEND;VALUE=DATE:20021210
END:VEVENT
BEGIN:VEVENT
-UID:74009D95-EC34-11D6-B2E3-0050E4E60429
+UID:17973D1C-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021024T235322Z
SUMMARY:CS - HW Ch 7-9 Due
DTSTART;VALUE=DATE:20021213
DTEND;VALUE=DATE:20021214
END:VEVENT
BEGIN:VEVENT
-UID:7400A566-EC34-11D6-B2E3-0050E4E60429
+UID:1797431C-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021030T180640Z
SUMMARY:Ling - Journal Due: Phonology
DTSTART;VALUE=DATE:20021104
@@ -212,33 +212,33 @@ BEGIN:VEVENT
DTSTAMP:20021030T180940Z
RECURRENCE-ID;TZID=US/Central:20021106T090000
DTSTART;TZID=US/Central:20021106T090000
-UID:73FFE032-EC34-11D6-B2E3-0050E4E60429
+UID:17965C2C-EE1A-11D6-A6EB-0050E4E60429
DURATION:PT1H
DESCRIPTION:Meet in Library Computer Lab
END:VEVENT
BEGIN:VEVENT
-UID:73FFE032-EC34-11D6-B2E3-0050E4E60429
RECURRENCE-ID;TZID=US/Central:20021111T090000
+UID:17965C2C-EE1A-11D6-A6EB-0050E4E60429
DTSTART;TZID=US/Central:20021111T090000
DURATION:PT1H
DESCRIPTION:Meet in Confer 230
END:VEVENT
BEGIN:VEVENT
-UID:7400AAE0-EC34-11D6-B2E3-0050E4E60429
+UID:179748A4-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021030T181349Z
SUMMARY:Ling - Rough Draft for Paper 1 Due
DTSTART;VALUE=DATE:20021111
DTEND;VALUE=DATE:20021112
END:VEVENT
BEGIN:VEVENT
-UID:7400AF8D-EC34-11D6-B2E3-0050E4E60429
+UID:17974E1A-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021030T181450Z
SUMMARY:CPR - Red Cross Written Test
DTSTART;VALUE=DATE:20021106
DTEND;VALUE=DATE:20021107
END:VEVENT
BEGIN:VEVENT
-UID:7400B448-EC34-11D6-B2E3-0050E4E60429
+UID:179753B2-EE1A-11D6-A6EB-0050E4E60429
DTSTAMP:20021030T181535Z
SUMMARY:Bible - Quiz 2
DTSTART;VALUE=DATE:20021105
diff --git a/calendars/default.ics b/calendars/default.ics
index a39010b..a0df229 100644
--- a/calendars/default.ics
+++ b/calendars/default.ics
@@ -63,11 +63,11 @@ END:VEVENT
BEGIN:VEVENT
SEQUENCE:5
DTSTAMP:20020926T031348Z
-SUMMARY:New Event
+SUMMARY:last sunday
UID:54C848A4-D456-11D6-A297-0050E4E60429
DTSTART;TZID=US/Central:20020922T113000
DURATION:PT1H
-RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=1SU
+RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=-2SU,-3FR
END:VEVENT
BEGIN:VEVENT
SEQUENCE:3
diff --git a/config.inc.php b/config.inc.php
index 2831762..ea68a5f 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -10,7 +10,7 @@ $calendar_path = './calendars'; // Path to directory with calendars
$default_view = 'day'; // Default view for calendars = 'day', 'week', 'month', 'year'
$minical_view = 'current'; // Where do the mini-calendars go when clicked? = 'day', 'week', 'month', 'current'
$default_cal = 'School'; // Exact filename of calendar without .ics
-$language = 'japanese'; // Language support - 'English', 'Polish', 'German', 'French', 'Dutch', 'Danish', 'Italian', 'Japanese', 'Norwegian', 'Spanish', 'Swedish', 'Portuguese'
+$language = 'English'; // Language support - 'English', 'Polish', 'German', 'French', 'Dutch', 'Danish', 'Italian', 'Japanese', 'Norwegian', 'Spanish', 'Swedish', 'Portuguese'
$week_start_day = 'Sunday'; // Day of the week your week starts on
$day_start = '0700'; // Start time for day grid
$gridLength = '15'; // Grid distance in minutes for day view, multiples of 15 preferred
@@ -19,7 +19,7 @@ $month_event_lines = '1'; // Number of lines to wrap each event title in mo
$tomorrows_events_lines = '1'; // Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines.
$allday_week_lines = '1'; // Number of lines to wrap each event title in all-day events in week view, 0 means display all lines.
$week_events_lines = '1'; // Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines.
-$timezone = 'Same as Server'; // Set timezone. Read TIMEZONES file for more information
+$timezone = ''; // Set timezone. Read TIMEZONES file for more information
$default_path = 'http://www.example.com/phpicalendar'; // The HTTP URL to the PHP iCalendar directory
$tmp_dir = '/tmp'; // The temporary directory on your system (/tmp is fine for UNIXes including Mac OS X)
@@ -41,7 +41,7 @@ $blacklisted_cals[] = ''; // list. This should be the exact calendar filenam
$blacklisted_cals[] = ''; // the parser will *not* parse any cal that is in this list (it will not be Web accessible)
// add more lines as necessary
-$list_webcals[] = 'http://icalx.com/public/carlos/Halloween.ics'; // Fill in between the quotes exact URL of a calendar that you wish
+$list_webcals[] = ''; // Fill in between the quotes exact URL of a calendar that you wish
$list_webcals[] = ''; // to show up in your calendar list. You must prefix the URL with http://
$list_webcals[] = ''; // or webcal:// and the filename should contain the .ics suffix
$list_webcals[] = ''; // $allow_webcals does *not* need to be "yes" for these to show up and work
diff --git a/functions/ical_parser.php b/functions/ical_parser.php
index 7bdc32a..f8b6487 100644
--- a/functions/ical_parser.php
+++ b/functions/ical_parser.php
@@ -2,7 +2,6 @@
define('BASE', './');
include(BASE.'functions/init.inc.php');
-include(BASE.'functions/date_add.php');
include(BASE.'functions/date_functions.php');
include(BASE.'functions/draw_functions.php');
include(BASE.'functions/overlapping_events.php');
@@ -377,10 +376,18 @@ if ($parse_file) {
} else {
// loop through the days on which this event happens
foreach($byday as $day) {
- ereg ('([\-\+]{0,1})([0-9]{1})([A-Z]{2})', $day, $byday_arr);
+ ereg ('([-\+]{0,1})([0-9]{1})([A-Z]{2})', $day, $byday_arr);
$nth = $byday_arr[2]-1;
$on_day = two2threeCharDays($byday_arr[3]);
- $next_date_time = strtotime($on_day.' +'.$nth.' week', $next_range_time);
+ $on_day_num = two2threeCharDays($byday_arr[3],false);
+ if ($byday_arr[1] == '-') {
+ $last_day_tmp = date('t',$next_range_time);
+ $next_range_time = strtotime(date('Y-m-'.$last_day_tmp, $next_range_time));
+ $last_tmp = (date('w',$next_range_time) == $on_day_num) ? '' : 'last ';
+ $next_date_time = strtotime($last_tmp.$on_day.' -'.$nth.' week', $next_range_time);
+ } else {
+ $next_date_time = strtotime($on_day.' +'.$nth.' week', $next_range_time);
+ }
$next_date = date('Ymd', $next_date_time);
$recur_data[] = $next_date_time;
}
@@ -393,10 +400,17 @@ if ($parse_file) {
if (is_array($byday)) {
$checkdate_time = mktime(0,0,0,$month,1,$year);
foreach($byday as $day) {
- ereg ('([\-\+]{0,1})([0-9]{1})([A-Z]{2})', $day, $byday_arr);
+ ereg ('([-\+]{0,1})([0-9]{1})([A-Z]{2})', $day, $byday_arr);
$nth = $byday_arr[2]-1;
$on_day = two2threeCharDays($byday_arr[3]);
- $next_date_time = strtotime($on_day.' +'.$nth.' week', $checkdate_time);
+ if ($byday_arr[1] == '-') {
+ $last_day_tmp = date('t',$checkdate_time);
+ $checkdate_time = strtotime(date('Y-m-'.$last_day_tmp, $checkdate_time));
+ $last_tmp = (date('w',$checkdate_time) == $on_day_num) ? '' : 'last ';
+ $next_date_time = strtotime($last_tmp.$on_day.' -'.$nth.' week', $checkdate_time);
+ } else {
+ $next_date_time = strtotime($on_day.' +'.$nth.' week', $checkdate_time);
+ }
}
} else {
$day = date('d', $start_date_time);
@@ -453,197 +467,210 @@ if ($parse_file) {
$valarm_set = FALSE;
} else {
- unset ($field, $data);
+ unset ($field, $data, $prop_pos, $property);
ereg ("([^:]+):(.*)", $line, $line);
$field = $line[1];
$data = $line[2];
- if (preg_match("/^DTSTART/i", $field)) {
- $zulu_time = false;
- if (substr($data,-1) == 'Z') $zulu_time = true;
- $data = ereg_replace('T', '', $data);
- $data = ereg_replace('Z', '', $data);
- if (preg_match("/^DTSTART;VALUE=DATE/i", $field)) {
- $allday_start = $data;
- //echo "$summary - $allday_start<br>";
- } 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';
- }
-
- ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs);
- $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];
+ $property = $field;
+ $prop_pos = strpos($property,';');
+ if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
+
+ switch ($property) {
+ case 'DTSTART':
+ $zulu_time = false;
+ if (substr($data,-1) == 'Z') $zulu_time = true;
+ $data = ereg_replace('T', '', $data);
+ $data = ereg_replace('Z', '', $data);
+ if (preg_match("/^DTSTART;VALUE=DATE/i", $field)) {
+ $allday_start = $data;
+ //echo "$summary - $allday_start<br>";
+ } 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';
+ }
+
+ ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs);
+ $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 = '+0000';
+ $offset_tmp = $server_offset_tmp;
}
- } elseif (isset($calendar_tz)) {
- if (array_key_exists($calendar_tz, $tz_array)) {
+ $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);
+ }
+ break;
+
+ case 'DTEND';
+ $zulu_time = false;
+ if (substr($data,-1) == 'Z') $zulu_time = true;
+ $data = ereg_replace('T', '', $data);
+ $data = ereg_replace('Z', '', $data);
+ if (preg_match("/^DTEND;VALUE=DATE/i", $field)) {
+ $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';
+ }
+
+ ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs);
+ $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 = '+0000';
+ $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);
+
+ }
+ break;
+
+ case 'EXDATE':
+ $data = split(",", $data);
+ foreach ($data as $exdata) {
+ $exdata = ereg_replace('T', '', $exdata);
+ $exdata = ereg_replace('Z', '', $exdata);
+ ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $exdata, $regs);
+ $except_dates[] = $regs[1] . $regs[2] . $regs[3];
+ $except_times[] = $regs[4] . $regs[5];
+ }
+ break;
+
+ case 'SUMMARY':
+ $data = str_replace("\\n", "<br>", $data);
+ $data = str_replace("\\r", "<br>", $data);
+ $data = htmlentities(urlencode($data));
+ $summary = $data;
+ break;
+
+ case 'DESCRIPTION':
+ $data = str_replace("\\n", "<br>", $data);
+ $data = str_replace("\\r", "<br>", $data);
+ $data = htmlentities(urlencode($data));
+ if ($valarm_set == FALSE) {
+ $description = $data;
} else {
- $offset_tmp = $server_offset_tmp;
+ $valarm_description = $data;
}
- $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);
- }
-
- } elseif (preg_match("/^DTEND/i", $field)) {
- $zulu_time = false;
- if (substr($data,-1) == 'Z') $zulu_time = true;
- $data = ereg_replace('T', '', $data);
- $data = ereg_replace('Z', '', $data);
- if (preg_match("/^DTEND;VALUE=DATE/i", $field)) {
- $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';
+ break;
+
+ case 'RECURRENCE-ID':
+ $parts = explode(';', $field);
+ foreach($parts as $part) {
+ $eachval = split('=',$part);
+ if ($eachval[0] == 'TZID') {
+ $recurrence_id['tzid'] = $eachval[1];
+ } elseif ($eachval[0] == 'RANGE') {
+ $recurrence_id['range'] = $eachval[1];
+ } elseif ($eachval[0] == 'VALUE') {
+ $recurrence_id['value'] = $eachval[1];
+ } else {
+ $recurrence_id[] = $eachval[1];
+ }
}
+ unset($parts, $part, $eachval);
+ $data = ereg_replace('T', '', $data);
+ $data = ereg_replace('Z', '', $data);
ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs);
- $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];
+ $recurrence_id['date'] = $regs[1] . $regs[2] . $regs[3];
+ $recurrence_id['time'] = $regs[4] . $regs[5];
+
+ $recur_unixtime = mktime($regs[4], $regs[5], 0, $regs[2], $regs[3], $regs[1]);
+
+ $dlst = date('I', $recur_unixtime);
+ $server_offset_tmp = chooseOffset($recur_unixtime);
+ if (isset($recurrence_id['tzid'])) {
+ $tz_tmp = $recurrence_id['tzid'];
+ $offset_tmp = $tz_array[$tz_tmp][$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);
+ $recur_unixtime = calcTime($offset_tmp, $server_offset_tmp, $recur_unixtime);
+ $recurrence_id['date'] = date('Ymd', $recur_unixtime);
+ $recurrence_id['time'] = date('Hi', $recur_unixtime);
unset($server_offset_tmp);
-
- }
-
- } elseif (preg_match("/^EXDATE/i", $field)) {
- $data = split(",", $data);
- foreach ($data as $exdata) {
- $exdata = ereg_replace('T', '', $exdata);
- $exdata = ereg_replace('Z', '', $exdata);
- ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $exdata, $regs);
- $except_dates[] = $regs[1] . $regs[2] . $regs[3];
- $except_times[] = $regs[4] . $regs[5];
- }
-
- } elseif (preg_match("/^SUMMARY/i", $field)) {
- $data = str_replace("\\n", "<br>", $data);
- $data = str_replace("\\r", "<br>", $data);
- $data = htmlentities(urlencode($data));
- $summary = $data;
-
- } elseif (preg_match("/^DESCRIPTION/i", $field)) {
- $data = str_replace("\\n", "<br>", $data);
- $data = str_replace("\\r", "<br>", $data);
- $data = htmlentities(urlencode($data));
- if ($valarm_set == FALSE) {
- $description = $data;
- } else {
- $valarm_description = $data;
- }
- } elseif (preg_match("/^RECURRENCE-ID/i", $field)) {
-
- $parts = split(';', $field);
- foreach($parts as $part) {
- $eachval = split('=',$part);
- if ($eachval[0] == 'TZID') {
- $recurrence_id['tzid'] = $eachval[1];
- } elseif ($eachval[0] == 'RANGE') {
- $recurrence_id['range'] = $eachval[1];
- } elseif ($eachval[0] == 'VALUE') {
- $recurrence_id['value'] = $eachval[1];
- } else {
- $recurrence_id[] = $eachval[1];
- }
- }
- unset($parts, $part, $eachval);
-
- $data = ereg_replace('T', '', $data);
- $data = ereg_replace('Z', '', $data);
- ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs);
- $recurrence_id['date'] = $regs[1] . $regs[2] . $regs[3];
- $recurrence_id['time'] = $regs[4] . $regs[5];
-
- $recur_unixtime = mktime($regs[4], $regs[5], 0, $regs[2], $regs[3], $regs[1]);
-
- $dlst = date('I', $recur_unixtime);
- $server_offset_tmp = chooseOffset($recur_unixtime);
- if (isset($recurrence_id['tzid'])) {
- $tz_tmp = $recurrence_id['tzid'];
- $offset_tmp = $tz_array[$tz_tmp][$dlst];
- } elseif (isset($calendar_tz)) {
- $offset_tmp = $tz_array[$calendar_tz][$dlst];
- } else {
- $offset_tmp = $server_offset_tmp;
- }
- $recur_unixtime = calcTime($offset_tmp, $server_offset_tmp, $recur_unixtime);
- $recurrence_id['date'] = date('Ymd', $recur_unixtime);
- $recurrence_id['time'] = date('Hi', $recur_unixtime);
- unset($server_offset_tmp);
-
- } elseif (preg_match("/^UID/i", $field)) {
- $uid = $data;
- } elseif (preg_match("/^X-WR-CALNAME/i", $field)) {
- $calendar_name = $data;
- $master_array['calendar_name'] = $calendar_name;
- } elseif (preg_match("/^X-WR-TIMEZONE/i", $field)) {
- $calendar_tz = $data;
- $master_array['calendar_tz'] = $calendar_tz;
- } elseif (preg_match("/^DURATION/i", $field)) {
-
- if (($first_duration == TRUE) && (!stristr($field, '=DURATION'))) {
- ereg ('^P([0-9]{1,2})?([W,D]{0,1}[T])?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?', $data, $duration);
- if ($duration[2] = 'W') {
- $weeks = $duration[1];
- $days = 0;
- } else {
- $days = $duration[1];
- $weeks = 0;
+ break;
+
+ case 'UID':
+ $uid = $data;
+ break;
+ case 'X-WR-CALNAME':
+ $calendar_name = $data;
+ $master_array['calendar_name'] = $calendar_name;
+ break;
+ case 'X-WR-TIMEZONE':
+ $calendar_tz = $data;
+ $master_array['calendar_tz'] = $calendar_tz;
+ break;
+ case 'DURATION':
+ if (($first_duration == TRUE) && (!stristr($field, '=DURATION'))) {
+ ereg ('^P([0-9]{1,2})?([W,D]{0,1}[T])?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?', $data, $duration);
+ if ($duration[2] = 'W') {
+ $weeks = $duration[1];
+ $days = 0;
+ } else {
+ $days = $duration[1];
+ $weeks = 0;
+ }
+ $hours = ereg_replace('H', '', $duration[3]);
+ $minutes = ereg_replace('M', '', $duration[4]);
+ $seconds = ereg_replace('S', '', $duration[5]);
+ $the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds);
+ $beginning = (strtotime($start_time) + $the_duration);
+ $end_time = date ('Hi', $beginning);
+ $first_duration = FALSE;
+ }
+ break;
+ case 'RRULE':
+ $data = ereg_replace ('RRULE:', '', $data);
+ $rrule = split (';', $data);
+ foreach ($rrule as $recur) {
+ ereg ('(.*)=(.*)', $recur, $regs);
+ $rrule_array[$regs[1]] = $regs[2];
}
- $hours = ereg_replace('H', '', $duration[3]);
- $minutes = ereg_replace('M', '', $duration[4]);
- $seconds = ereg_replace('S', '', $duration[5]);
- $the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds);
- $beginning = (strtotime($start_time) + $the_duration);
- $end_time = date ('Hi', $beginning);
- $first_duration = FALSE;
- }
-
- } elseif (preg_match("/^RRULE/i", $field)) {
- $data = ereg_replace ('RRULE:', '', $data);
- $rrule = split (';', $data);
- foreach ($rrule as $recur) {
- ereg ('(.*)=(.*)', $recur, $regs);
- $rrule_array[$regs[1]] = $regs[2];
- }
-
- } elseif (preg_match("/^ATTENDEE/i", $field)) {
- $attendee = $data;
-
+ break;
+ case 'ATTENDEE':
+ $attendee = $data;
+ break;
}
}
}
diff --git a/functions/init.inc.php b/functions/init.inc.php
index 669dd23..c92be45 100644
--- a/functions/init.inc.php
+++ b/functions/init.inc.php
@@ -3,7 +3,7 @@
// so I have this making sure they all are. This should be commented out/deleted
// for shipping versions. This is a convenience so when I commit, changes are made and
// I don't get errors.
-chmod(BASE.'calendars/School.ics',0666);
+//chmod(BASE.'calendars/School.ics',0666);
// uncomment when developing, comment for shipping version
//error_reporting (E_ALL);

© 2014-2024 Faster IT GmbH | imprint | privacy policy