15 lines
420 B
PHP
15 lines
420 B
PHP
<?php
|
|
function az_content(string $rel): array {
|
|
static $cache = [];
|
|
if (!isset($cache[$rel])) {
|
|
$file = $_SERVER['DOCUMENT_ROOT'] . '/content/' . $rel;
|
|
$data = json_decode((string) file_get_contents($file), true);
|
|
if (!is_array($data)) {
|
|
http_response_code(500);
|
|
exit('Content file missing or invalid: ' . htmlspecialchars($rel));
|
|
}
|
|
$cache[$rel] = $data;
|
|
}
|
|
return $cache[$rel];
|
|
}
|