'https://libreho.st/directory.json', // either url or path relative to script
'srcType' => 'url', // path or url
];
// ---------------------------------------------------------
if (debug) {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
$hosts = getCache('hosts');
$recache = !is_array($hosts) || !useCache;
if ($recache) {
$directory = getDirFile($directoryFile);
if (!is_array($directory)) {
http_response_code(500);
# guess i'll
die();
# ¯\_(ツ)_/¯
}
if (debug) {
echo "recached: " . __FILE__ . ":". __LINE__ . " \n
";
}
resetCache();
$hosts = [];
$cacheData = [];
foreach ($directory as $librehostJsonUrl) {
$hostInformation = getHostInformation($librehostJsonUrl);
$hosts[] = $hostInformation;
}
$cacheData['hosts'] = $hosts;
writeCache($cacheData);
} elseif (debug) {
echo "Cache is valid";
}
?>