diff options
Diffstat (limited to 'pages')
-rw-r--r-- | pages/api/emergency-real.php | 10 | ||||
-rw-r--r-- | pages/api/emergency.php | 10 | ||||
-rw-r--r-- | pages/api/me.php | 2 | ||||
-rw-r--r-- | pages/api/pleasure-real.php | 6 | ||||
-rw-r--r-- | pages/api/pleasure.php | 6 | ||||
-rw-r--r-- | pages/api/plex-thumb.php | 2 | ||||
-rw-r--r-- | pages/api/plex.php | 2 | ||||
-rw-r--r-- | pages/api/pluralkit-integration.php | 8 | ||||
-rw-r--r-- | pages/api/wakeup-real.php | 6 | ||||
-rw-r--r-- | pages/api/wakeup.php | 6 | ||||
-rw-r--r-- | pages/home.inc | 133 | ||||
-rw-r--r-- | pages/jobs.inc | 30 | ||||
-rw-r--r-- | pages/metadata.inc | 2 | ||||
-rw-r--r-- | pages/money.inc | 12 | ||||
-rw-r--r-- | pages/page.inc | 2 | ||||
-rw-r--r-- | pages/travelling.inc | 2 |
16 files changed, 156 insertions, 83 deletions
diff --git a/pages/api/emergency-real.php b/pages/api/emergency-real.php index d0412c8..a67f549 100644 --- a/pages/api/emergency-real.php +++ b/pages/api/emergency-real.php @@ -9,18 +9,18 @@ if (!$isLoggedIn && !$isLowerLoggedIn) { global $_PROFILE; -$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; +$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: ⚠️🆘 EMERGENCY ⚠️🆘\r\n" . + "Title: " . formatPonypush("⚠️🆘 EMERGENCY ⚠️🆘") . "\r\n" . "Priority: urgent\r\n" . "Tags: emergency\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now!" + 'content' => formatPonypush("This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now!") ] ])); @@ -29,11 +29,11 @@ file_get_contents('https://' . $ntfy["server"] . '/emergency', false, stream_con 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: ⚠️🆘 EMERGENCY ⚠️🆘\r\n" . + "Title: " . formatPonypush("⚠️🆘 EMERGENCY ⚠️🆘") . "\r\n" . "Priority: urgent\r\n" . "Tags: emergency\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now!" + 'content' => formatPonypush("This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now!") ] ])); diff --git a/pages/api/emergency.php b/pages/api/emergency.php index 2f764b1..24c975a 100644 --- a/pages/api/emergency.php +++ b/pages/api/emergency.php @@ -9,18 +9,18 @@ if (!$isLoggedIn && !$isLowerLoggedIn) { global $_PROFILE; -$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; +$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: [Test] ⚠️🆘 EMERGENCY ⚠️🆘\r\n" . + "Title: " . formatPonypush("[Test] ⚠️🆘 EMERGENCY ⚠️🆘") . "\r\n" . "Priority: urgent\r\n" . "Tags: emergency\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now! [This notification is test]" + 'content' => formatPonypush("[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now! [This notification is test]") ] ])); @@ -29,11 +29,11 @@ file_get_contents('https://' . $ntfy["server"] . '/emergency', false, stream_con 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: [Test] ⚠️🆘 EMERGENCY ⚠️🆘\r\n" . + "Title: " . formatPonypush("[Test] ⚠️🆘 EMERGENCY ⚠️🆘") . "\r\n" . "Priority: urgent\r\n" . "Tags: emergency\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now! [This notification is test]" + 'content' => formatPonypush("[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now! [This notification is test]") ] ])); diff --git a/pages/api/me.php b/pages/api/me.php index 4f86549..5b13208 100644 --- a/pages/api/me.php +++ b/pages/api/me.php @@ -1,6 +1,6 @@ <?php -$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); +$app = $GLOBALS["ColdHazeApp"]; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; diff --git a/pages/api/pleasure-real.php b/pages/api/pleasure-real.php index 5ac0039..122d994 100644 --- a/pages/api/pleasure-real.php +++ b/pages/api/pleasure-real.php @@ -22,18 +22,18 @@ if ($_PROFILE["login"] === "raindrops" && isset($frontRaindrops[0])) { $pony = "somepony"; } -$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; +$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/pleasure', false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: 🏩 $pony wants to play for a bit\r\n" . + "Title: " . formatPonypush("🏩 $pony wants to play for a bit") . "\r\n" . "Priority: high\r\n" . "Tags: pleasure\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "Hey, $pony wants to play and have fun for a bit, get up!" + 'content' => formatPonypush("Hey, $pony wants to play and have fun for a bit, get up!") ] ])); diff --git a/pages/api/pleasure.php b/pages/api/pleasure.php index 705adfe..14abada 100644 --- a/pages/api/pleasure.php +++ b/pages/api/pleasure.php @@ -22,18 +22,18 @@ if ($_PROFILE["login"] === "raindrops" && isset($frontRaindrops[0])) { $pony = "somepony"; } -$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; +$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/pleasure', false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: [Test] 🏩 $pony wants to play for a bit\r\n" . + "Title: " . formatPonypush("[Test] 🏩 $pony wants to play for a bit") . "\r\n" . "Priority: high\r\n" . "Tags: pleasure\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "[This is a test] Hey, $pony wants to play and have fun for a bit, get up!" + 'content' => formatPonypush("[This is a test] Hey, $pony wants to play and have fun for a bit, get up!") ] ])); diff --git a/pages/api/plex-thumb.php b/pages/api/plex-thumb.php index 4a20159..4009871 100644 --- a/pages/api/plex-thumb.php +++ b/pages/api/plex-thumb.php @@ -1,6 +1,6 @@ <?php -$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); +$app = $GLOBALS["ColdHazeApp"]; if (isset($_GET["library"]) && isset($_GET["id"]) && is_numeric($_GET["library"]) && is_numeric($_GET["id"])) { header("Content-Type: image/jpg"); diff --git a/pages/api/plex.php b/pages/api/plex.php index a2fa739..00164c7 100644 --- a/pages/api/plex.php +++ b/pages/api/plex.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/random.inc"; -$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); +$app = $GLOBALS["ColdHazeApp"]; function formatTitle($metadata) { if ($metadata['grandparentTitle']) { diff --git a/pages/api/pluralkit-integration.php b/pages/api/pluralkit-integration.php index 0efa8cb..69d99b1 100644 --- a/pages/api/pluralkit-integration.php +++ b/pages/api/pluralkit-integration.php @@ -2,14 +2,14 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/agewarning.inc"; -$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); +$app = $GLOBALS["ColdHazeApp"]; $user = $_GET['user'] ?? null; $inputJSON = file_get_contents('php://input'); $input = json_decode($inputJSON, true); -$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["webhook"]; +$data = $GLOBALS["ColdHazeApp"]["webhook"]; -if (isset(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ponytown"][$user])) { - $ponytown = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ponytown"][$user]; +if (isset($GLOBALS["ColdHazeApp"]["ponytown"][$user])) { + $ponytown = $GLOBALS["ColdHazeApp"]["ponytown"][$user]; } else { header("HTTP/1.1 404 Not Found") and die(); } diff --git a/pages/api/wakeup-real.php b/pages/api/wakeup-real.php index fd113ba..f00d5ea 100644 --- a/pages/api/wakeup-real.php +++ b/pages/api/wakeup-real.php @@ -15,18 +15,18 @@ $frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/in $pony = "somepony"; if ($_PROFILE['login'] === "raindrops") $pony = $frontRaindrops[0]["display_name"]; else $pony = $frontCloudburst[0]["display_name"]; -$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; +$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: 🥱 Wake up!\r\n" . + "Title: " . formatPonypush("🥱 Wake up!") . "\r\n" . "Priority: high\r\n" . "Tags: wakeup\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "Hey, $pony wants you to wake up!" + 'content' => formatPonypush("Hey, $pony wants you to wake up!") ] ])); diff --git a/pages/api/wakeup.php b/pages/api/wakeup.php index e4603ef..a5d2b9f 100644 --- a/pages/api/wakeup.php +++ b/pages/api/wakeup.php @@ -15,18 +15,18 @@ $frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/in $pony = "somepony"; if ($_PROFILE['login'] === "raindrops") $pony = $frontRaindrops[0]["display_name"]; else $pony = $frontCloudburst[0]["display_name"]; -$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; +$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: [Test] 🥱 Wake up!\r\n" . + "Title: " . formatPonypush("[Test] 🥱 Wake up!") . "\r\n" . "Priority: high\r\n" . "Tags: wakeup\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "[This notification is test] Hey, $pony wants you to wake up! [This notification is test]" + 'content' => formatPonypush("[This notification is test] Hey, $pony wants you to wake up! [This notification is test]") ] ])); diff --git a/pages/home.inc b/pages/home.inc index 86bf513..cc04e42 100644 --- a/pages/home.inc +++ b/pages/home.inc @@ -4,24 +4,9 @@ if (isset($_GET["ec"])) { header("HTTP/1.1 " . $_GET["ec"] . " Error"); } -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn; ?> +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn; -<br> -<div class="container"> - <?php if (isset($_GET['em'])): ?> - <div class="alert alert-danger alert-dismissible"> - <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button> - <b><?= $lang["home"]["error"] ?> </b><?= strip_tags(base64_decode($_GET['em'])) ?> - </div> - <?php endif; ?> - - <?php if ($readOnly && $isNormallyLoggedIn || $readOnly && $isLowerLoggedIn): ?> - <div class="alert alert-warning"> - <b>Notice: </b>This website is temporarily under maintenance and the administrators have locked the database. Although you are logged in as <?= $_PROFILE['name'] ?>, you cannot access any of the logged-in features while the website is under maintenance. <a href="/-/emergency">Alerts dispatching</a> remains possible in case of an emergency. - </div> - <?php endif; ?> - - <?php global $travelling; $byColor = getMembersByColor(); ?> +function banner() { global $isLoggedIn; global $isLowerLoggedIn; $byColor = getMembersByColor(); global $lang; ?> <div style="text-align: center;"> <img alt="" src="/assets/logo/newlogo<?= $isLoggedIn || $isLowerLoggedIn ? "3" : "" ?>.png" style="width:128px;"> <p style="z-index:999;position:relative;background:transparent;margin: 20px -10px 0 -20px;padding-right:30px;height:32px;text-align: center;display:grid;grid-template-columns: repeat(<?= count($byColor) ?>, 1fr);"> @@ -30,18 +15,20 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE <div style="margin-top:-33px;margin-bottom:0;margin-left:-20px;margin-right:20px;height:32px;text-align: center;display:grid;grid-template-columns: repeat(<?= count($byColor) ?>, 1fr);position:relative;left:10px;"> <?php foreach ($byColor as $member): ?><div> <span style="display: inline-block;background: transparent;position:absolute;width: 0;height: 0;margin-top: 17px;box-shadow: 0 6px 20px 20px #<?= $member["color"] ?>;z-index: 9;margin-left: 8px;opacity: .75;"></span> - </div><?php endforeach; ?> + </div><?php endforeach; ?> </div> <div style="padding:5px 10px;background:#3332328a;border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;position:relative;z-index: 999;backdrop-filter: blur(30px);"> <h2 style="margin-top: 20px;">Cold Haze</h2> <?php if ($isLoggedIn || $isLowerLoggedIn): ?> - <p><?= count($byColor) ?> ponies in 3 plural systems</p> + <p><?= count($byColor) ?> ponies in 3 plural systems</p> <?php else: ?> - <p><?= count($byColor) ?> <?= $lang["home"]["intro"] ?></p> + <p><?= count($byColor) ?> <?= $lang["home"]["intro"] ?></p> <?php endif; ?> </div> </div> +<?php } +function members() { global $isLoggedIn; global $isLowerLoggedIn; global $app; ?> <div id="new-homepage" style="margin-top:20px;"> <div id="new-homepage-systems" <?php if ($isLoggedIn || $isLowerLoggedIn): ?>style="grid-template-columns: repeat(3, 1fr);"<?php endif; ?>> @@ -73,6 +60,110 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE endforeach; ?> </div> </div> +<?php } ?> + +<br> +<div class="container"> + <?php if (isset($_GET['em'])): ?> + <div class="alert alert-danger alert-dismissible"> + <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button> + <b><?= $lang["home"]["error"] ?> </b><?= strip_tags(base64_decode($_GET['em'])) ?> + </div> + <?php endif; ?> + + <?php if ($readOnly && $isNormallyLoggedIn || $readOnly && $isLowerLoggedIn): ?> + <div class="alert alert-warning"> + <b>Notice: </b>This website is temporarily under maintenance and the administrators have locked the database. Although you are logged in as <?= $_PROFILE['name'] ?>, you cannot access any of the logged-in features while the website is under maintenance. <a href="/-/emergency">Alerts dispatching</a> remains possible in case of an emergency. + </div> + <?php endif; ?> + + <?php + + $cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json"), true); + if (!isset($cache["banner"])) $cache["banner"] = []; + if (!isset($cache["members"])) $cache["members"] = []; + + if (!isset($cache["banner"]["public"])) { + ob_start(); + + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = false; + $isLowerLoggedIn = false; + banner(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + + $cache["banner"]["public"] = ob_get_contents(); + ob_end_clean(); + } + + if (!isset($cache["banner"]["private"])) { + ob_start(); + + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = true; + $isLowerLoggedIn = true; + banner(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + + $cache["banner"]["private"] = ob_get_contents(); + ob_end_clean(); + } + + if (!isset($cache["members"]["public"])) { + ob_start(); + + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = false; + $isLowerLoggedIn = false; + members(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + + $cache["members"]["public"] = ob_get_contents(); + ob_end_clean(); + } + + if (!isset($cache["members"]["private"])) { + ob_start(); + + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + $isLoggedIn = true; + $isLowerLoggedIn = true; + members(); + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + + $cache["members"]["private"] = ob_get_contents(); + ob_end_clean(); + } + + if ($isLowerLoggedIn || $isLoggedIn) { + echo($cache["banner"]["private"]); + } else { + echo($cache["banner"]["public"]); + } + + ?> + + <div class="alert alert-warning" style="margin-top:20px;"> + <b>Notice:</b> The administrators are currently trying a new optimisation technique based on a virtual file system (chvfs). Data loss, corruption or inconsistency may happen and should be reported on <a href="https://bugs.equestria.dev/issues/CH" target="_blank">bugs.equestria.dev</a>. + </div> + + <?php + + if ($isLowerLoggedIn || $isLoggedIn) { + echo($cache["members"]["private"]); + } else { + echo($cache["members"]["public"]); + } + + ?> </div> -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file +<?php file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", json_encode($cache)); require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file diff --git a/pages/jobs.inc b/pages/jobs.inc index ae1405d..109b484 100644 --- a/pages/jobs.inc +++ b/pages/jobs.inc @@ -86,31 +86,11 @@ $history = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/ <b>Job lifetime:</b> <ul class="tracking"> - <li><b>Queued by PHP</b><br><?php - $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["queue"])), 0, -3)); - $d[1] = (string)((float)$d[1]); - echo($d[0] . ":" . $d[1]); - ?></li> - <?php if (isset($item["tracking"]["pickup"])): ?><li><b>Picked up by the runner</b><br><?php - $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["pickup"])), 0, -3)); - $d[1] = (string)((float)$d[1]); - echo($d[0] . ":" . $d[1]); - ?></li><?php endif; ?> - <?php if (isset($item["tracking"]["start"])): ?><li><b>Started</b><br><?php - $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["start"])), 0, -3)); - $d[1] = (string)((float)$d[1]); - echo($d[0] . ":" . $d[1]); - ?></li><?php endif; ?> - <?php if (isset($item["tracking"]["end"])): ?><li><b><?= $item["completed"] ? "Finished" : "Failed" ?></b><br><?php - $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["end"])), 0, -3)); - $d[1] = (string)((float)$d[1]); - echo($d[0] . ":" . $d[1]); - ?></li><?php endif; ?> - <?php if (isset($item["tracking"]["logged"])): ?><li><b>Tracking logged</b><br><?php - $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["logged"])), 0, -3)); - $d[1] = (string)((float)$d[1]); - echo($d[0] . ":" . $d[1]); - ?></li><?php endif; ?> + <li><b>Queued by PHP</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["queue"])) ?></li> + <?php if (isset($item["tracking"]["pickup"])): ?><li><b>Picked up by the runner</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["pickup"])) ?></li><?php endif; ?> + <?php if (isset($item["tracking"]["start"])): ?><li><b>Started</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["start"])) ?></li><?php endif; ?> + <?php if (isset($item["tracking"]["end"])): ?><li><b><?= $item["completed"] ? "Finished" : "Failed" ?></b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["end"])) ?></li><?php endif; ?> + <?php if (isset($item["tracking"]["logged"])): ?><li><b>Tracking logged</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["logged"])) ?></li><?php endif; ?> </ul> </div> </div> diff --git a/pages/metadata.inc b/pages/metadata.inc index adde5e7..04579a8 100644 --- a/pages/metadata.inc +++ b/pages/metadata.inc @@ -178,6 +178,8 @@ if ($member === null) { if (trim($metadata["species"][1]) === "") unset($metadata["species"][1]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json", json_encode($metadata)); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json", "{}"); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", "{}"); header("Location: /" . $_GET['_']); } else { diff --git a/pages/money.inc b/pages/money.inc index 15a7a83..387f5c0 100644 --- a/pages/money.inc +++ b/pages/money.inc @@ -64,16 +64,16 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) { if (!isset($_GET["description"])) $_GET["description"] = ""; $_GET["description"] = substr($_GET["description"], 0, 150); - $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; + $ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: " . (getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " created a transaction to " . $account["name"] . " (" . ucfirst($account["owner"]) . ")\r\n" . + "Title: " . formatPonypush((getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " created a transaction to " . $account["name"] . " (" . ucfirst($account["owner"]) . ")") . "\r\n" . "Tags: bits\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($account["currency"] === "gbp" ? "£" : "€") . abs((float)$_GET["amount"]) . " were " . ((float)$_GET["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($_GET["description"]) !== "" ? ": " . $_GET["description"] : "") + 'content' => formatPonypush(($account["currency"] === "gbp" ? "£" : "€") . abs((float)$_GET["amount"]) . " were " . ((float)$_GET["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($_GET["description"]) !== "" ? ": " . $_GET["description"] : "")) ] ])); @@ -90,16 +90,16 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) { file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/money/" . $name . ".json", json_encode($account, JSON_PRETTY_PRINT)); } else { if (isset($_GET["id"]) && is_numeric($_GET["id"]) && isset($account["transactions"][(int)$_GET["id"]])) { - $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; + $ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: " . (getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " deleted a transaction from " . $account["name"] . " (" . ucfirst($account["owner"]) . ")\r\n" . + "Title: " . formatPonypush((getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " deleted a transaction from " . $account["name"] . " (" . ucfirst($account["owner"]) . ")") . "\r\n" . "Tags: bits\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($account["currency"] === "gbp" ? "£" : "€") . abs((float)$account["transactions"][(int)$_GET["id"]]["amount"]) . " " . ((float)$account["transactions"][(int)$_GET["id"]]["amount"] >= 0 ? "advance" : "withdrawal") . " created by " . (getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["display_name"] ?? getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["name"]) . " " . timeAgo($account["transactions"][(int)$_GET["id"]]["date"]) + 'content' => formatPonypush(($account["currency"] === "gbp" ? "£" : "€") . abs((float)$account["transactions"][(int)$_GET["id"]]["amount"]) . " " . ((float)$account["transactions"][(int)$_GET["id"]]["amount"] >= 0 ? "advance" : "withdrawal") . " created by " . (getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["display_name"] ?? getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["name"]) . " " . timeAgo($account["transactions"][(int)$_GET["id"]]["date"])) ] ])); diff --git a/pages/page.inc b/pages/page.inc index 8446062..931e6e5 100644 --- a/pages/page.inc +++ b/pages/page.inc @@ -2,7 +2,7 @@ global $lang; global $pages; global $isLoggedIn; global $isLowerLoggedIn; -$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); +$app = $GLOBALS["ColdHazeApp"]; $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); if (!isset($_GET['_']) || trim($_GET['_']) === "") peh_error("Invalid request", 400); diff --git a/pages/travelling.inc b/pages/travelling.inc index fdcfa99..cfbd4ac 100644 --- a/pages/travelling.inc +++ b/pages/travelling.inc @@ -2,7 +2,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $isLowerLoggedIn; $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); -$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); +$app = $GLOBALS["ColdHazeApp"]; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; |