From c70c2bf2b28e6d41c1c53fc5c57a95a5b4c8c9d6 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Sat, 15 Aug 2026 19:17:36 +0200 Subject: [PATCH] Add admin endpoint for manual cache build progress --- main-cache-status.php | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 main-cache-status.php diff --git a/main-cache-status.php b/main-cache-status.php new file mode 100644 index 0000000..ad391f5 --- /dev/null +++ b/main-cache-status.php @@ -0,0 +1,47 @@ +'unavailable','message'=>'Bratonien Tools ist nicht aktiv.')); + exit; +} +if (!function_exists('is_admin') || !is_admin()) +{ + http_response_code(403); + echo json_encode(array('state'=>'forbidden','message'=>'Administratorrechte erforderlich.')); + exit; +} + +require_once(BRATONIEN_TOOLS_PATH.'tools/image_cache.inc.php'); +$file = bratonien_tools_main_cache_status_file(); +if (!is_file($file) || !is_readable($file)) +{ + echo json_encode(array( + 'state'=>'idle','message'=>'Noch kein manueller Cache-Aufbau gestartet.', + 'total'=>0,'completed'=>0,'generated'=>0,'cached'=>0,'skipped'=>0,'errors'=>0,'current'=>'','updated_at'=>0, + ), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + exit; +} + +$raw = @file_get_contents($file); +$data = $raw !== false ? json_decode($raw, true) : null; +if (!is_array($data)) +{ + http_response_code(500); + echo json_encode(array('state'=>'error','message'=>'Cache-Status ist nicht lesbar.')); + exit; +} + +echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);