diff options
Diffstat (limited to 'pages/debug.inc')
-rw-r--r-- | pages/debug.inc | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/pages/debug.inc b/pages/debug.inc index e316a6f..1327af5 100644 --- a/pages/debug.inc +++ b/pages/debug.inc @@ -1,18 +1,20 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; function itemToName(string $item): string { - if ($item === "docs_cleanup") return "Deleting scheduled documents"; - if ($item === "important_backup") return "Differential backups"; - if ($item === "restore") return "Failure protection"; - if ($item === "backups") return "Encrypted off-site backups"; - if ($item === "calendar") return "Google Calendar integration"; - if ($item === "version") return "Version information"; - if ($item === "logo") return "Website logo processing"; - if ($item === "favicons") return "Favicons processing"; - if ($item === "assets") return "External assets download"; + global $lang; global $pages; + + if ($item === "docs_cleanup") return $lang["debug"]["docs_cleanup"]; + if ($item === "important_backup") return $lang["debug"]["important_backup"]; + if ($item === "restore") return $lang["debug"]["restore"]; + if ($item === "backups") return $lang["debug"]["backups"]; + if ($item === "calendar") return $lang["debug"]["calendar"]; + if ($item === "version") return $lang["debug"]["version"]; + if ($item === "logo") return $lang["debug"]["logo"]; + if ($item === "favicons") return $lang["debug"]["favicons"]; + if ($item === "assets") return $lang["debug"]["assets"]; if (str_starts_with($item, "system-")) { $system = explode("-", $item)[2]; @@ -20,11 +22,11 @@ function itemToName(string $item): string { $systemName = $system === "gdapd" ? "Raindrops System" : "Cloudburst System"; return match ($type) { - "general" => "General info about $systemName", - "members" => "Members in the $systemName", - "fronters" => "Current fronter(s) in the $systemName", - "switches" => "Switch history from the $systemName", - default => "$type in $systemName", + "general" => $lang["debug"]["general"] . " $systemName", + "members" => $lang["debug"]["members"] . " $systemName", + "fronters" => $lang["debug"]["fronters"] . " $systemName", + "switches" => $lang["debug"]["switches"] . " $systemName", + default => "$type " . $lang["debug"]["in"] . " $systemName", }; } @@ -35,9 +37,9 @@ function itemToName(string $item): string { $member = getSystemMember($system, $id) ?? [ "name" => $id, "display_name" => $id, "id" => $id ]; if ($member["name"] === "unknown") { - return "Unknown (" . $systemName . ")'s images"; + return str_replace("%1", $lang["debug"]["unknown"] . " (" . $systemName . ")", $lang["debug"]["images"]); } else { - return getMiniName($member["display_name"] ?? $member["name"]) . "'s images"; + return str_replace("%1", getMiniName($member["display_name"] ?? $member["name"]), $lang["debug"]["images"]); } } @@ -51,32 +53,32 @@ function itemToName(string $item): string { <?php $data = json_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/refresh.json"), true); ?> <div id="page-content"> - <h2>Data updater debugging</h2> - <p>This page provides debugging information to troubleshoot unexpectedly long update times or reported failures.</p> + <h2><?= $pages["debug"]["name"][$lang["_name"]] ?></h2> + <p><?= $lang["debug"]["description"] ?></p> <?php if (time() - $data["timestamp"] > 360): ?> <div class="alert alert-warning"> <p> - <b>The data is not updated periodically anymore.</b> + <b><?= $lang["debug"]["warning"]["title"] ?></b> </p> - This can be due to multiple things: + <?= $lang["debug"]["warning"]["intro"] ?> <ul> - <li>the data updater has been disabled temporarily for maintenance;</li> - <li>the data updater cannot start on the server;</li> - <li>the server was down for an extended period of time</li> + <li><?= $lang["debug"]["warning"]["list"][0] ?></li> + <li><?= $lang["debug"]["warning"]["list"][1] ?></li> + <li><?= $lang["debug"]["warning"]["list"][2] ?></li> </ul> - If you are an administrator and think this is not normal, you may investigate the issue. + <?= $lang["debug"]["warning"]["admin"] ?> </div> <?php endif; ?> - <h4>General information</h4> + <h4><?= $lang["debug"]["general_title"] ?></h4> <ul> - <li><b>Update date:</b> <?php $dt = DateTime::createFromFormat('U.u', $data["timestamp"]); echo($dt->format("l j F Y, G:i:s.u T")); ?></li> - <li><b>Total duration:</b> <?= round($data["duration"] * 1000) ?> ms</li> - <li><b>Longest operation:</b> <?= itemToName(array_search(max(array_values($data["times"])), $data["times"])) ?? "-" ?> (<?= round(max(array_values($data["times"])) * 1000) ?> ms, <?= round((max(array_values($data["times"])) / $data["duration"]) * 100, 2) ?>%)</li> + <li><b><?= $lang["debug"]["time"] ?></b> <?php $dt = DateTime::createFromFormat('U.u', $data["timestamp"]); echo($dt->format("l j F Y, G:i:s.u T")); ?></li> + <li><b><?= $lang["debug"]["duration"] ?></b> <?= round($data["duration"] * 1000) ?> ms</li> + <li><b><?= $lang["debug"]["long"] ?></b> <?= itemToName(array_search(max(array_values($data["times"])), $data["times"])) ?? "-" ?> (<?= round(max(array_values($data["times"])) * 1000) ?> ms, <?= round((max(array_values($data["times"])) / $data["duration"]) * 100, 2) ?>%)</li> </ul> - <h4 id="times">Processing times</h4> + <h4 id="times"><?= $lang["debug"]["times"] ?></h4> <div> <?php foreach ($data["times"] as $item => $time): ?><span class="element tooltip-nohelp" title="<b><?= itemToName($item) ?></b><br>(<?= round($time * 1000) ?> ms)" data-bs-toggle="tooltip" data-bs-html="true" style="opacity:.75;display:inline-block;background:#<?= substr(md5($item), 0, 6) ?>;height:8px;margin:4px 0;width:<?= ($time / $data["duration"]) * 100 ?>%"></span><?php endforeach; ?> </div> @@ -86,11 +88,11 @@ function itemToName(string $item): string { <?php endforeach; ?> </ul> - <h4 id="failures">Reported failures</h4> + <h4 id="failures"><?= $lang["debug"]["failures"] ?></h4> <?php if (count($data["restored"]) < 1): ?> - <p><i>The data updater has not reported any update failure in the last run.</i></p> + <p><i><?= $lang["debug"]["no_failure"] ?></i></p> <?php else: ?> - <p>The following files have failed to update:</p> + <p><?= $lang["debug"]["failure"] ?></p> <ul> <?php foreach ($data["restored"] as $item): ?> <li><code><?= $item ?></code></li> |