From a3fd902e4ecc68a09b5324bba3ed43c9501156ed Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 15 Jun 2011 12:53:14 +0000 Subject: get_cache_contents, default directory --- it_url.class | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'it_url.class') 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'], "/"); } @@ -550,6 +550,15 @@ function get_cache($p = array()) return $result ? $path : false; } +/** + * 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 -- cgit v1.2.3