From b690f955bb712d2cdafbdb3fddb8469cde6b25ae Mon Sep 17 00:00:00 2001 From: Jason Oster Date: Fri, 19 Jun 2009 20:39:46 +0000 Subject: Use http "last-modified" time on webcals and remove "webcals_hours" config setting --- functions/date_functions.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'functions/date_functions.php') diff --git a/functions/date_functions.php b/functions/date_functions.php index 9eba84e..4751ad2 100644 --- a/functions/date_functions.php +++ b/functions/date_functions.php @@ -4,6 +4,30 @@ require_once(BASE."functions/is_daylight.php"); // functions for returning or comparing dates +// 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 // integer of that day; 0=Sun, 1=Mon, etc. -- cgit v1.2.3