diff options
author | Chad Little <clittle@users.sourceforge.net> | 2004-05-23 08:23:44 +0000 |
---|---|---|
committer | Chad Little <clittle@users.sourceforge.net> | 2004-05-23 08:23:44 +0000 |
commit | d2174d8d9b99ded409e70e1bf70f46488a6c4457 (patch) | |
tree | 12ba15b6304603dab170cfae3c4cff650f75e29e | |
parent | 965b7c97bfab2eedfd38613b83fc40c15d7c08ba (diff) | |
download | phpicalendar-d2174d8d9b99ded409e70e1bf70f46488a6c4457.tar.gz phpicalendar-d2174d8d9b99ded409e70e1bf70f46488a6c4457.tar.bz2 phpicalendar-d2174d8d9b99ded409e70e1bf70f46488a6c4457.zip |
Added cache for All Combined.
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | config.inc.php | 2 | ||||
-rw-r--r-- | functions/ical_parser.php | 62 |
3 files changed, 52 insertions, 13 deletions
@@ -100,6 +100,7 @@ Changes: -RSS supports ports other than 80. -RSS respects $calendar_path. -YEARLY repeating events display better. + -All Calendars Combined can now be cached for greater performance. -Various bug fixes. 1.1 diff --git a/config.inc.php b/config.inc.php index 6ac9e4b..e723366 100644 --- a/config.inc.php +++ b/config.inc.php @@ -30,7 +30,7 @@ $download_uri = ''; // The HTTP URL to your calendars directory, ie. http: $default_path = 'http://www.example.com/phpicalendar'; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar // Yes/No questions --- 'yes' means Yes, anything else means no. 'yes' must be lowercase. -$save_parsed_cals = 'no'; // Recommended 'yes'. Saves a copy of the cal in /tmp after it's been parsed. Improves performence. +$save_parsed_cals = 'yes'; // Recommended 'yes'. Saves a copy of the cal in /tmp after it's been parsed. Improves performence. $display_custom_goto = 'no'; // In the 'Jump To' box, display the custom 'go to day' box. $display_ical_list = 'yes'; // In the 'Jump To' box, display the pop-up menu with the list of all calendars in the $calendar_path directory. $allow_webcals = 'no'; // Allow http:// and webcal:// prefixed URLs to be used as the $cal for remote viewing of "subscribe-able" calendars. This does not have to be enabled to allow specific ones below. diff --git a/functions/ical_parser.php b/functions/ical_parser.php index 877bd60..aef5911 100644 --- a/functions/ical_parser.php +++ b/functions/ical_parser.php @@ -33,20 +33,53 @@ $this_year = $day_array2[1]; // reading the file if it's allowed $parse_file = true; -if (($is_webcal == false) && ($save_parsed_cals == 'yes') && ($cal != $ALL_CALENDARS_COMBINED)) { - $realcal_mtime = filemtime($filename); - $parsedcal = $tmp_dir.'/parsedcal-'.$cal_filename.'-'.$this_year; - if (file_exists($parsedcal)) { - $parsedcal_mtime = filemtime($parsedcal); - if ($realcal_mtime == $parsedcal_mtime) { +if (($is_webcal == false) && ($save_parsed_cals == 'yes')) { + if (sizeof ($cal_filelist) > 1) { + $parsedcal = $tmp_dir.'/parsedcal-'.$cal_filename.'-'.$this_year; + if (file_exists($parsedcal)) { $fd = fopen($parsedcal, 'r'); $contents = fread($fd, filesize($parsedcal)); fclose($fd); $master_array = unserialize($contents); - if ($master_array['-1'] == 'valid cal file') { - $parse_file = false; - $calendar_name = $master_array['calendar_name']; - $calendar_tz = $master_array['calendar_tz']; + $z=1; + $y=0; + if (sizeof($master_array['-4']) == (sizeof($cal_filelist))) { + foreach ($master_array['-4'] as $temp_array) { + $mtime = $master_array['-4'][$z]['mtime']; + $fname = $master_array['-4'][$z]['filename']; + $realcal_mtime = filemtime($fname); + if ($mtime == $realcal_mtime) { + $y++; + } + $z++; + } + if ($y == sizeof($cal_filelist)) { + if ($master_array['-1'] == 'valid cal file') { + $parse_file = false; + $calendar_name = $master_array['calendar_name']; + $calendar_tz = $master_array['calendar_tz']; + } + } + } + } + if ($parse_file == true) unset($master_array); + } else { + foreach ($cal_filelist as $filename) { + $realcal_mtime = filemtime($filename); + $parsedcal = $tmp_dir.'/parsedcal-'.$cal_filename.'-'.$this_year; + if (file_exists($parsedcal)) { + $parsedcal_mtime = filemtime($parsedcal); + if ($realcal_mtime == $parsedcal_mtime) { + $fd = fopen($parsedcal, 'r'); + $contents = fread($fd, filesize($parsedcal)); + fclose($fd); + $master_array = unserialize($contents); + if ($master_array['-1'] == 'valid cal file') { + $parse_file = false; + $calendar_name = $master_array['calendar_name']; + $calendar_tz = $master_array['calendar_tz']; + } + } } } } @@ -71,6 +104,9 @@ foreach ($cal_filelist as $filename) { $nextline = fgets($ifile, 1024); if (trim($nextline) != 'BEGIN:VCALENDAR') exit(error($error_invalidcal_lang, $filename)); + //Mod time + $actual_mtime = filemtime($filename); + // Set a value so we can check to make sure $master_array contains valid data $master_array['-1'] = 'valid cal file'; @@ -120,6 +156,8 @@ foreach ($cal_filelist as $filename) { case 'END:VEVENT': if (!isset($master_array[-3][$calnumber])) $master_array[-3][$calnumber] = $actual_calname; + if (!isset($master_array[-4][$calnumber]['mtime'])) $master_array[-4][$calnumber]['mtime'] = $actual_mtime; + if (!isset($master_array[-4][$calnumber]['filename'])) $master_array[-4][$calnumber]['filename'] = $filename; // Handle DURATION if (!isset($end_unixtime) && isset($the_duration)) { @@ -1093,7 +1131,7 @@ if ($parse_file) { } // write the new master array to the file - if (isset($master_array) && is_array($master_array) && $save_parsed_cals == 'yes' && $is_webcal == FALSE && $cal != $ALL_CALENDARS_COMBINED) { + if (isset($master_array) && is_array($master_array) && $save_parsed_cals == 'yes' && $is_webcal == FALSE) { $write_me = serialize($master_array); $fd = fopen($parsedcal, 'w'); fwrite($fd, $write_me); @@ -1105,7 +1143,7 @@ if ($parse_file) { //If you want to see the values in the arrays, uncomment below. //print '<pre>'; -//print_r($master_array[20040529]); +//print_r($master_array['-4']); //print_r($overlap_array); //print_r($day_array); //print_r($rrule_array); |