diff options
Diffstat (limited to 'url.class')
-rw-r--r-- | url.class | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -337,15 +337,15 @@ function get_cache_filename($p) /** * Store contents of url in a file and return file name. Provides locking. Call statically. * Requires www writeable var/urlcache in your service dir. Params in assoc array: - * @url url to get - * @timeout timeout in milliseconds, default 10000 - * @maxage maximum age of cache entries in seconds, default 86400 - * @cleanbefore maximum daytime when attempting cleanup, default 7200 - * @preprocess callback function (or array for methods) to change received file - * @safety value 0 means dont generate alert, value 1 means generate alerts on timeouts and failures - * @keepfailed keep old versions of files if download fails (sending alerts conservatively) - * @cachedir directory to store cache files in. NO TRAILING SLASH - * @it_error parameters for it_error + * @p['url'] url to get + * @p['timeout'] timeout in milliseconds, default 10000 + * @p['maxage'] maximum age of cache entries in seconds, default 86400 + * @p['cleanbefore'] maximum daytime when attempting cleanup, default 7200 + * @p['preprocess'] callback function (or array for methods) to change received file or array('function' => ..., 'in' => $src, 'out' => $dst, ...) with callback function plus args + * @p['safety'] value 0 means dont generate alert, value 1 means generate alerts on timeouts and failures + * @p['keepfailed'] keep old versions of files if download fails (sending alerts conservatively) + * @p['cachedir'] directory to store cache files in. NO TRAILING SLASH + * @p['it_error'] parameters for it_error */ function get_cache($p = array()) { @@ -412,7 +412,11 @@ function get_cache($p = array()) fclose($dummy); EDC('getcache', "process", $p['url'], $path); $dstpath = "$path.preprocesstmp"; - call_user_func($p['preprocess'], $srcpath, $dstpath); + + if (is_array($p['preprocess']) && $p['preprocess']['function']) # Needs is_array as it can be a string where dereferencing gives first character! + call_user_func($p['preprocess']['function'], array('in' => $srcpath, 'out' => $dstpath) + $p['preprocess']); + else + call_user_func($p['preprocess'], $srcpath, $dstpath); if (!@filesize($dstpath) || !@rename($dstpath, $path)) { |