summaryrefslogtreecommitdiff
path: root/it_url.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_url.class')
-rw-r--r--it_url.class11
1 files changed, 10 insertions, 1 deletions
diff --git a/it_url.class b/it_url.class
index 91dae20..ff189c1 100644
--- a/it_url.class
+++ b/it_url.class
@@ -405,7 +405,7 @@ function get_multi($p=null)
*/
function get_cache_dir($p)
{
- $p += array('cachedir' => $GLOBALS['ULTRAHOME'] . "/var/urlcache");
+ $p += array('cachedir' => $GLOBALS['ULTRAHOME'] . "/var/urlcache", 'id' => "default");
return rtrim($p['cachedir'] . "/" . $p['id'], "/");
}
@@ -551,6 +551,15 @@ function get_cache($p = array())
}
/**
+ * Fetch a file, cache it and return contents
+ * @param see it_url::get_cache
+ */
+function get_cache_contents($p)
+{
+ return ($fn = self::get_cache($p)) ? file_get_contents($fn) : it::error(array('title' => "failed getting " . $p['url'], 'body' => var_export($p, true)));
+}
+
+/**
* Check whether file at given path is older than maxage
* @param $path File to check
* @param $maxage Maximum age of file in seconds