aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hu <jimhu@users.sourceforge.net>2008-12-15 17:25:27 +0000
committerJim Hu <jimhu@users.sourceforge.net>2008-12-15 17:25:27 +0000
commitcb1509c1c670974f54ed67d2076fef39e0d20812 (patch)
tree7f7f64c60ad63cf884cf5562565f46cffd3f9597
parent99cfde6479207ba9349d8c4a093ef14a1026154d (diff)
downloadphpicalendar-cb1509c1c670974f54ed67d2076fef39e0d20812.zip
phpicalendar-cb1509c1c670974f54ed67d2076fef39e0d20812.tar.gz
phpicalendar-cb1509c1c670974f54ed67d2076fef39e0d20812.tar.bz2
big changes to recurrence; trying to get closer to the spec
-rw-r--r--calendars/US Holidays.ics62
-rw-r--r--day.php13
-rw-r--r--functions/date_functions.php5
-rw-r--r--functions/ical_parser.php548
-rw-r--r--functions/init/set_error_reporting.php3
-rw-r--r--functions/parse/end_vevent.php391
-rw-r--r--functions/parse/overlapping_events.php4
-rw-r--r--functions/parse/parse_tzs.php4
-rw-r--r--functions/parse/recur_functions.php111
-rw-r--r--functions/template.php160
-rw-r--r--month.php8
-rw-r--r--week.php8
12 files changed, 647 insertions, 670 deletions
diff --git a/calendars/US Holidays.ics b/calendars/US Holidays.ics
index 8d3f758..4175848 100644
--- a/calendars/US Holidays.ics
+++ b/calendars/US Holidays.ics
@@ -74,17 +74,6 @@ RRULE:FREQ=MONTHLY;BYMONTH=2;BYDAY=3MO
END:VEVENT
BEGIN:VEVENT
-SUMMARY:Secretaries Day
-DESCRIPTION:Wednesday of last full week in April
-DTSTAMP:20030701T000000Z
-UID:holiday0032@icaldates.com
-CATEGORIES:Holiday - US
-DTSTART;VALUE=DATE:19520423
-RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=WE;BYMONTHDAY=25,26,27,21,22,23,24;BYMONTH=4
-END:VEVENT
-
-
-BEGIN:VEVENT
SUMMARY:Mardi Gras (Fat Tuesday)
DESCRIPTION:47 days before Easter
DTSTAMP:20030701T000000Z
@@ -95,7 +84,6 @@ X-WD-RECUR-EASTER:TRUE
X-WD-RECUR-OFFSET:-47
END:VEVENT
-
BEGIN:VEVENT
SUMMARY:St. Patrick's Day
DESCRIPTION:March 17
@@ -107,6 +95,16 @@ RRULE:FREQ=YEARLY
END:VEVENT
BEGIN:VEVENT
+SUMMARY:Daylight Savings +1 hr
+DESCRIPTION:2nd Sunday of March
+DTSTAMP:20030701T000000Z
+UID:holiday0009@icaldates.com
+CATEGORIES:Holiday - US
+DTSTART:20070311T020000
+RRULE:FREQ=MONTHLY;BYMONTH=3;BYDAY=2SU
+END:VEVENT
+
+BEGIN:VEVENT
SUMMARY:April Fools Day
DESCRIPTION:April 1
DTSTAMP:20030701T000000Z
@@ -117,13 +115,23 @@ RRULE:FREQ=YEARLY;INTERVAL=1;
END:VEVENT
BEGIN:VEVENT
-SUMMARY:Daylight Savings +1 hr
-DESCRIPTION:2nd Sunday of March
+SUMMARY:Secretaries Day
+DESCRIPTION:Wednesday of last full week in April
DTSTAMP:20030701T000000Z
-UID:holiday0009@icaldates.com
+UID:holiday0032@icaldates.com
CATEGORIES:Holiday - US
-DTSTART:20070311T020000
-RRULE:FREQ=MONTHLY;BYMONTH=3;BYDAY=2SU
+DTSTART;VALUE=DATE:19520423
+RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=WE;BYMONTHDAY=25,26,27,21,22,23,24;BYMONTH=4
+END:VEVENT
+
+BEGIN:VEVENT
+SUMMARY:Mother's Day
+DESCRIPTION:2nd Sunday of May
+DTSTAMP:20030701T000000Z
+UID:holiday0026@icaldates.com
+CATEGORIES:Holiday - US
+DTSTART;VALUE=DATE:17530513
+RRULE:FREQ=MONTHLY;BYMONTH=5;BYDAY=2SU
END:VEVENT
BEGIN:VEVENT
@@ -147,13 +155,13 @@ RRULE:FREQ=MONTHLY;BYMONTH=5;BYDAY=-1MO
END:VEVENT
BEGIN:VEVENT
-SUMMARY:Mother's Day
-DESCRIPTION:2nd Sunday of May
+SUMMARY:Flag Day
+DESCRIPTION:June 14
DTSTAMP:20030701T000000Z
-UID:holiday0026@icaldates.com
+UID:holiday0015@icaldates.com
CATEGORIES:Holiday - US
-DTSTART;VALUE=DATE:17530513
-RRULE:FREQ=MONTHLY;BYMONTH=5;BYDAY=2SU
+DTSTART;VALUE=DATE:17530614
+RRULE:FREQ=YEARLY
END:VEVENT
BEGIN:VEVENT
@@ -167,16 +175,6 @@ RRULE:FREQ=MONTHLY;BYMONTH=6;BYDAY=3SU
END:VEVENT
BEGIN:VEVENT
-SUMMARY:Flag Day
-DESCRIPTION:June 14
-DTSTAMP:20030701T000000Z
-UID:holiday0015@icaldates.com
-CATEGORIES:Holiday - US
-DTSTART;VALUE=DATE:17530614
-RRULE:FREQ=YEARLY
-END:VEVENT
-
-BEGIN:VEVENT
SUMMARY:Independence Day
DESCRIPTION:July 4
DTSTAMP:20030701T000000Z
diff --git a/day.php b/day.php
index 0e109d4..7ed31ea 100644
--- a/day.php
+++ b/day.php
@@ -1,20 +1,21 @@
<?php
+$current_view = 'day';
+if (!defined('BASE')) define('BASE', './');
+require_once(BASE.'functions/init.inc.php');
+header("Content-Type: text/html; charset=$phpiCal_config->charset");
if (isset($_GET['jumpto_day'])) {
$jumpto_day_time = strtotime($_GET['jumpto_day']);
if ($jumpto_day_time == -1) {
- $getdate = date('Ymd', time() + $second_offset);
+ $getdate = date('Ymd', time() + $phpiCal_config->second_offset);
} else {
$getdate = date('Ymd', $jumpto_day_time);
}
}
-$current_view = 'day';
-if (!defined('BASE')) define('BASE', './');
require_once(BASE.'functions/ical_parser.php');
require_once(BASE.'functions/list_functions.php');
require_once(BASE.'functions/template.php');
-header("Content-Type: text/html; charset=$charset");
-if ($minical_view == 'current') $minical_view = 'day';
+if ($phpiCal_config->minical_view == 'current') $minical_view = 'day';
$weekstart = 1;
$unix_time = strtotime($getdate);
@@ -24,7 +25,7 @@ $prev_day = date('Ymd', strtotime("-1 day", $unix_time));
$display_date = localizeDate($dateFormat_day, $unix_time);
$sidebar_date = localizeDate($dateFormat_week_list, $unix_time);
-$start_week_time = strtotime(dateOfWeek($getdate, $week_start_day));
+$start_week_time = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day));
// select for calendars
diff --git a/functions/date_functions.php b/functions/date_functions.php
index 568a767..3ba1b94 100644
--- a/functions/date_functions.php
+++ b/functions/date_functions.php
@@ -94,6 +94,11 @@ function yearCompare($now, $then) {
return $diff_years;
}
+function noneCompare($now, $then) {
+ return 0;
+}
+
+
// localizeDate() - similar to strftime but uses our preset arrays of localized
// months and week days and only supports %A, %a, %B, %b, %e, and %Y
// more can be added as needed but trying to keep it small while we can
diff --git a/functions/ical_parser.php b/functions/ical_parser.php
index ed80006..e6d5b22 100644
--- a/functions/ical_parser.php
+++ b/functions/ical_parser.php
@@ -9,7 +9,7 @@ include_once(BASE.'functions/parse/recur_functions.php');
// reading the file if it's allowed
$parse_file = true;
-if ($save_parsed_cals == 'yes') {
+if ($phpiCal_config->save_parsed_cals == 'yes') {
if (sizeof ($cal_filelist) > 1) {
$parsedcal = $tmp_dir.'/parsedcal-'.urlencode($cpath.'::'.$cal_filename).'-'.$this_year;
if (file_exists($parsedcal)) {
@@ -127,275 +127,298 @@ foreach ($cal_filelist as $cal_key=>$filename) {
}
$line = trim($line);
- switch ($line) {
- case 'BEGIN:VEVENT':
- // each of these vars were being set to an empty string
- unset (
- $start_time, $end_time, $start_date, $end_date, $summary,
- $allday_start, $allday_end, $start, $end, $the_duration,
- $beginning, $rrule_array, $start_of_vevent, $description, $url,
- $valarm_description, $start_unixtime, $end_unixtime, $display_end_tmp, $end_time_tmp1,
- $recurrence_id, $uid, $class, $location, $rrule, $abs_until, $until_check,
- $until, $bymonth, $byday, $bymonthday, $byweek, $byweekno,
- $byminute, $byhour, $bysecond, $byyearday, $bysetpos, $wkst,
- $interval, $number
- );
+ switch ($line) {
+ case 'BEGIN:VEVENT':
+ // each of these vars were being set to an empty string
+ unset (
+ $start_time, $end_time, $start_date, $end_date,
+ $allday_start, $allday_end, $start, $end, $the_duration,
+ $beginning, $start_of_vevent, $url,
+ $valarm_description, $start_unixtime, $end_unixtime, $display_end_tmp, $end_time_tmp1,
+ $recurrence_id, $uid, $rrule, $abs_until, $until_check,
+ $until, $byweek, $byweekno,
+ $byminute, $byhour, $bysecond
+ );
+
+ $interval = 1;
+ $summary = '';
+ $description = '';
+ $status = '';
+ $class = '';
+ $location = '';
+ $url = '';
+ $type = '';
+ $wkst = 'SU';
- $except_dates = array();
- $except_times = array();
- $byday = array();
- $bymonth = array();
- $bymonthday = array();
- $bysetpos = array();
- $first_duration = TRUE;
- $count = 1000000;
- $valarm_set = FALSE;
- $attendee = array();
- $organizer = array();
-
- break;
-
- case 'END:VEVENT':
- include BASE."functions/parse/end_vevent.php";
- break;
- case 'END:VTODO':
- if ((!$vtodo_priority) && ($status == 'COMPLETED')) {
- $vtodo_sort = 11;
- } elseif (!$vtodo_priority) {
- $vtodo_sort = 10;
- } else {
- $vtodo_sort = $vtodo_priority;
- }
+ $except_dates = array();
+ $except_times = array();
+ $rrule_array = array();
+ $byday = array();
+ $bymonth = array();
+ $bymonthday = array();
+ $byyearday = array();
+ $bysetpos = array();
+ $first_duration = TRUE;
+ $count = 1000000;
+ $valarm_set = FALSE;
+ $attendee = array();
+ $organizer = array();
+
+ break;
- // CLASS support
- if (isset($class)) {
- if ($class == 'PRIVATE') {
- $summary = '**PRIVATE**';
- $description = '**PRIVATE**';
- } elseif ($class == 'CONFIDENTIAL') {
- $summary = '**CONFIDENTIAL**';
- $description = '**CONFIDENTIAL**';
+ case 'END:VEVENT':
+ include BASE."functions/parse/end_vevent.php";
+ break;
+ case 'END:VTODO':
+ if ((!$vtodo_priority) && ($status == 'COMPLETED')) {
+ $vtodo_sort = 11;
+ } elseif (!$vtodo_priority) {
+ $vtodo_sort = 10;
+ } else {
+ $vtodo_sort = $vtodo_priority;
}
- }
-
- $master_array['-2']["$vtodo_sort"]["$uid"] = array ('start_date' => $start_date, 'start_time' => $start_time, 'vtodo_text' => $summary, 'due_date'=> $due_date, 'due_time'=> $due_time, 'completed_date' => $completed_date, 'completed_time' => $completed_time, 'priority' => $vtodo_priority, 'status' => $status, 'class' => $class, 'categories' => $vtodo_categories, 'description' => $description, 'calname' => $actual_calname);
- unset ($start_date, $start_time, $due_date, $due_time, $completed_date, $completed_time, $vtodo_priority, $status, $class, $vtodo_categories, $summary, $description);
- $vtodo_set = FALSE;
-
- break;
-
- case 'BEGIN:VTODO':
- $vtodo_set = TRUE;
- break;
- case 'BEGIN:VALARM':
- $valarm_set = TRUE;
- break;
- case 'END:VALARM':
- $valarm_set = FALSE;
- break;
-
- default:
-
- unset ($field, $data, $prop_pos, $property);
- if (ereg ("([^:]+):(.*)", $line, $line)){
- $field = $line[1];
- $data = $line[2];
-
- $property = $field;
- $prop_pos = strpos($property,';');
- if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
- $property = strtoupper($property);
-
- switch ($property) {
- // Start VTODO Parsing
- //
- case 'DUE':
- $datetime = extractDateTime($data, $property, $field);
- $due_date = $datetime[1];
- $due_time = $datetime[2];
- break;
-
- case 'COMPLETED':
- $datetime = extractDateTime($data, $property, $field);
- $completed_date = $datetime[1];
- $completed_time = $datetime[2];
- break;
-
- case 'PRIORITY':
- $vtodo_priority = "$data";
- break;
-
- case 'STATUS':
- $status = "$data";
- break;
-
- case 'CLASS':
- $class = "$data";
- break;
-
- case 'CATEGORIES':
- $vtodo_categories = "$data";
- break;
- //
- // End VTODO Parsing
-
- case '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':
- $datetime = extractDateTime($data, $property, $field);
- $end_unixtime = $datetime[0];
- $end_date = $datetime[1];
- $end_time = $datetime[2];
- $allday_end = $datetime[3];
- break;
+ // CLASS support
+ if (isset($class)) {
+ if ($class == 'PRIVATE') {
+ $summary = '**PRIVATE**';
+ $description = '**PRIVATE**';
+ } elseif ($class == 'CONFIDENTIAL') {
+ $summary = '**CONFIDENTIAL**';
+ $description = '**CONFIDENTIAL**';
+ }
+ }
+
+ $master_array['-2']["$vtodo_sort"]["$uid"] = array (
+ 'start_date' => $start_date,
+ 'start_time' => $start_time,
+ 'vtodo_text' => $summary,
+ 'due_date'=> $due_date,
+ 'due_time'=> $due_time,
+ 'completed_date' => $completed_date,
+ 'completed_time' => $completed_time,
+ 'priority' => $vtodo_priority,
+ 'status' => $status,
+ 'class' => $class,
+ 'categories' => $vtodo_categories,
+ 'description' => $description,
+ 'calname' => $actual_calname);
+ unset ($start_date, $start_time, $due_date, $due_time, $completed_date, $completed_time, $vtodo_priority, $status, $class, $vtodo_categories, $summary, $description);
+ $vtodo_set = FALSE;
+ break;
+
+ case 'BEGIN:VTODO':
+ $vtodo_set = TRUE;
+ break;
+ case 'BEGIN:VALARM':
+ $valarm_set = TRUE;
+ break;
+ case 'END:VALARM':
+ $valarm_set = FALSE;
+ break;
+
+ default:
+
+ unset ($field, $data, $prop_pos, $property);
+ if (ereg ("([^:]+):(.*)", $line, $line)){
+ $field = $line[1];
+ $data = $line[2];
+
+ $property = $field;
+ $prop_pos = strpos($property,';');
+ if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
+ $property = strtoupper($property);
+
+ switch ($property) {
- case 'EXDATE':
- $data = split(",", $data);
- foreach ($data as $exdata) {
- $exdata = str_replace('T', '', $exdata);
- $exdata = str_replace('Z', '', $exdata);
- preg_match ('/([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];
- // Added for Evolution, since they dont think they need to tell me which time to exclude.
- if (($regs[4] == '') && ($start_time != '')) {
- $except_times[] = $start_time;
+ // Start VTODO Parsing
+ //
+ case 'DUE':
+ $datetime = extractDateTime($data, $property, $field);
+ $due_date = $datetime[1];
+ $due_time = $datetime[2];
+ break;
+
+ case 'COMPLETED':
+ $datetime = extractDateTime($data, $property, $field);
+ $completed_date = $datetime[1];
+ $completed_time = $datetime[2];
+ break;
+
+ case 'PRIORITY':
+ $vtodo_priority = "$data";
+ break;
+
+ case 'STATUS':
+ $status = "$data";
+ break;
+
+ case 'CLASS':
+ $class = "$data";
+ break;
+
+ case 'CATEGORIES':
+ $vtodo_categories = "$data";
+ break;
+ //
+ // End VTODO Parsing
+
+ case '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':
+ $datetime = extractDateTime($data, $property, $field);
+ $end_unixtime = $datetime[0];
+ $end_date = $datetime[1];
+ $end_time = $datetime[2];
+ $allday_end = $datetime[3];
+ break;
+
+ case 'EXDATE':
+ $data = split(",", $data);
+ foreach ($data as $exdata) {
+ $exdata = str_replace('T', '', $exdata);
+ $exdata = str_replace('Z', '', $exdata);
+ preg_match ('/([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];
+ // Added for Evolution, since they dont think they need to tell me which time to exclude.
+ if (($regs[4] == '') && ($start_time != '')) {
+ $except_times[] = $start_time;
+ } else {
+ $except_times[] = $regs[4] . $regs[5];
+ }
+ }
+ break;
+
+ case 'SUMMARY':
+ $data = str_replace("\\n", "<br />", $data);
+ $data = str_replace("\\t", "&nbsp;", $data);
+ $data = str_replace("\\r", "<br />", $data);
+ $data = str_replace('$', '&#36;', $data);
+ $data = stripslashes($data);
+ $data = htmlentities(urlencode($data));
+ if ($valarm_set == FALSE) {
+ $summary = $data;
} else {
- $except_times[] = $regs[4] . $regs[5];
+ $valarm_summary = $data;
}
- }
- break;
-
- case 'SUMMARY':
- $data = str_replace("\\n", "<br />", $data);
- $data = str_replace("\\t", "&nbsp;", $data);
- $data = str_replace("\\r", "<br />", $data);
- $data = str_replace('$', '&#36;', $data);
- $data = stripslashes($data);
- $data = htmlentities(urlencode($data));
- if ($valarm_set == FALSE) {
- $summary = $data;
- } else {
- $valarm_summary = $data;
- }
- break;
-
- case 'DESCRIPTION':
- $data = str_replace("\\n", "<br />", $data);
- $data = str_replace("\\t", "&nbsp;", $data);
- $data = str_replace("\\r", "<br />", $data);
- $data = str_replace('$', '&#36;', $data);
- $data = stripslashes($data);
- $data = htmlentities(urlencode($data));
- if ($valarm_set == FALSE) {
- $description = $data;
- } else {
- $valarm_description = $data;
- }
- break;
-
- case 'RECURRENCE-ID':
- $parts = explode(';', $field);
- foreach($parts as $part) {
- $eachval = split('=',$part);
- if ($eachval[0] == 'RECURRENCE-ID') {
- // do nothing
- } elseif ($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];
+ break;
+
+ case 'DESCRIPTION':
+ $data = str_replace("\\n", "<br />", $data);
+ $data = str_replace("\\t", "&nbsp;", $data);
+ $data = str_replace("\\r", "<br />", $data);
+ $data = str_replace('$', '&#36;', $data);
+ $data = stripslashes($data);
+ $data = htmlentities(urlencode($data));
+ if ($valarm_set == FALSE) {
+ $description = $data;
} else {
- $recurrence_id[] = $eachval[1];
+ $valarm_description = $data;
}
- }
- unset($parts, $part, $eachval);
-
- $data = str_replace('T', '', $data);
- $data = str_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]);
-
- if (isset($recurrence_id['tzid'])) {
- $offset_tmp = chooseOffset($recur_unixtime, $recurrence_id['tzid']);
- } elseif (isset($calendar_tz)) {
- $offset_tmp = chooseOffset($recur_unixtime, $tz_array[$calendar_tz]);
- } else {
- $offset_tmp = $chooseOffset($recur_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);
- $recurrence_d = date('Ymd', $recur_unixtime);
- $recurrence_t = date('Hi', $recur_unixtime);
- unset($server_offset_tmp);
- break;
-
- case 'UID':
- $uid = $data;
- break;
- case 'X-WR-CALNAME':
- $actual_calname = $data;
- $master_array['calendar_name'] = $actual_calname;
- $cal_displaynames[$cal_key] = $actual_calname; #correct the default calname based on filename
- 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])?([0-9]{1,2}[D])?([T]{0,1})?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?', $data, $duration);
- $weeks = str_replace('W', '', $duration[1]);
- $days = str_replace('D', '', $duration[2]);
- $hours = str_replace('H', '', $duration[4]);
- $minutes = str_replace('M', '', $duration[5]);
- $seconds = str_replace('S', '', $duration[6]);
- $the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds);
- $first_duration = FALSE;
- }
- break;
- case 'RRULE':
- $data = str_replace ('RRULE:', '', $data);
- $rrule = split (';', $data);
- foreach ($rrule as $recur) {
- ereg ('(.*)=(.*)', $recur, $regs);
- $rrule_array[$regs[1]] = $regs[2];
- }
- break;
- case 'ATTENDEE':
- $field = str_replace("ATTENDEE;CN=", "", $field);
- $data = str_replace ("mailto:", "", $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' => stripslashes($field), 'email' => stripslashes($data));
- break;
- case 'LOCATION':
- $data = str_replace("\\n", "<br />", $data);
- $data = str_replace("\\t", "&nbsp;", $data);
- $data = str_replace("\\r", "<br />", $data);
- $data = stripslashes($data);
- $location = $data;
- break;
- case 'URL':
- $url = $data;
- break;
+ break;
+
+ case 'RECURRENCE-ID':
+ $parts = explode(';', $field);
+ foreach($parts as $part) {
+ $eachval = split('=',$part);
+ if ($eachval[0] == 'RECURRENCE-ID') {
+ // do nothing
+ } elseif ($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 = str_replace('T', '', $data);
+ $data = str_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]);
+
+ if (isset($recurrence_id['tzid'])) {
+ $offset_tmp = chooseOffset($recur_unixtime, $recurrence_id['tzid']);
+ } elseif (isset($calendar_tz)) {
+ $offset_tmp = chooseOffset($recur_unixtime, $tz_array[$calendar_tz]);
+ } else {
+ $offset_tmp = $chooseOffset($recur_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);
+ $recurrence_d = date('Ymd', $recur_unixtime);
+ $recurrence_t = date('Hi', $recur_unixtime);
+ unset($server_offset_tmp);
+ break;
+
+ case 'UID':
+ $uid = $data;
+ break;
+ case 'X-WR-CALNAME':
+ $actual_calname = $data;
+ $master_array['calendar_name'] = $actual_calname;
+ $cal_displaynames[$cal_key] = $actual_calname; #correct the default calname based on filename
+ 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])?([0-9]{1,2}[D])?([T]{0,1})?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?', $data, $duration);
+ $weeks = str_replace('W', '', $duration[1]);
+ $days = str_replace('D', '', $duration[2]);
+ $hours = str_replace('H', '', $duration[4]);
+ $minutes = str_replace('M', '', $duration[5]);
+ $seconds = str_replace('S', '', $duration[6]);
+ $the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds);
+ $first_duration = FALSE;
+ }
+ break;
+ case 'RRULE':
+ $data = str_replace ('RRULE:', '', $data);
+ $rrule = split (';', $data);
+ foreach ($rrule as $recur) {
+ ereg ('(.*)=(.*)', $recur, $regs);
+ $rrule_array[$regs[1]] = $regs[2];
+ }
+ break;
+ case 'ATTENDEE':
+ $field = str_replace("ATTENDEE;CN=", "", $field);
+ $data = str_replace ("mailto:", "", $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' => stripslashes($field), 'email' => stripslashes($data));
+ break;
+ case 'LOCATION':
+ $data = str_replace("\\n", "<br />", $data);
+ $data = str_replace("\\t", "&nbsp;", $data);
+ $data = str_replace("\\r", "<br />", $data);
+ $data = stripslashes($data);
+ $location = $data;
+ break;
+ case 'URL':
+ $url = $data;
+ break;
+ }
}
}
- }
}
}
if (!isset($master_array['-3'][$calnumber])) $master_array['-3'][$calnumber] = $actual_calname;
@@ -421,7 +444,7 @@ if ($parse_file) {
}
// write the new master array to the file
- if (isset($master_array) && is_array($master_array) && $save_parsed_cals == 'yes') {
+ if (isset($master_array) && is_array($master_array) && $phpiCal_config->save_parsed_cals == 'yes') {
$write_me = serialize($master_array);
$fd = @fopen($parsedcal, 'w');
if ($fd == FALSE) exit(error($lang['l_error_cache'], $filename));
@@ -433,14 +456,13 @@ if ($parse_file) {
// Set a calender name for all calenders combined
-if ($cal == $ALL_CALENDARS_COMBINED) {
+if ($cal == $phpiCal_config->ALL_CALENDARS_COMBINED) {
$calendar_name = $all_cal_comb_lang;
}
$cal_displayname = urldecode(implode(', ', $cal_displaynames)); #reset this with the correct names
$template_started = getmicrotime();
//If you want to see the values in the arrays, uncomment below.
-
//print '<pre>';
//print_r($master_array);
//print_r($overlap_array);
@@ -452,4 +474,4 @@ $template_started = getmicrotime();
//print_r($cal_filelist);
//print_r($tz_array);
//print '</pre>';
-?>
+?> \ No newline at end of file
diff --git a/functions/init/set_error_reporting.php b/functions/init/set_error_reporting.php
index 91e491d..b57040e 100644
--- a/functions/init/set_error_reporting.php
+++ b/functions/init/set_error_reporting.php
@@ -4,6 +4,7 @@ config boolean $verbose_errors = false by default
*/
// uncomment when developing, comment for shipping version
-error_reporting (E_ERROR | E_WARNING | E_PARSE);
+error_reporting (E_ALL);
+#error_reporting (E_ERROR | E_WARNING | E_PARSE);
#error_reporting(0);
// Older versions of PHP do not define $_SERVER. Define it here instead.
diff --git a/functions/parse/end_vevent.php b/functions/parse/end_vevent.php
index 33175cf..5cf2c35 100644
--- a/functions/parse/end_vevent.php
+++ b/functions/parse/end_vevent.php
@@ -3,12 +3,14 @@
What happens in this file:
1. Initialization: add information not present by default
-2.
+ a. duration
+ b. class
+ c. uid
+ d. adjust start_time and end_time
+2. Build recur_data array
+3. Add occurrences to master_array
*/
-if (!isset($url)) $url = '';
-if (!isset($type)) $type = '';
-
// Handle DURATION
if (!isset($end_unixtime)) {
if(!isset($the_duration)) $the_duration = 0;
@@ -36,13 +38,6 @@ if (!isset($uid)) {
$uid_valid = true;
}
-if (!isset($summary)) $summary = '';
-if (!isset($description)) $description = '';
-if (!isset($status)) $status = '';
-if (!isset($class)) $class = '';
-if (!isset($location)) $location = '';
-
-
# adjust event start and end times
if (isset($start_time) && isset($end_time)) {
// Mozilla style all-day events or just really long events
@@ -112,26 +107,8 @@ if (isset($allday_start) && $allday_start != '') {
$rrule_array['END_TIME'] = $end_time;
# $rrule_array['END'] = 'end';
}
-
-$start_date_time = strtotime($start_date);
-if (!isset($fromdate)){
- #this should happen if not in one of the rss views
- $this_month_start_time = strtotime($this_year.$this_month.'01');
- if ($current_view == 'year' || ($save_parsed_cals == 'yes' && !$is_webcal)|| $current_view == 'print' && $printview == 'year') {
- $start_range_time = strtotime($this_year.'-01-01 -2 weeks');
- $end_range_time = strtotime($this_year.'-12-31 +2 weeks');
- } else {
- $start_range_time = strtotime('-1 month -2 day', $this_month_start_time);
- $end_range_time = strtotime('+2 month +2 day', $this_month_start_time);
- }
-}else{
- $start_range_time = strtotime($fromdate);
- $end_range_time = strtotime($todate)+60*60*24;
-}
-
-$freq_type = 'year';
-$interval = 1;
+$freq_type = 'none';
# Load $rrule_array
foreach ($rrule_array as $key => $val) {
switch($key) {
@@ -157,7 +134,7 @@ foreach ($rrule_array as $key => $val) {
if (strlen($until) == 8) $until = $until.'235959';
$abs_until = $until;
ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})', $until, $regs);
- $until = mktime($regs[4],$regs[5],$regs[6],$regs[2],$regs[3],$regs[1]);
+ $until_unixtime = mktime($regs[4],$regs[5],@$regs[6],$regs[2],$regs[3],$regs[1]);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = localizeDate($dateFormat_week,$until);
break;
case 'INTERVAL':
@@ -167,47 +144,39 @@ foreach ($rrule_array as $key => $val) {
}
break;
case 'BYSECOND':
- $bysecond = $val;
- $bysecond = split (',', $bysecond);
+ $bysecond = split (',', $val);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysecond;
break;
case 'BYMINUTE':
- $byminute = $val;
- $byminute = split (',', $byminute);
+ $byminute = split (',', $val);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byminute;
break;
case 'BYHOUR':
- $byhour = $val;
- $byhour = split (',', $byhour);
+ $byhour = split (',', $val);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byhour;
break;
case 'BYDAY':
- $byday = $val;
- $byday = split (',', $byday);
+ $byday = split (',', $val);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byday;
break;
case 'BYMONTHDAY':
- $bymonthday = $val;
- $bymonthday = split (',', $bymonthday);
+ $bymonthday = split (',', $val);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonthday;
break;
case 'BYYEARDAY':
- $byyearday = $val;
- $byyearday = split (',', $byyearday);
+ $byyearday = split (',', $val);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byyearday;
break;
case 'BYWEEKNO':
- $byweekno = $val;
- $byweekno = split (',', $byweekno);
+ $byweekno = split (',', $val);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byweekno;
break;
case 'BYMONTH':
- $bymonth = $val;
- $bymonth = split (',', $bymonth);
+ $bymonth = split (',', $val);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonth;
break;
case 'BYSETPOS':
- $bysetpos = $val;
+ $bysetpos = split (',', $val);
$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysetpos;
break;
case 'WKST':
@@ -216,243 +185,98 @@ foreach ($rrule_array as $key => $val) {
break;
}
}
-/*
-Load $recur_array
-$recur_array is an array of unix times for instances of an event. This code handles repeats.
-Note that dates with exceptions are counted as instances.
-RDATE is currently not supported
-*/
# $recur is the recurrence info that goes into the master array for this VEVENT
-$recur = $recur_array[($start_date)][($hour.$minute)][$uid]['recur'];
-
-// if $until isn't set yet, we set it to the end of our range we're looking at
-if (!isset($until)) $until = $end_range_time;
-if (!isset($abs_until)) $abs_until = date('YmdHis', $end_range_time);
-$end_date_time = $until;
-
-// If the $end_range_time is less than the $start_date_time, or $start_range_time is greater
-// than $end_date_time, we may as well forget the whole thing
-// It doesn't do us any good to spend time adding data we aren't even looking at
-// this will prevent the year view from taking way longer than it needs to
-if ($end_range_time >= $start_date_time && $start_range_time_tmp <= $end_date_time) {
-
- // if the beginning of our range is less than the start of the item, we may as well set it equal to it
- if ($start_range_time < $start_date_time){
- $start_range_time = $start_date_time;
- }
- if ($end_range_time > $end_date_time) $end_range_time = $end_date_time;
-
- // initialize the time we will increment
- $next_range_time = $start_range_time;
-
- // start at the $start_range and go until we hit the end of our range.
- if(!isset($wkst)) $wkst='SU';
- $wkst3char = two2threeCharDays($wkst);
+$recur = @$recur_array[($start_date)][($hour.$minute)][$uid]['recur'];
- # set first instance if it's in range
- $recur_data = array();
- if ($start_unixtime < $mArray_end && $end_unixtime > $mArray_begin){
- $recur_data[] = $start_unixtime;
- }
- /*
- The while loop below increments $next_range_time by $freq type. For the larger freq types, there is only
- one $next_range_time per repeat, but the BYXXX rules may write more than one event in that repeat cycle
- $next_date_time handles those instances within a $freq_type
- */
- #echo "<br><br>$summary<br>next range time:".date("Ymd his",$next_range_time)." <br>start range time ".date("Ymd his",$start_range_time)." <br>end range time ".date("Ymd his",$end_range_time);
- while (($next_range_time >= $start_range_time) && ($next_range_time <= $end_range_time)) {
- # pick the right compare function from date_functions.php
- # $diff is the number of occurrences between start_date and next_range_time
- $func = $freq_type.'Compare';
- $diff = $func(date('Ymd',$next_range_time), $start_date);
- $rcount = $diff;
- if(count($byday) > 1) $rcount = $diff * count($byday);
- if ($rcount < $count && $diff % $interval == 0) {
- $year = date('Y', $next_range_time);
- $month = date('m', $next_range_time);
- switch ($rrule_array['FREQ']) {
- case 'DAILY':
- $recur_data[] = $next_range_time;
- break;
- case 'WEEKLY':
- // Populate $byday with the default day if it's not set.
- if (!isset($byday)) $byday[] = strtoupper(substr(date('D', $start_date_time), 0, 2));
- $the_sunday = dateOfWeek(date("Ymd",$next_range_time), $wkst3char);
- foreach($byday as $key=>$day) {
- $day = two2threeCharDays($day);
- #need to find the first day of the appropriate week.
- if ($key == 0){
- $next_date_time = strtotime("next $day",strtotime($the_sunday)) + (12 * 60 * 60);
- }else{
- $next_date_time = strtotime("next $day",$next_date_time) + (12 * 60 * 60);
- }
- $recur_data[] = $next_date_time; #echo "<br>$key $day ".strtotime("Ymd his", $next_date_time);
- }
- break;
- case 'MONTHLY':
- if (empty($bymonth)) $bymonth = array(1,2,3,4,5,6,7,8,9,10,11,12);
- if (!empty($bysetpos)){
- /* bysetpos code from dustinbutler
- start on day 1 or last day.
- if day matches any BYDAY the count is incremented.
- SETPOS = 4, need 4th match
- SETPOS = -1, need 1st match
- */
- if ($bysetpos > 0) {
- $next_day = '+1 day';
- $day = 1;
- } else {
- $next_day = '-1 day';
- $day = $totalDays[$month];
- }
- $day = mktime(0, 0, 0, $month, $day, $year);
- $countMatch = 0;
- while ($countMatch != abs($bysetpos)) {
- /* Does this day match a BYDAY value? */
- $thisDay = $day;
- $textDay = strtoupper(substr(date('D', $thisDay), 0, 2));
- if (in_array($textDay, $byday)) {
- $countMatch++;
- }
- $day = strtotime($next_day, $thisDay);
- }
- if(in_array(date("m", $next_date_time), $bymonth)) $recur_data[] = $next_date_time;
- }elseif (count($bymonthday) > 0 && empty($byday)) {
- foreach($bymonthday as $day) {
- if ($day < 0) $day = ((date('t', $next_range_time)) + ($day)) + 1;
- if (checkdate($month,$day,$year)) {
- $next_date_time = mktime(0,0,0,$month,$day,$year);
- if(in_array(date("m", $next_date_time), $bymonth)) $recur_data[] = $next_date_time;
- }
- }
- } else {
- foreach($byday as $day) {
- /* set $byday_arr
- [0] => byday string, e.g. 4TH
- [1] => sign/modifier
- [2] => 4 number
- [3] => TH day abbr
- */
- ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr);
- $on_day = two2threeCharDays($byday_arr[3]);
- $next_date_time = strtotime($byday_arr[1].$byday_arr[2].$on_day, $next_range_time);
- if(empty($bymonthday) && in_array(date("m", $next_date_time), $bymonth)) $recur_data[] = $next_date_time;
-
- if (isset($bymonthday) && (!empty($bymonthday))) {
- // This supports MONTHLY where BYDAY and BYMONTH are both set
- foreach($bymonthday as $day) {
- if (checkdate($month,$day,$year)) {
- $next_date_time = mktime(0,0,0,$month,$day,$year);
- $daday = strtolower(strftime("%a", $next_date_time));
- if ($daday == $on_day && in_array($month, $bymonth)) {
- if(in_array(date("m", $next_date_time), $bymonth)) $recur_data[] = $next_date_time;
- }
- }
- }
- }
- } # end foreach $byday
- }
- break;
- case 'YEARLY':
- if ((!isset($bymonth)) || (sizeof($bymonth) == 0)) $bymonth = array(date('m', $start_date_time));
- foreach($bymonth as $month) {
- if (isset($bysetpos)){
- /* bysetpos code from dustinbutler
- start on day 1 or last day.
- if day matches any BYDAY the count is incremented.
- SETPOS = 4, need 4th match
- SETPOS = -1, need 1st match
- */
- if ($bysetpos > 0) {
- $next_day = '+1 day';
- $day = 1;
- } else {
- $next_day = '-1 day';
- $day = date("t",$month);
- }
- $day = mktime(12, 0, 0, $month, $day, $year);
- $countMatch = 0;
- while ($countMatch != abs($bysetpos)) {
- /* Does this day match a BYDAY value? */
- $thisDay = $day;
- $textDay = strtoupper(substr(date('D', $thisDay), 0, 2));
- if (in_array($textDay, $byday)) {
- $countMatch++;
- }
- $day = strtotime($next_day, $thisDay);
- }
- $recur_data[] = $thisDay;
- }
- if ((isset($byday)) && (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);
- if ($byday_arr[2] != '') {
- $nth = $byday_arr[2]-1;
- } else {
- $nth = 0;
- }
- $on_day = two2threeCharDays($byday_arr[3]);
- $on_day_num = two2threeCharDays($byday_arr[3],false);
- 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);
- $next_date_time = mktime(0,0,0,$month,$day,$year+1);
- //echo date('Ymd',$next_date_time).$summary.'<br>';
- }
- if (isset($next_date_time) && $next_date_time != '') $recur_data[] = $next_date_time;
- }
- if (isset($byyearday)) {
- foreach ($byyearday as $yearday) {
- ereg ('([-\+]{0,1})?([0-9]{1,3})', $yearday, $byyearday_arr);
- if ($byyearday_arr[1] == '-') {
- $ydtime = mktime(0,0,0,12,31,$this_year);
- $yearnum = $byyearday_arr[2] - 1;
- $next_date_time = strtotime('-'.$yearnum.' days', $ydtime);
- } else {
- $ydtime = mktime(0,0,0,1,1,$this_year);
- $yearnum = $byyearday_arr[2] - 1;
- $next_date_time = strtotime('+'.$yearnum.' days', $ydtime);
- }
- if (isset($next_date_time) && $next_date_time != '') $recur_data[] = $next_date_time;
- }
- }
- break;
- default:
- // anything else we need to end the loop
- $next_range_time = $end_range_time + 100;
- } # end switch
- }
- $next_range_time = strtotime('+'.$interval.' '.$freq_type, $next_range_time);
- } #end while loop
-} # end if time compare
+/* ============================ Load $recur_data ============================
+$recur_data is an array of unix times for instances of an event. This code handles repeats.
+Note that dates with exceptions are counted as instances.
+RDATE is currently not supported
+A. Set up the time range to scan for events.
+If COUNT is not set (default is 1,000,000) then we don't have to start at start_date; we can start at the minimum interval for the view.
+variables ending in date are in phpical date format: YYYYMMDD
+variables ending with time are in phpical time format: HHMM
+variables ending in unixtime are in unixtime
-#foreach($recur_data as $time) echo "<br>".date("Ymd his",$time);
+mArray_begin and mArray_end are set in initialization by date_range.php and may be overwritten by rss_common.php. These should be the default for start_range and end_range unixtimes. Conditions where overwrite these:
+ COUNT < 1,000,000 - we have to count occurrences; reset next_range_unixtime starting value
+ $until_unixtime < $mArray_end - stop iterating early
+ !isset($rrule_array['FREQ']) - only iterate once, set the end_range_unixtime to the end_date_unixtime
+Note that start_range_unixtime and end_range_unixtime are not the same as start_date_unixtime and end_date_unixtime */
+$next_range_unixtime = $mArray_begin;
+$end_range_unixtime = $mArray_end+60*60*24;
+$start_date_unixtime = strtotime($start_date);
+if($count < 1000000) $next_range_unixtime = $start_date_unixtime;
+if(isset($until) && $end_range_unixtime > $until_unixtime) $end_range_unixtime = $until_unixtime;
+if(!isset($rrule_array['FREQ'])){
+ $end_range_unixtime = strtotime($end_date);
+ $count = 1;
+}
+// if the beginning of our range is less than the start of the item, we may as well set it equal to it
+if ($next_range_unixtime < $start_date_unixtime) $next_range_unixtime = $start_date_unixtime;
+
+// convert wkst to a 3 char day for strtotime to work
+$wkst3char = two2threeCharDays($wkst);
+/* The while loop below increments $next_range_time by $freq type. For the larger freq types, there is only
+one $next_range_time per repeat, but the BYXXX rules may write more than one event in that repeat cycle
+$next_date_time handles those instances within a $freq_type */
+#echo "<pre>$summary\n\tstart mArray time:".date("Ymd his",$mArray_begin)."\n\tstart range time:".date("Ymd his",$next_range_unixtime)."\n\tend range time ".date("Ymd his",$end_range_unixtime)."</pre>";
+$recur_data = array();
+while ($next_range_unixtime <= $end_range_unixtime) {
+ $year = date('Y', $next_range_unixtime);
+ $month = date('m', $next_range_unixtime);
+ # pick the right compare function from date_functions.php
+ # $diff is the number of occurrences between start_date and next_range_time
+ $func = $freq_type.'Compare';
+ $diff = $func(date('Ymd',$next_range_time), $start_date);
+ switch ($freq_type){
+ case 'day':
+ add_recur($next_range_unixtime);
+ break;
+ case 'week':
+ add_recur(expand_byday($next_range_unixtime));
+ break;
+ case 'month':
+ $next_date_unixtime = mktime(12,0,0,$month,date('d',$start_unixtime),$year); echo "month".date("Ymd his",$next_date_unixtime);
+ add_recur(($next_date_unixtime));
+ break;
+ case 'year':
+ $next_date_unixtime = mktime(12,0,0,date('m',$start_unixtime),date('d',$start_unixtime),$year); echo "year:$hour,$min,0,".date('m',$start_unixtime).",".date('d',$start_unixtime).",$year".date("Ymd his",$next_date_unixtime);print_r($datetime);
+ add_recur(($next_date_unixtime));
+ break;
+ default:
+ add_recur($start_unixtime);
+ break 2;
+ }
+ $next_range_unixtime = strtotime('+'.$interval.' '.$freq_type, $next_range_unixtime);
+} #end while loop
+$recur_data = array_unique($recur_data);
+sort($recur_data);
+echo "<pre>$summary recur_data:";
+#var_dump($recur_data);
+foreach($recur_data as $time) echo "\n".date("Ymd his",$time);
+echo "</pre>";
+if ($count < count($recur_data)){
+ $arr = array_slice($recur_data,0,$count);
+ $recur_data =$arr;
+}
# use recur_data array to write the master array
// use the same code to write the data instead of always changing it 5 times
-$recur_data_hour = @substr($start_time,0,2);
-$recur_data_minute = @substr($start_time,2,2);
-foreach($recur_data as $recur_data_time) {
- $recur_data_year = date('Y', $recur_data_time);
- $recur_data_month = date('m', $recur_data_time);
- $recur_data_day = date('d', $recur_data_time);
+$recur_data_hour = @substr($start_unixtime,0,2);
+$recur_data_minute = @substr($start_unixtime,2,2);
+foreach($recur_data as $recur_data_unixtime) {
+ $recur_data_year = date('Y', $recur_data_unixtime);
+ $recur_data_month = date('m', $recur_data_unixtime);
+ $recur_data_day = date('d', $recur_data_unixtime);
$recur_data_date = $recur_data_year.$recur_data_month.$recur_data_day;
- if (($recur_data_time >= $start_date_time) && ($recur_data_time <= $end_date_time) && ($count_to != $count) && !in_array($recur_data_date, $except_dates)) {
+ if ( !in_array($recur_data_date, $except_dates) ) {
if (isset($allday_start) && $allday_start != '') {
- $start_time2 = $recur_data_time;
- $end_time2 = strtotime('+'.$diff_allday_days.' days', $recur_data_time);
+ $start_time2 = $recur_data_unixtime;
+ $end_time2 = strtotime('+'.$diff_allday_days.' days', $recur_data_unixtime);
while ($start_time2 < $end_time2) {
$start_date2 = date('Ymd', $start_time2);
$master_array[($start_date2)][('-1')][$uid] = array (
@@ -473,7 +297,7 @@ foreach($recur_data as $recur_data_time) {
$start_unixtime_tmp = mktime($recur_data_hour,$recur_data_minute,0,$recur_data_month,$recur_data_day,$recur_data_year);
$end_unixtime_tmp = $start_unixtime_tmp + $length;
- if (($end_time >= $bleed_time) && ($bleed_check == '-1')) {
+ if (($end_time >= $phpiCal_config->bleed_time) && ($bleed_check == '-1')) {
$start_tmp = strtotime(date('Ymd',$start_unixtime_tmp));
$end_date_tmp = date('Ymd',$end_unixtime_tmp);
while ($start_tmp < $end_unixtime_tmp) {
@@ -530,8 +354,6 @@ foreach($recur_data as $recur_data_time) {
if (!isset($end_time_tmp1)) $end_time_tmp1 = $end_time;
// Let's double check the until to not write past it
- $until_check = $recur_data_date.$hour.$minute.'00';
- if ($abs_until > $until_check) {
$master_array[($recur_data_date)][($hour.$minute)][$uid] = array (
'event_start' => $start_time,
'event_end' => $end_time_tmp1,
@@ -555,7 +377,7 @@ foreach($recur_data as $recur_data_time) {
$master_array[($recur_data_date)][($hour.$minute)][$uid]['display_end'] = $display_end_tmp;
}
checkOverlap($recur_data_date, ($hour.$minute), $uid);
- }
+
}
}
}
@@ -580,5 +402,16 @@ if (is_array($except_dates)) {
// Clear event data now that it's been saved.
unset($start_time, $start_time_tmp, $end_time, $end_time_tmp, $start_unixtime, $start_unixtime_tmp, $end_unixtime, $end_unixtime_tmp, $summary, $length, $description, $status, $class, $location, $organizer, $attendee);
-
+//If you want to see the values in the arrays, uncomment below.
+//print '<pre>';
+//print_r($master_array);
+//print_r($overlap_array);
+//print_r($day_array);
+//print_r($rrule_array);
+//print_r($byday_arr);
+//print_r($recurrence_delete);
+//print_r($cal_displaynames);
+//print_r($cal_filelist);
+//print_r($tz_array);
+//print '</pre>';
?> \ No newline at end of file
diff --git a/functions/parse/overlapping_events.php b/functions/parse/overlapping_events.php
index 9595c83..224f79b 100644
--- a/functions/parse/overlapping_events.php
+++ b/functions/parse/overlapping_events.php
@@ -114,7 +114,7 @@ function checkOverlap($event_date, $event_time, $uid) {
if (!isset($event_date)) return;
$event = $master_array[$event_date][$event_time][$uid];
// Copy out the array - we replace this at the end.
- $ol_day_array = $overlap_array[$event_date];
+ $ol_day_array = @$overlap_array[$event_date];
$drawTimes = drawEventTimes($event['event_start'], $event['event_end']);
// For a given date,
@@ -141,7 +141,7 @@ function checkOverlap($event_date, $event_time, $uid) {
// 'start' - start_time for the overlap block.
// 'end' - end_time for the overlap block.
- $ol_day_array = $overlap_array[$event_date];
+ $ol_day_array = @$overlap_array[$event_date];
// Track if $event has been merged in, so we don't re-add the details to 'event' or 'overlapRanges' multiple times.
$already_merged_once = false;
// First, check the existing overlap blocks, see if the event overlaps with any.
diff --git a/functions/parse/parse_tzs.php b/functions/parse/parse_tzs.php
index 93f24d5..daafe33 100644
--- a/functions/parse/parse_tzs.php
+++ b/functions/parse/parse_tzs.php
@@ -17,6 +17,8 @@ while (!feof($ifile)) {
$nextline = ereg_replace("[\r\n]", "", $nextline);
}
$line = trim($line);
+ $is_daylight = false;
+ $is_std = false;
switch ($line) {
case 'BEGIN:VTIMEZONE':
@@ -25,6 +27,7 @@ while (!feof($ifile)) {
case 'BEGIN:STANDARD':
unset ($offset_s);
$is_std = true;
+ $is_daylight = false;
break;
case 'END:STANDARD':
$offset_s = $offset_to;
@@ -33,6 +36,7 @@ while (!feof($ifile)) {
case 'BEGIN:DAYLIGHT':
unset ($offset_d);
$is_daylight = true;
+ $is_std = false;
break;
case 'END:DAYLIGHT':
$offset_d = $offset_to;
diff --git a/functions/parse/recur_functions.php b/functions/parse/recur_functions.php
new file mode 100644
index 0000000..5b845b3
--- /dev/null
+++ b/functions/parse/recur_functions.php
@@ -0,0 +1,111 @@
+<?php
+
+/* from the std
+
+BYxxx rule parts modify the recurrence in some manner. BYxxx rule
+ parts for a period of time which is the same or greater than the
+ frequency generally reduce or limit the number of occurrences of the
+ recurrence generated. For example, "FREQ=DAILY;BYMONTH=1" reduces the
+ number of recurrence instances from all days (if BYMONTH tag is not
+ present) to all days in January. BYxxx rule parts for a period of
+ time less than the frequency generally increase or expand the number
+ of occurrences of the recurrence. For example,
+ "FREQ=YEARLY;BYMONTH=1,2" increases the number of days within the
+ yearly recurrence set from 1 (if BYMONTH tag is not present) to 2.
+
+ If multiple BYxxx rule parts are specified, then after evaluating the
+ specified FREQ and INTERVAL rule parts, the BYxxx rule parts are
+ applied to the current set of evaluated occurrences in the following
+ order: BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR,
+ BYMINUTE, BYSECOND and BYSETPOS; then COUNT and UNTIL are evaluated.
+
+ We will use two kinds of functions - those that restrict the date to allowed values and those that expand allowed values
+
+*/
+
+function add_recur($times,$freq=''){
+ global $recur_data;
+ if (!is_array($times)) $times = array($times);
+ /*BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR,
+ BYMINUTE, BYSECOND and BYSETPOS*/
+ $times = restrict_bymonth($times,$freq);
+ $times = restrict_byweekno($times,$freq);
+ $times = restrict_byyearday($times,$freq);
+ $times = restrict_bymonthday($times,$freq);
+ $times = restrict_byday($times,$freq);
+ $times = restrict_bysetpos($times,$freq);
+
+ foreach ($times as $time) if(isset($time)) $recur_data[] = $time;
+ return;
+}
+
+function expand_byday($time){
+ global $freq_type, $byday, $wkst3char;
+ $the_sunday = dateOfWeek(date("Ymd",$time), $wkst3char);
+# echo "$freq_type, ".print_r($byday,true)."$wkst3char $the_sunday";
+ if (empty($byday)) $byday[] = strtoupper(substr(date('D', $time), 0, 2));
+ foreach($byday as $key=>$day) {
+ /* set $byday_arr
+ [0] => byday string, e.g. 4TH
+ [1] => sign/modifier
+ [2] => 4 number
+ [3] => TH day abbr
+ */
+ ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr);
+ $on_day = two2threeCharDays($byday_arr[3]);
+ switch($freq_type){
+ case 'week':
+ #need to find the first day of the appropriate week.
+ if ($key == 0){
+ $next_date_time = strtotime("next $on_day",strtotime($the_sunday)) + (12 * 60 * 60);
+ }else{
+ $next_date_time = strtotime("next $on_day",$next_date_time) + (12 * 60 * 60);
+ }
+ default:
+ $next_date_time = strtotime($byday_arr[1].$byday_arr[2].$on_day, $time);
+ }
+ $times[] = $next_date_time;
+ }
+ return $times;
+}
+
+
+function restrict_bymonth($times,$freq=''){
+ global $bymonth;
+ if (empty($bymonth)) return $times;
+ foreach ($times as $time) if(in_array(date("m", $time), $bymonth)) $new_times[] = $time;
+ return $new_times;
+}
+function restrict_byweekno($times,$freq=''){
+ global $byweekno;
+ if(empty($byweekno)) return $times;
+ foreach ($times as $time) if(in_array(date("W", $time), $byweekno)) $new_times[] = $time;
+ return $new_times;
+
+}
+function restrict_byyearday($times,$freq=''){
+ global $byyearday;
+ if(empty($byyearday)) return $times;
+ foreach ($times as $time) if(in_array(date("z", $time), $byyearday)) $new_times[] = $time;
+ return $new_times;
+}
+
+function restrict_bymonthday($times,$freq=''){
+ global $bymonthday;
+ if(empty($bymonthday)) return $times;
+ foreach ($times as $time) if(in_array(date("j", $time), $bymonthday)) $new_times[] = $time;
+ return $new_times;
+}
+function restrict_byday($times,$freq=''){
+ global $byday;
+ if(empty($byday)) return $times;
+ foreach($byday as $key=>$day) $byday3[] = two2threeCharDays($day);
+ foreach ($times as $time) if(in_array(strtolower(date("D", $time)), $byday3)) $new_times[] = $time;
+ return $new_times;
+}
+
+function restrict_bysetpos($times,$freq=''){
+ global $rrule_array, $bysetpos;
+ if(empty($bysetpos)) return $times;
+
+} \ No newline at end of file
diff --git a/functions/template.php b/functions/template.php
index c5a9c6f..b6e1e2d 100644
--- a/functions/template.php
+++ b/functions/template.php
@@ -10,7 +10,7 @@ class Page {
$this->page = str_replace('{SUBSCRIBE_PATH}', $subscribe_path, $this->page);
$this->page = str_replace('{DOWNLOAD_FILENAME}', $download_filename, $this->page);
} else {
- $this->page = preg_replace('!<\!-- switch display_download on -->(.*)<\!-- switch display_download off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch display_download on -->(.*)<\!-- switch display_download off -->!Uis', '', $this->page);
}
}
@@ -48,16 +48,16 @@ class Page {
$this->page = str_replace('{DELETE_TABLE}', $delete_table, $this->page);
} else {
- $this->page = preg_replace('!<\!-- switch logged_in on -->(.*)<\!-- switch logged_in off -->!is', '', $this->page);
- $this->page = preg_replace('!<\!-- switch logged_in2 on -->(.*)<\!-- switch logged_in2 off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch logged_in on -->(.*)<\!-- switch logged_in off -->!Uis', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch logged_in2 on -->(.*)<\!-- switch logged_in2 off -->!Uis', '', $this->page);
}
}
function draw_print($template_p) {
global $phpiCal_config, $getdate, $cal, $master_array, $printview, $dateFormat_day, $timeFormat, $week_start, $week_end, $lang;
- preg_match("!<\!-- loop events on -->(.*)<\!-- loop events off -->!is", $this->page, $match1);
- preg_match("!<\!-- switch some_events on -->(.*)<\!-- loop events on -->!is", $this->page, $match3);
+ preg_match("!<\!-- loop events on -->(.*)<\!-- loop events off -->!Uis", $this->page, $match1);
+ preg_match("!<\!-- switch some_events on -->(.*)<\!-- loop events on -->!Uis", $this->page, $match3);
$loop_event = trim($match1[1]);
$loop_day = trim($match3[1]);
$parse_month = date ("Ym", strtotime($getdate));
@@ -102,11 +102,11 @@ class Page {
}
if ($description == '') {
- $events_tmp = preg_replace('!<\!-- switch description_events on -->(.*)<\!-- switch description_events off -->!is', '', $events_tmp);
+ $events_tmp = preg_replace('!<\!-- switch description_events on -->(.*)<\!-- switch description_events off -->!Uis', '', $events_tmp);
}
if ($location == '') {
- $events_tmp = preg_replace('!<\!-- switch location_events on -->(.*)<\!-- switch location_events off -->!is', '', $events_tmp);
+ $events_tmp = preg_replace('!<\!-- switch location_events on -->(.*)<\!-- switch location_events off -->!Uis', '', $events_tmp);
}
$search = array('{EVENT_START}', '{EVENT_TEXT}', '{DESCRIPTION}', '{LOCATION}');
@@ -124,19 +124,19 @@ class Page {
}
if ($events_week < 1) {
- $this->page = preg_replace('!<\!-- switch some_events on -->(.*)<\!-- switch some_events off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch some_events on -->(.*)<\!-- switch some_events off -->!Uis', '', $this->page);
} else {
- $this->page = preg_replace('!<\!-- switch some_events on -->(.*)<\!-- switch some_events off -->!is', $final, $this->page);
- $this->page = preg_replace('!<\!-- switch no_events on -->(.*)<\!-- switch no_events off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch some_events on -->(.*)<\!-- switch some_events off -->!Uis', $final, $this->page);
+ $this->page = preg_replace('!<\!-- switch no_events on -->(.*)<\!-- switch no_events off -->!Uis', '', $this->page);
}
}
function draw_search($template_p) {
global $phpiCal_config, $getdate, $cal, $the_arr, $printview, $dateFormat_day, $timeFormat, $week_start, $week_end, $lang;
- preg_match("!<\!-- switch results on -->(.*)<\!-- switch results off -->!is", $this->page, $match1);
- preg_match("!<\!-- switch recur on -->(.*)<\!-- loop recur off -->!is", $this->page, $match2);
- preg_match("!<\!-- switch exceptions on -->(.*)<\!-- switch exceptions off -->!is", $this->page, $match3);
+ preg_match("!<\!-- switch results on -->(.*)<\!-- switch results off -->!Uis", $this->page, $match1);
+ preg_match("!<\!-- switch recur on -->(.*)<\!-- loop recur off -->!Uis", $this->page, $match2);
+ preg_match("!<\!-- switch exceptions on -->(.*)<\!-- switch exceptions off -->!Uis", $this->page, $match3);
$loop_event = trim($match1[1]);
$loop_recur = trim($match2[1]);
$loop_except = trim($match3[1]);
@@ -172,10 +172,10 @@ class Page {
}
if ($description == '') {
- $events_tmp = preg_replace('!<\!-- switch description_events on -->(.*)<\!-- switch description_events off -->!is', '', $events_tmp);
+ $events_tmp = preg_replace('!<\!-- switch description_events on -->(.*)<\!-- switch description_events off -->!Uis', '', $events_tmp);
}
if (!isset($val['exceptions'])) {
- $events_tmp = preg_replace('!<\!-- switch exceptions on -->(.*)<\!-- switch exceptions off -->!is', '', $events_tmp);
+ $events_tmp = preg_replace('!<\!-- switch exceptions on -->(.*)<\!-- switch exceptions off -->!Uis', '', $events_tmp);
}else{
$some_exceptions = "";
foreach ($val['exceptions'] as $except_val){
@@ -196,13 +196,13 @@ class Page {
#is there a recur in the exception?
if (!$except_val['recur']) {
- $except_tmp = preg_replace('!<\!-- switch except_recur on -->(.*)<\!-- switch except_recur off -->!is', '', $except_tmp);
+ $except_tmp = preg_replace('!<\!-- switch except_recur on -->(.*)<\!-- switch except_recur off -->!Uis', '', $except_tmp);
}else{
$except_tmp = str_replace('{EXCEPT_RECUR}', $except_val['recur'], $except_tmp);
}
#is there a description in the exception?
if (!$except_val['description']) {
- $except_tmp = preg_replace('!<\!-- switch except_description on -->(.*)<\!-- switch except_description off -->!is', '', $except_tmp);
+ $except_tmp = preg_replace('!<\!-- switch except_description on -->(.*)<\!-- switch except_description off -->!Uis', '', $except_tmp);
}else{
$except_description = stripslashes(urldecode($except_val['description']));
$except_tmp = str_replace('{EXCEPT_DESCRIPTION}', $except_description, $except_tmp);
@@ -210,13 +210,13 @@ class Page {
$some_exceptions .= $except_tmp;
}
- $events_tmp = preg_replace('!<\!-- switch exceptions on -->(.*)<\!-- switch exceptions off -->!is', $some_exceptions,$events_tmp );
+ $events_tmp = preg_replace('!<\!-- switch exceptions on -->(.*)<\!-- switch exceptions off -->!Uis', $some_exceptions,$events_tmp );
}
if (!$val['recur']) {
- $events_tmp = preg_replace('!<\!-- switch recur on -->(.*)<\!-- switch recur off -->!is', '', $events_tmp);
+ $events_tmp = preg_replace('!<\!-- switch recur on -->(.*)<\!-- switch recur off -->!Uis', '', $events_tmp);
}else{
$events_tmp = str_replace('{RECUR}', $val['recur'], $events_tmp);
}
@@ -236,10 +236,10 @@ class Page {
}
}
if ($events_found < 1) {
- $this->page = preg_replace('!<\!-- switch results on -->(.*)<\!-- switch results off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch results on -->(.*)<\!-- switch results off -->!Uis', '', $this->page);
} else {
- $this->page = preg_replace('!<\!-- switch results on -->(.*)<\!-- switch results off -->!is', $final, $this->page);
- $this->page = preg_replace('!<\!-- switch no_results on -->(.*)<\!-- switch no_results off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch results on -->(.*)<\!-- switch results off -->!Uis', $final, $this->page);
+ $this->page = preg_replace('!<\!-- switch no_results on -->(.*)<\!-- switch no_results off -->!Uis', '', $this->page);
#echo "<hr>this->page: $this->page<br><hr>";
}
@@ -272,11 +272,10 @@ class Page {
$weekarray[$i] = $thisdate;
$start_week_time = strtotime('+1 day', $start_week_time);
}
-
// Replaces the allday events
- preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!is", $this->page, $match1);
- preg_match("!<\!-- loop alldaysofweek on -->(.*)<\!-- loop allday on -->!is", $this->page, $match2);
- preg_match("!<\!-- loop allday off -->(.*)<\!-- loop alldaysofweek off -->!is", $this->page, $match3);
+ preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!Uis", $this->page, $match1);
+ preg_match("!<\!-- loop alldaysofweek on -->(.*)<\!-- loop allday on -->!Uis", $this->page, $match2);
+ preg_match("!<\!-- loop allday off -->(.*)<\!-- loop alldaysofweek off -->!Uis", $this->page, $match3);
$loop_ad = trim($match1[1]);
$loop_begin = trim($match2[1]);
$loop_end = trim($match3[1]);
@@ -297,13 +296,14 @@ class Page {
$replace .= $loop_end;
$weekreplace .= $replace;
}
- $this->page = preg_replace('!<\!-- loop alldaysofweek on -->(.*)<\!-- loop alldaysofweek off -->!is', $weekreplace, $this->page);
+ $this->page = preg_replace('!<\!-- loop alldaysofweek on -->(.*)<\!-- loop alldaysofweek off -->!Uis', $weekreplace, $this->page);
// Replaces the daysofweek
- preg_match("!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is", $this->page, $match1);
+ preg_match("!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!Uis", $this->page, $match1);
$loop_dof = trim($match1[1]);
$start_wt = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day));
$start_day = strtotime($phpiCal_config->week_start_day);
+ $weekday_loop = '';
for ($i=0; $i<$phpiCal_config->week_length; $i++) {
$day_num = date("w", $start_day);
$daylink = date('Ymd', $start_wt);
@@ -330,11 +330,11 @@ class Page {
$loop_tmp = str_replace($search, $replace, $loop_dof);
$weekday_loop .= $loop_tmp;
}
- $this->page = preg_replace('!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is', $weekday_loop, $this->page);
+ $this->page = preg_replace('!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!Uis', $weekday_loop, $this->page);
// Build the body
- preg_match("!<\!-- loop row on -->(.*)<\!-- loop row off -->!is", $this->page, $match2);
- preg_match("!<\!-- loop event on -->(.*)<\!-- loop event off -->!is", $this->page, $match3);
+ preg_match("!<\!-- loop row on -->(.*)<\!-- loop row off -->!Uis", $this->page, $match2);
+ preg_match("!<\!-- loop event on -->(.*)<\!-- loop event off -->!Uis", $this->page, $match3);
$loop_hours = trim($match2[1]);
$loop_event = trim($match3[1]);
@@ -508,15 +508,15 @@ class Page {
$weekdisplay .= "</tr>\n";
}
- $this->page = preg_replace('!<\!-- loop row on -->(.*)<\!-- loop event off -->!is', $weekdisplay, $this->page);
+ $this->page = preg_replace('!<\!-- loop row on -->(.*)<\!-- loop event off -->!Uis', $weekdisplay, $this->page);
}
function draw_day($template_p) {
- global $getdate, $cal, $master_array, $dateFormat_week_list, $current_view, $day_array, $timeFormat, $phpiCal_config;
+ global $getdate, $cal, $master_array, $dateFormat_week_list, $current_view, $day_array, $timeFormat, $phpiCal_config, $daysofweek_lang;
// Replaces the allday events
$replace = '';
- if (is_array($master_array[$getdate]['-1'])) {
- preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!is", $this->page, $match1);
+ if (is_array(@$master_array[$getdate]['-1'])) {
+ preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!Uis", $this->page, $match1);
$loop_ad = trim($match1[1]);
foreach ($master_array[$getdate]['-1'] as $uid => $allday) {
$event_calno = $allday['calnumber'];
@@ -527,10 +527,10 @@ class Page {
$replace .= $loop_tmp;
}
}
- $this->page = preg_replace('!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!is', $replace, $this->page);
+ $this->page = preg_replace('!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!Uis', $replace, $this->page);
// Replaces the daysofweek
- preg_match("!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is", $this->page, $match1);
+ preg_match("!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!Uis", $this->page, $match1);
$loop_dof = trim($match1[1]);
$start_wt = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day));
$start_day = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day));
@@ -558,7 +558,7 @@ class Page {
$loop_tmp = str_replace($search, $replace, $loop_dof);
$weekday_loop .= $loop_tmp;
}
- $this->page = preg_replace('!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is', $weekday_loop, $this->page);
+ $this->page = preg_replace('!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!Uis', $weekday_loop, $this->page);
// Build the body
$dayborder = 0;
@@ -573,8 +573,8 @@ class Page {
}
}
}
- preg_match("!<\!-- loop row on -->(.*)<\!-- loop row off -->!is", $this->page, $match2);
- preg_match("!<\!-- loop event on -->(.*)<\!-- loop event off -->!is", $this->page, $match3);
+ preg_match("!<\!-- loop row on -->(.*)<\!-- loop row off -->!Uis", $this->page, $match2);
+ preg_match("!<\!-- loop event on -->(.*)<\!-- loop event off -->!Uis", $this->page, $match3);
$loop_hours = trim($match2[1]);
$loop_event = trim($match3[1]);
@@ -583,7 +583,7 @@ class Page {
preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $getdate, $day_array2);
$this_day = $day_array2[3];
$this_month = $day_array2[2];
- $this_year = $day_array2[1];
+ $this_year = $day_array2[1];
foreach ($day_array as $key) {
preg_match('/([0-9]{2})([0-9]{2})/', $key, $regs_tmp);
$cal_time = $key;
@@ -723,9 +723,10 @@ class Page {
}
}
- $daydisplay .= '</tr>'."\n";
- }
- $this->page = preg_replace('!<\!-- loop row on -->(.*)<\!-- loop event off -->!is', $daydisplay, $this->page);
+ $daydisplay .= '</tr>'."\n";
+ }
+
+ $this->page = preg_replace('!<\!-- loop row on -->(.*)<\!-- loop event off -->!Uis', $daydisplay, $this->page);
}
@@ -733,8 +734,8 @@ class Page {
function tomorrows_events() {
global $phpiCal_config, $getdate, $master_array, $next_day, $timeFormat, $tomorrows_events_lines;
- preg_match("!<\!-- switch t_allday on -->(.*)<\!-- switch t_allday off -->!is", $this->page, $match1);
- preg_match("!<\!-- switch t_event on -->(.*)<\!-- switch t_event off -->!is", $this->page, $match2);
+ preg_match("!<\!-- switch t_allday on -->(.*)<\!-- switch t_allday off -->!Uis", $this->page, $match1);
+ preg_match("!<\!-- switch t_event on -->(.*)<\!-- switch t_event off -->!Uis", $this->page, $match2);
$loop_t_ad = trim($match1[1]);
$loop_t_e = trim($match2[1]);
$return_adtmp = '';
@@ -757,12 +758,12 @@ class Page {
}
}
- $this->page = preg_replace('!<\!-- switch t_allday on -->(.*)<\!-- switch t_allday off -->!is', $replace_ad, $this->page);
- $this->page = preg_replace('!<\!-- switch t_event on -->(.*)<\!-- switch t_event off -->!is', $replace_e, $this->page);
+ $this->page = preg_replace('!<\!-- switch t_allday on -->(.*)<\!-- switch t_allday off -->!Uis', $replace_ad, $this->page);
+ $this->page = preg_replace('!<\!-- switch t_event on -->(.*)<\!-- switch t_event off -->!Uis', $replace_e, $this->page);
} else {
- $this->page = preg_replace('!<\!-- switch tomorrows_events on -->(.*)<\!-- switch tomorrows_events off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch tomorrows_events on -->(.*)<\!-- switch tomorrows_events off -->!Uis', '', $this->page);
}
}
@@ -770,15 +771,15 @@ class Page {
function get_vtodo() {
global $phpiCal_config, $getdate, $master_array, $next_day, $timeFormat, $tomorrows_events_lines;
- preg_match("!<\!-- switch show_completed on -->(.*)<\!-- switch show_completed off -->!is", $this->page, $match1);
- preg_match("!<\!-- switch show_important on -->(.*)<\!-- switch show_important off -->!is", $this->page, $match2);
- preg_match("!<\!-- switch show_normal on -->(.*)<\!-- switch show_normal off -->!is", $this->page, $match3);
+ preg_match("!<\!-- switch show_completed on -->(.*)<\!-- switch show_completed off -->!Uis", $this->page, $match1);
+ preg_match("!<\!-- switch show_important on -->(.*)<\!-- switch show_important off -->!Uis", $this->page, $match2);
+ preg_match("!<\!-- switch show_normal on -->(.*)<\!-- switch show_normal off -->!Uis", $this->page, $match3);
$completed = trim($match1[1]);
$important = trim($match2[1]);
$normal = trim($match3[1]);
$nugget2 = '';
$todo_popup_data_index = 0;
- if (is_array($master_array['-2'])) {
+ if (is_array(@$master_array['-2'])) {
foreach ($master_array['-2'] as $vtodo_times) {
foreach ($vtodo_times as $val) {
$vtodo_text = stripslashes(urldecode($val["vtodo_text"]));
@@ -843,24 +844,24 @@ class Page {
// If there are no TODO items, completely hide the TODO list.
if (($nugget2 == '') || ($phpiCal_config->show_todos != 'yes')) {
- $this->page = preg_replace('!<\!-- switch vtodo on -->(.*)<\!-- switch vtodo off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch vtodo on -->(.*)<\!-- switch vtodo off -->!Uis', '', $this->page);
}
// Otherwise display the list of TODOs.
else {
- $this->page = preg_replace('!<\!-- switch show_completed on -->(.*)<\!-- switch show_normal off -->!is', $nugget2, $this->page);
+ $this->page = preg_replace('!<\!-- switch show_completed on -->(.*)<\!-- switch show_normal off -->!Uis', $nugget2, $this->page);
}
}
function draw_month($template_p, $offset = '+0', $type) {
- global $phpiCal_config, $getdate, $master_array, $this_year, $this_month, $dateFormat_month, $cal, $minical_view, $month_event_lines, $daysofweekreallyshort_lang, $daysofweekshort_lang, $timeFormat_small, $timeFormat;
- preg_match("!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!is", $template_p, $match1);
- preg_match("!<\!-- loop monthdays on -->(.*)<\!-- loop monthdays off -->!is", $template_p, $match2);
- preg_match("!<\!-- switch notthismonth on -->(.*)<\!-- switch notthismonth off -->!is", $template_p, $match3);
- preg_match("!<\!-- switch istoday on -->(.*)<\!-- switch istoday off -->!is", $template_p, $match4);
- preg_match("!<\!-- switch ismonth on -->(.*)<\!-- switch ismonth off -->!is", $template_p, $match5);
- preg_match("!<\!-- loop monthweeks on -->(.*)<\!-- loop monthdays on -->!is", $template_p, $match6);
- preg_match("!<\!-- loop monthdays off -->(.*)<\!-- loop monthweeks off -->!is", $template_p, $match7);
+ global $phpiCal_config, $getdate, $master_array, $this_year, $this_month, $dateFormat_month, $cal, $minical_view, $month_event_lines, $daysofweekreallyshort_lang, $daysofweekshort_lang, $daysofweek_lang, $timeFormat_small, $timeFormat;
+ preg_match("!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!Uis", $template_p, $match1);
+ preg_match("!<\!-- loop monthdays on -->(.*)<\!-- loop monthdays off -->!Uis", $template_p, $match2);
+ preg_match("!<\!-- switch notthismonth on -->(.*)<\!-- switch notthismonth off -->!Uis", $template_p, $match3);
+ preg_match("!<\!-- switch istoday on -->(.*)<\!-- switch istoday off -->!Uis", $template_p, $match4);
+ preg_match("!<\!-- switch ismonth on -->(.*)<\!-- switch ismonth off -->!Uis", $template_p, $match5);
+ preg_match("!<\!-- loop monthweeks on -->(.*)<\!-- loop monthdays on -->!Uis", $template_p, $match6);
+ preg_match("!<\!-- loop monthdays off -->(.*)<\!-- loop monthweeks off -->!Uis", $template_p, $match7);
$loop_wd = trim($match1[1]);
$loop_md = trim($match2[1]);
@@ -895,7 +896,7 @@ class Page {
} elseif ($type == 'medium') {
$langtype = $daysofweekshort_lang;
} elseif ($type == 'large') {
- $langtype = $phpiCal_config->daysofweek_lang;
+ $langtype = $daysofweek_lang;
}
$weekday_loop = '';
@@ -978,7 +979,7 @@ class Page {
} while ($whole_month == TRUE);
$return = str_replace('<!-- loop weekday on -->'.$match1[1].'<!-- loop weekday off -->', $weekday_loop, $template_p);
- $return = preg_replace('!<\!-- loop monthweeks on -->(.*)<\!-- loop monthweeks off -->!is', $middle, $return);
+ $return = preg_replace('!<\!-- loop monthweeks on -->(.*)<\!-- loop monthweeks off -->!Uis', $middle, $return);
$return = str_replace('{MONTH_TITLE}', $month_title, $return);
$return = str_replace('{CAL}', $cal, $return);
$return = str_replace('{MONTH_DATE}', $month_date, $return);
@@ -987,17 +988,17 @@ class Page {
}
function nomonthbottom() {
- $this->page = preg_replace('!<\!-- switch showbottom on -->(.*)<\!-- switch showbottom off -->!is','', $this->page);
+ $this->page = preg_replace('!<\!-- switch showbottom on -->(.*)<\!-- switch showbottom off -->!Uis','', $this->page);
}
function nosearch() {
- $this->page = preg_replace('!<\!-- switch show_search on -->(.*)<\!-- switch show_search off -->!is','', $this->page);
+ $this->page = preg_replace('!<\!-- switch show_search on -->(.*)<\!-- switch show_search off -->!Uis','', $this->page);
}
function monthbottom() {
global $phpiCal_config, $getdate, $master_array, $this_year, $this_month, $cal, $timeFormat, $timeFormat_small, $dateFormat_week_list, $lang;
- preg_match("!<\!-- loop showbottomevents_odd on -->(.*)<\!-- loop showbottomevents_odd off -->!is", $this->page, $match1);
- preg_match("!<\!-- loop showbottomevents_even on -->(.*)<\!-- loop showbottomevents_even off -->!is", $this->page, $match2);
+ preg_match("!<\!-- loop showbottomevents_odd on -->(.*)<\!-- loop showbottomevents_odd off -->!Uis", $this->page, $match1);
+ preg_match("!<\!-- loop showbottomevents_even on -->(.*)<\!-- loop showbottomevents_even off -->!Uis", $this->page, $match2);
$loop[0] = trim($match1[1]);
$loop[1] = trim($match2[1]);
@@ -1052,7 +1053,7 @@ class Page {
# unset ($switch);
} while ($this_month == $check_month);
- $this->page = preg_replace('!<\!-- loop showbottomevents_odd on -->(.*)<\!-- loop showbottomevents_even off -->!is', $middle, $this->page);
+ $this->page = preg_replace('!<\!-- loop showbottomevents_odd on -->(.*)<\!-- loop showbottomevents_even off -->!Uis', $middle, $this->page);
}
@@ -1064,6 +1065,7 @@ class Page {
if (!file_exists($file)) die("Template file $file not found.");
}
$this->page = join('', file($file));
+ return;
}
function parse($file) {
@@ -1090,7 +1092,7 @@ class Page {
// This removes any unfilled tags
if (!$data) {
- $this->page = preg_replace('!<\!-- switch ' . $tag . ' on -->(.*)<\!-- switch ' . $tag . ' off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch ' . $tag . ' on -->(.*)<\!-- switch ' . $tag . ' off -->!Uis', '', $this->page);
}
// This replaces any tags
@@ -1110,7 +1112,7 @@ class Page {
// This removes any unfilled tags
if (!$data) {
- $this->page = preg_replace('!<\!-- switch ' . $tag . ' on -->(.*)<\!-- switch ' . $tag . ' off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch ' . $tag . ' on -->(.*)<\!-- switch ' . $tag . ' off -->!Uis', '', $this->page);
}
// This replaces any tags
@@ -1125,24 +1127,24 @@ class Page {
global $phpiCal_config, $php_started, $lang, $template_started, $cpath;
// Looks for {MONTH} before sending page out
- preg_match_all ('!\{MONTH_([A-Z]*)\|?([+|-])([0-9]{1,2})\}!is', $this->page, $match);
+ preg_match_all ('!\{MONTH_([A-Z]*)\|?([+|-])([0-9]{1,2})\}!Uis', $this->page, $match);
if (sizeof($match) > 0) {
$i=0;
foreach ($match[1] as $key => $val) {
if ($match[1][$i] == 'SMALL') {
- $phpiCal_config->template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_small.tpl');
+ $template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_small.tpl');
$type = 'small';
$offset = $match[2][$i].$match[3][$i];
} elseif ($match[1][$i] == 'MEDIUM') {
- $phpiCal_config->template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_medium.tpl');
+ $template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_medium.tpl');
$type = 'medium';
$offset = $match[3][$i];
} else {
- $phpiCal_config->template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_large.tpl');
+ $template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_large.tpl');
$type = 'large';
$offset = $match[2][$i].$match[3][$i];
}
- $data = $this->draw_month($phpiCal_config->template_file, $offset, $type);
+ $data = $this->draw_month($template_file, $offset, $type);
$this->page = str_replace($match[0][$i], $data, $this->page);
$i++;
}
@@ -1150,11 +1152,11 @@ class Page {
$php_ended = @getmicrotime();
$generated1 = number_format(($php_ended-$php_started),3);
- $generated2 = number_format(($php_ended-$phpiCal_config->template_started),3);
+ $generated2 = number_format(($php_ended-$template_started),3);
$this->page = str_replace('{GENERATED1}', $generated1, $this->page);
$this->page = str_replace('{GENERATED2}', $generated2, $this->page);
if ($phpiCal_config->enable_rss != 'yes') {
- $this->page = preg_replace('!<\!-- switch rss_powered on -->(.*)<\!-- switch rss_powered off -->!is', '', $this->page);
+ $this->page = preg_replace('!<\!-- switch rss_powered on -->(.*)<\!-- switch rss_powered off -->!Uis', '', $this->page);
} else {
$this->page = str_replace('{BASE}', BASE, $this->page);
}
diff --git a/month.php b/month.php
index 6c38848..0982718 100644
--- a/month.php
+++ b/month.php
@@ -5,10 +5,10 @@ require_once(BASE.'functions/ical_parser.php');
require_once(BASE.'functions/list_functions.php');
require_once(BASE.'functions/template.php');
header("Content-Type: text/html; charset=$charset");
-if ($minical_view == 'current') $minical_view = 'month';
+if ($phpiCal_config->minical_view == 'current') $minical_view = 'month';
$unix_time = strtotime($getdate);
-$today_today = date('Ymd', time() + $second_offset);
+$today_today = date('Ymd', time() + $phpiCal_config->second_offset);
$tomorrows_date = date('Ymd', strtotime("+1 day", $unix_time));
$yesterdays_date = date('Ymd', strtotime("-1 day", $unix_time));
$sidebar_date = localizeDate($dateFormat_week_list, $unix_time);
@@ -33,7 +33,7 @@ $prev_month = date("Ymd", $prev_month_time);
$display_date = localizeDate ($dateFormat_month, $unix_time);
$parse_month = date ("Ym", $unix_time);
$first_of_month = $this_year.$this_month."01";
-$start_month_day = dateOfWeek($first_of_month, $week_start_day);
+$start_month_day = dateOfWeek($first_of_month, $phpiCal_config->week_start_day);
$thisday2 = localizeDate($dateFormat_week_list, $unix_time);
$num_of_events2 = 0;
@@ -70,7 +70,7 @@ $page->replace_tags(array(
'default_path' => '',
'rss_available' => '',
'rss_valid' => '',
- 'show_search' => $show_search,
+ 'show_search' => $phpiCal_config->show_search,
'next_month' => $next_month,
'prev_month' => $prev_month,
'show_goto' => '',
diff --git a/week.php b/week.php
index c0a9d70..1807eb7 100644
--- a/week.php
+++ b/week.php
@@ -4,13 +4,13 @@ define('BASE', './');
require_once(BASE.'functions/ical_parser.php');
require_once(BASE.'functions/list_functions.php');
require_once(BASE.'functions/template.php');
-header("Content-Type: text/html; charset=$charset");
-if ($minical_view == "current") $minical_view = "week";
+header("Content-Type: text/html; charset=$phpiCal_config->charset");
+if ($phpiCal_config->minical_view == "current") $minical_view = "week";
$starttime = "0500";
$weekstart = 1;
$unix_time = strtotime($getdate);
-$today_today = date('Ymd', time() + $second_offset);
+$today_today = date('Ymd', time() + $second_offset);
$next_week = date("Ymd", strtotime("+1 week", $unix_time));
$prev_week = date("Ymd", strtotime("-1 week", $unix_time));
$next_day = date('Ymd', strtotime("+1 day", $unix_time));
@@ -88,7 +88,7 @@ $page->replace_tags(array(
'list_weeks' => $list_weeks,
'list_jumps' => $list_jumps,
'legend' => $list_calcolors,
- 'style_select' => $style_select,
+ 'style_select' => '',
'l_goprint' => $lang['l_goprint'],
'l_preferences' => $lang['l_preferences'],
'l_calendar' => $lang['l_calendar'],

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