summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
Diffstat (limited to 'it.class')
-rw-r--r--it.class9
1 files changed, 6 insertions, 3 deletions
diff --git a/it.class b/it.class
index 2953085..52779f3 100644
--- a/it.class
+++ b/it.class
@@ -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;
}
/**