Uptime-Status/controller/status.php

35 lines
906 B
PHP
Raw Normal View History

2023-10-31 18:36:02 +01:00
<?php
require_once("../vendor/autoload.php");
2023-10-31 22:15:05 +01:00
require_once("../model/page.php");
2023-10-31 18:52:33 +01:00
require_once(__DIR__ . "/filters.php");
2023-10-31 18:36:02 +01:00
class UptimeStatus {
private $data;
public function load_data() {
2023-10-31 22:15:05 +01:00
$page = json_decode(file_get_contents(UPTIME_KUMA_URL . "/api/status-page/" . UPTIME_KUMA_PAGE), true);
$heartbeat = json_decode(file_get_contents(UPTIME_KUMA_URL . "/api/status-page/heartbeat/" . UPTIME_KUMA_PAGE), true);
$this->data = Page::convert($page, $heartbeat)->export();
}
public function raw() {
return $this->data;
2023-10-31 18:36:02 +01:00
}
public function display() {
$twig_config = [];
if (ENABLE_TWIG_CACHE) $twig_config["cache"] = "../cache/twig/";
2023-10-31 18:36:02 +01:00
$loader = new \Twig\Loader\FilesystemLoader("../view/");
$twig = new \Twig\Environment($loader, $twig_config);
2023-10-31 18:52:33 +01:00
$twig->addFilter(\Filters\timeago());
2023-10-31 22:15:05 +01:00
$twig->addFilter(\Filters\isof());
2023-10-31 18:36:02 +01:00
2023-10-31 22:15:05 +01:00
echo $twig->render('index.twig', $this->data);
2023-10-31 18:36:02 +01:00
}
}