From 5e768d30a0c8ea53423cc4f077c8f37381b8cbb3 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Thu, 18 May 2023 18:05:49 +0200 Subject: Updated 2 files (automated) --- pages/api/computer.php | 9 ++++++- pages/computers.inc | 66 +++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 62 insertions(+), 13 deletions(-) diff --git a/pages/api/computer.php b/pages/api/computer.php index f5117f9..7dce4b6 100644 --- a/pages/api/computer.php +++ b/pages/api/computer.php @@ -52,8 +52,15 @@ switch ($_GET['type']) { case "data": if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata"); + if (isset($json_object["_session"])) unset($json_object["_session"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json", json_encode($json_object)); break; } -die($_PROFILE['login'] . "-" . $host); \ No newline at end of file +if (isset($_GET["json"])) { + die(json_encode([ + "id" => $_PROFILE['login'] . "-" . $host + ])); +} else { + die($_PROFILE['login'] . "-" . $host); +} \ No newline at end of file diff --git a/pages/computers.inc b/pages/computers.inc index 2e493fa..b711c32 100644 --- a/pages/computers.inc +++ b/pages/computers.inc @@ -4,6 +4,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; gl $computer = []; $parts = explode("/", $pagename); +$names = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/names.json"), true); + if (isset($parts[1])) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $parts[1] . ".json")) { $computer = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $parts[1] . ".json"), true); @@ -11,9 +13,9 @@ if (isset($parts[1])) { $owner = explode("-", $id)[0]; if (count($parts) > 2) { - $title = "Remote control · " . $computer["host"] . " · " . $title; + $title = "Remote control · " . ($names[$id] ?? $computer["host"]) . " · " . $title; } else { - $title = $computer["host"] . " · " . $title; + $title = ($names[$id] ?? $computer["host"]) . " · " . $title; } } else { header("Location: /-/computers"); @@ -26,9 +28,6 @@ if (isset($parts[2]) && $parts[2] !== "control") { die(); } -$names = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/names.json"), true); -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - $parts = array_values(array_filter($parts, function ($i) { return $i !== "-"; })); @@ -41,6 +40,12 @@ if (str_ends_with($computer["os"], "unknown")) { $computer["os"] = trim(substr($computer["os"], 0, -7)); } +if (str_ends_with($computer["os"], "rolling")) { + $computer["os"] = trim(substr($computer["os"], 0, -7)); +} + +require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; + ?>