Update of /cvsroot/phpicalendar/phpicalendar/functions
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13633/functions
Modified Files:
date_functions.php ical_parser.php
Log Message:
Use http "last-modified" time on webcals and remove "webcals_hours" config setting
Index: date_functions.php
===================================================================
RCS file: /cvsroot/phpicalendar/phpicalendar/functions/date_functions.php,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** date_functions.php 21 May 2009 15:06:12 -0000 1.55
--- date_functions.php 19 Jun 2009 20:39:46 -0000 1.56
***************
*** 5,8 ****
--- 5,32 ----
+ // get remote file last modification date (returns unix timestamp)
+ function remote_filemtime($url) {
+ $fp = fopen($url, 'r');
+ if (!$fp) return 0;
+ $metadata = stream_get_meta_data($fp);
+ fclose($fp);
+
+ $unixtime = 0;
+ foreach ($metadata['wrapper_data'] as $response) {
+ // case: redirection
+ // WARNING: does not handle relative redirection
+ if (substr(strtolower($response), 0, 10) == 'location: ') {
+ return GetRemoteLastModified(substr($response, 10));
+ }
+ // case: last-modified
+ else if (substr(strtolower($response), 0, 15) == 'last-modified: ') {
+ $unixtime = strtotime(substr($response, 15));
+ break;
+ }
+ }
+
+ return $unixtime;
+ }
+
// takes iCalendar 2 day format and makes it into 3 characters
// if $txt is true, it returns the 3 letters, otherwise it returns the
Index: ical_parser.php
===================================================================
RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ical_parser.php,v
retrieving revision 1.253
retrieving revision 1.254
diff -C2 -d -r1.253 -r1.254
*** ical_parser.php 18 Jun 2009 16:21:45 -0000 1.253
--- ical_parser.php 19 Jun 2009 20:39:47 -0000 1.254
***************
*** 20,24 ****
$z=1;
$y=0;
- $webcal_mtime = time() - ($phpiCal_config->webcal_hours * 3600);
if (sizeof($master_array['-4']) == (sizeof($cal_filelist))) {
foreach ($master_array['-4'] as $temp_array) {
--- 20,23 ----
***************
*** 26,34 ****
$fname = $master_array['-4'][$z]['filename'];
$wcalc = $master_array['-4'][$z]['webcal'];
if ($wcalc == 'no') $realcal_mtime = filemtime($fname);
! if (isset($realcal_mtime) && ($mtime == $realcal_mtime) && ($wcalc == 'no')) {
! $y++;
! } elseif (($wcalc == 'yes') && ($mtime > $webcal_mtime)) {
! //echo date('H:i',$mtime). ' > '. date('H:i',$webcal_mtime);
$y++;
}
--- 25,33 ----
$fname = $master_array['-4'][$z]['filename'];
$wcalc = $master_array['-4'][$z]['webcal'];
+
if ($wcalc == 'no') $realcal_mtime = filemtime($fname);
! else $realcal_mtime = remote_filemtime($fname);
!
! if ($mtime == $realcal_mtime) {
$y++;
}
***************
*** 51,55 ****
} else {
foreach ($cal_filelist as $filename) {
! $realcal_mtime = filemtime($filename);
$parsedcal = $phpiCal_config->tmp_dir.'/parsedcal-'.urlencode($cpath.'::'.$cal_filename).'-'.$this_year;
if (file_exists($parsedcal)) {
--- 50,60 ----
} else {
foreach ($cal_filelist as $filename) {
! if (substr($filename, 0, 7) == 'http://' || substr($filename, 0, 8) == 'https://' || substr($filename, 0, 9) == 'webcal://') {
! $realcal_mtime = remote_filemtime($filename);
! }
! else {
! $realcal_mtime = filemtime($filename);
! }
!
$parsedcal = $phpiCal_config->tmp_dir.'/parsedcal-'.urlencode($cpath.'::'.$cal_filename).'-'.$this_year;
if (file_exists($parsedcal)) {
***************
*** 85,91 ****
// 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(array('http://', 'https://'), 'webcal://', $filename);
$cal_httpPrefix = str_replace(array('webcal://', 'https://'), 'http://', $filename);
--- 90,94 ----
***************
*** 93,97 ****
$filename = $cal_httpPrefix;
$master_array['-4'][$calnumber]['webcal'] = 'yes';
! $actual_mtime = time();
} else {
$actual_mtime = @filemtime($filename);
--- 96,100 ----
$filename = $cal_httpPrefix;
$master_array['-4'][$calnumber]['webcal'] = 'yes';
! $actual_mtime = @remote_filemtime($filename);
} else {
$actual_mtime = @filemtime($filename);
|