diff options
author | Urban Müller | 2023-03-23 16:03:46 +0100 |
---|---|---|
committer | Urban Müller | 2023-03-23 16:03:46 +0100 |
commit | 7f4c4b82275852786f373b13ed54d8d6d635b99f (patch) | |
tree | bed6a7f0d0bae69a5592f31ba29a15616b36281d | |
parent | 9b94f30c83be11060c35bfc2f7be60f8fdd38548 (diff) | |
download | itools-7f4c4b82275852786f373b13ed54d8d6d635b99f.tar.gz itools-7f4c4b82275852786f373b13ed54d8d6d635b99f.tar.bz2 itools-7f4c4b82275852786f373b13ed54d8d6d635b99f.zip |
use json for header storage
-rw-r--r-- | it_url.class | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/it_url.class b/it_url.class index e2cd993..7bcf22d 100644 --- a/it_url.class +++ b/it_url.class @@ -601,7 +601,7 @@ static function get_cache($p = array()) if (!is_writable(dirname($path))) it::error("parent dir not writable: " . trim(it::exec('ls -ld {dir} 2>&1', ['dir' => dirname($path)]))); - if (($filemtime = it_url::_expired($path, $p['maxage'], $p['randomexpire'])) || ($p['returnheaders'] && !file_exists(("$path.headers")))) # Outdated(non-zero int) or non-existant(true)? + if (($filemtime = it_url::_expired($path, $p['maxage'], $p['randomexpire'])) || ($p['returnheaders'] && !file_exists(("$path.json")))) # Outdated(non-zero int) or non-existant(true)? { $fileexists = $filemtime !== true; @@ -618,7 +618,7 @@ static function get_cache($p = array()) $success = true; $isnewfile = it_url::_atomicwrite($path, $p['assoc'] ? serialize($data) : $data); if ($p['returnheaders']) - it::file_put_contents("$path.headers", '<?php return ' . var_export($url->headers, true) . ";\n"); + it::file_put("$path.json", it::json_encode($url->headers)); } else if ($p['keepfailed']) $success = $fileexists; @@ -648,7 +648,7 @@ static function get_cache($p = array()) # Read headers before $path is modified for preprocessing if ($p['returnheaders']) - $headers = @include("$path.headers"); + $headers = it::json_decode(it::file_get("$path.json"), 'assoc' => true); if ($success && $p['preprocess']) { |