diff options
author | Urban Müller | 2011-06-15 12:53:14 +0000 |
---|---|---|
committer | Urban Müller | 2011-06-15 12:53:14 +0000 |
commit | a3fd902e4ecc68a09b5324bba3ed43c9501156ed (patch) | |
tree | dfb43afe88205e9555d1b8809e71768f98729117 /it_url.class | |
parent | 17e4e31dd7f5b943d6d23f4ccde01d3214a52ff9 (diff) | |
download | itools-a3fd902e4ecc68a09b5324bba3ed43c9501156ed.tar.gz itools-a3fd902e4ecc68a09b5324bba3ed43c9501156ed.tar.bz2 itools-a3fd902e4ecc68a09b5324bba3ed43c9501156ed.zip |
get_cache_contents, default directory
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 11 |
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 |