diff options
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -186,7 +186,7 @@ static function error($p = array(), $extra = null) return null; # prevent recursion if ($_SERVER['REMOTE_ADDR']) - $url = "http://" . it::replace([':443$' => ""], $_SERVER['HTTP_HOST']) . $_SERVER['REQUEST_URI']; # we ignore https for easier debugging + $url = ($_SERVER['HTTPS'] ? "https://" : "http://") . $_SERVER['REQUEST_URI']; else $url = $_SERVER['SCRIPT_NAME'] . " " . implode(" ", array_slice($GLOBALS['argv'], 1)) . " (pwd " . $_SERVER['PWD'] . ")"; @@ -1158,10 +1158,13 @@ static function mail($p) * @param $p['keyval'] each line of the file is one tab-separated key/value pair, return assoc array * @param $p['lines'] return file as array of lines without newline * @param $p['json'] return data json-decoded, set to "assoc" to get objects as assoc arrays + * @param $p['it_cache'] cache with these parameters */ static function file_get($filename, $p = array()) { - if (($data = it::file_get_contents($filename == "-" ? "php://stdin" : $filename)) !== false) + if (isset($p['it_cache']) && ($key = "it_file_get_" . md5(json_encode([$filename, $p]))) && ($result = it_cache::get($key, $p['it_cache'])) !== null) + return $result; + elseif (($data = it::file_get_contents($filename == "-" ? "php://stdin" : $filename)) !== false) { if ($p['keyval']) { @@ -1179,7 +1182,7 @@ static function file_get($filename, $p = array()) $result = $data; } - return $result; + return isset($p['it_cache']) ? it_cache::put($key, $result, $p['it_cache']) : $result; } /** |