aboutsummaryrefslogtreecommitdiffstats
path: root/functions/date_functions.php
diff options
context:
space:
mode:
authorJason Oster <parasytic@users.sourceforge.net>2009-06-19 20:39:46 +0000
committerJason Oster <parasytic@users.sourceforge.net>2009-06-19 20:39:46 +0000
commitb690f955bb712d2cdafbdb3fddb8469cde6b25ae (patch)
treebf4bb03cf340f64dda6e14e96b41a26da8c3ccd3 /functions/date_functions.php
parent6836bebf950e2f69a310e92df6af730913f10945 (diff)
downloadphpicalendar-b690f955bb712d2cdafbdb3fddb8469cde6b25ae.tar.gz
phpicalendar-b690f955bb712d2cdafbdb3fddb8469cde6b25ae.tar.bz2
phpicalendar-b690f955bb712d2cdafbdb3fddb8469cde6b25ae.zip
Use http "last-modified" time on webcals and remove "webcals_hours" config setting
Diffstat (limited to 'functions/date_functions.php')
-rw-r--r--functions/date_functions.php24
1 files changed, 24 insertions, 0 deletions
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.

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