aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Little <clittle@users.sourceforge.net>2004-08-08 01:47:17 +0000
committerChad Little <clittle@users.sourceforge.net>2004-08-08 01:47:17 +0000
commit0b3393545875f1442ea270bd54ced763b6fe54ba (patch)
tree23af2e93f1c36a86f28e2f1defe7a3e613ab6217
parent3e34b9a428a0ba1ba1c3b2df28a33474518c05f1 (diff)
downloadphpicalendar-0b3393545875f1442ea270bd54ced763b6fe54ba.tar.gz
phpicalendar-0b3393545875f1442ea270bd54ced763b6fe54ba.tar.bz2
phpicalendar-0b3393545875f1442ea270bd54ced763b6fe54ba.zip
Added webcal caching.
-rw-r--r--README6
-rw-r--r--config.inc.php3
-rw-r--r--functions/ical_parser.php33
3 files changed, 30 insertions, 12 deletions
diff --git a/README b/README
index a5e4e2f..dfbb172 100644
--- a/README
+++ b/README
@@ -41,8 +41,9 @@ http://phpicalendar.sourceforge.net/phpBB2
Supported Calendar Applications:
--------------------------------
-PHP iCalendar supports any calendar application that can generate
-valid IETF 2445 files (.ics). Some of the supported applications are:
+PHP iCalendar does not edit calendars, instead it supports any calendar
+application that can generate valid IETF 2445 files (.ics).
+Some of the supported applications are:
- Apple iCal
- http://www.apple.com/ical/
@@ -101,6 +102,7 @@ Changes:
-RSS respects $calendar_path.
-YEARLY repeating events display better.
-All Calendars Combined can now be cached for greater performance.
+ -Webcals can be cached for greater performance.
-Parsing engine now twice as fast.
-Various bug fixes.
diff --git a/config.inc.php b/config.inc.php
index b2d29e3..a65b92e 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -43,9 +43,8 @@ $login_cookies = 'no'; // Set to yes to store authentication information via
// Calendar Caching (decreases page load times)
$save_parsed_cals = 'no'; // Saves a copy of the cal in /tmp after it's been parsed. Improves performence.
-$save_parsed_webcals = 'no'; // Saves a copy of the webcal in /tmp after it's been parsed. Improves performence.
$tmp_dir = '/tmp'; // The temporary directory on your system (/tmp is fine for UNIXes including Mac OS X). Any php-writable folder works.
-$webcal_hours = '24'; // Number of hours to cache webcals.
+$webcal_hours = '24'; // Number of hours to cache webcals. Setting to '0' will always re-parse webcals.
// Webdav style publishing
$phpicalendar_publishing = ''; // Set to '1' to enable remote webdav style publish. See 'calendars/publish.php' for complete information;
diff --git a/functions/ical_parser.php b/functions/ical_parser.php
index 47ff58a..6eece29 100644
--- a/functions/ical_parser.php
+++ b/functions/ical_parser.php
@@ -33,7 +33,7 @@ $this_year = $day_array2[1];
// reading the file if it's allowed
$parse_file = true;
-if (($is_webcal == false) && ($save_parsed_cals == 'yes')) {
+if ($save_parsed_cals == 'yes') {
if (sizeof ($cal_filelist) > 1) {
$parsedcal = $tmp_dir.'/parsedcal-'.$cal_filename.'-'.$this_year;
if (file_exists($parsedcal)) {
@@ -47,8 +47,13 @@ if (($is_webcal == false) && ($save_parsed_cals == 'yes')) {
foreach ($master_array['-4'] as $temp_array) {
$mtime = $master_array['-4'][$z]['mtime'];
$fname = $master_array['-4'][$z]['filename'];
+ $wcalc = $master_array['-4'][$z]['webcal'];
$realcal_mtime = filemtime($fname);
- if ($mtime == $realcal_mtime) {
+ $webcal_mtime = strtotime("now -$webcal_hours hours");
+ if (($mtime == $realcal_mtime) && ($wcalc == 'no')) {
+ $y++;
+ } elseif (($wcalc == 'yes') && ($mtime > $webcal_mtime)) {
+ //echo date('H:i',$mtime). ' > '. date('H:i',$webcal_mtime);
$y++;
}
$z++;
@@ -99,16 +104,26 @@ foreach ($cal_filelist as $filename) {
if ($parse_file) {
+ // Let's see if we're doing a webcal
+ $is_webcal == FALSE;
+ if (substr($filename, 0, 7) == 'http://' || substr($filename, 0, 8) == 'https://' || substr($filename, 0, 9) == 'webcal://') {
+ $is_webcal == TRUE;
+ $cal_webcalPrefix = str_replace('http://','webcal://',$filename);
+ $cal_httpPrefix = str_replace('webcal://','http://',$filename);
+ $cal_httpsPrefix = str_replace('webcal://','https://',$filename);
+ $cal_httpsPrefix = str_replace('http://','https://',$cal_httpsPrefix);
+ $filename = $cal_httpPrefix;
+ $master_array['-4'][$calnumber]['webcal'] = 'yes';
+ $actual_mtime = time();
+ } else {
+ $actual_mtime = filemtime($filename);
+ }
+
$ifile = @fopen($filename, "r");
if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $filename));
$nextline = fgets($ifile, 1024);
if (trim($nextline) != 'BEGIN:VCALENDAR') exit(error($lang['l_error_invalidcal'], $filename));
- //Mod time
- if ($is_webcal == false) {
- $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';
@@ -160,6 +175,7 @@ foreach ($cal_filelist as $filename) {
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;
+ if (!isset($master_array['-4'][$calnumber]['webcal'])) $master_array['-4'][$calnumber]['webcal'] = 'no';
if (!isset($url)) $url = '';
if (!isset($type)) $type = '';
@@ -1135,12 +1151,13 @@ 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) {
+ if (isset($master_array) && is_array($master_array) && $save_parsed_cals == 'yes') {
$write_me = serialize($master_array);
$fd = fopen($parsedcal, 'w');
fwrite($fd, $write_me);
fclose($fd);
touch($parsedcal, $realcal_mtime);
+ //echo 'writing file';
}
}

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