diff options
author | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
commit | 23563c7188e089929b60f9e10721c6fc43a220ff (patch) | |
tree | edfe2b009c82900d4ac27db02222d2f68dcad846 /pages | |
parent | 7a7a49332df7c852abbaa33c7e8e87f93d064d61 (diff) | |
download | pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.gz pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.bz2 pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.zip |
Updated 15 files, added includes/maintenance/deleteUnusedAssets.php and deleted 4944 files (automated)
Diffstat (limited to 'pages')
-rw-r--r-- | pages/api/badger.php | 3 | ||||
-rw-r--r-- | pages/api/browser.php | 4 | ||||
-rw-r--r-- | pages/api/chrome.php | 90 | ||||
-rw-r--r-- | pages/api/desktop.php | 3 | ||||
-rw-r--r-- | pages/api/fronter.php | 177 | ||||
-rw-r--r-- | pages/api/wear/schedule.php | 117 | ||||
-rw-r--r-- | pages/fronting.inc | 20 | ||||
-rw-r--r-- | pages/games.inc | 83 | ||||
-rw-r--r-- | pages/home.inc | 5 | ||||
-rw-r--r-- | pages/home.old.inc | 79 | ||||
-rw-r--r-- | pages/rules.inc | 289 | ||||
-rw-r--r-- | pages/schedules.inc | 79 | ||||
-rw-r--r-- | pages/toys.inc | 697 |
13 files changed, 8 insertions, 1638 deletions
diff --git a/pages/api/badger.php b/pages/api/badger.php index 0682041..ee7bfa7 100644 --- a/pages/api/badger.php +++ b/pages/api/badger.php @@ -2,6 +2,9 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; +global $isLoggedIn; global $isLowerLoggedIn; +$isLoggedIn = false; $isLowerLoggedIn = false; + $list = scoreOrderGlobal(); function getAge($metadata) { diff --git a/pages/api/browser.php b/pages/api/browser.php deleted file mode 100644 index 657b2a7..0000000 --- a/pages/api/browser.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php - -header("Content-Type: application/json"); -die(json_encode(get_browser(), JSON_PRETTY_PRINT));
\ No newline at end of file diff --git a/pages/api/chrome.php b/pages/api/chrome.php deleted file mode 100644 index db32511..0000000 --- a/pages/api/chrome.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; - - -if (isset($_GET["e"])) { - header("Access-Control-Allow-Origin: chrome-extension://foioekefbipjjonpgpbjahmplcealhhg"); -} else { - header("Access-Control-Allow-Origin: *"); -} - -header("Access-Control-Allow-Credentials: true"); -header("Access-Control-Allow-Methods: *"); -header("Access-Control-Allow-Headers: *"); - -if (!isset($_GET["t"])) { - header("Content-Type: application/json"); - - if ($isLoggedIn) { - die("true"); - } else { - die("false"); - } -} else { - switch ($_GET["t"]) { - case "onboarding": - header("Content-Type: text/html"); - - ?> -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link rel="icon" href="https://git.equestria.dev/equestria.dev/luna/raw/branch/mane/icons/logo.png" type="image/png"> - <title>Luna for Chrome OS</title> - <style> - html, body { - background-color: #0d0b16; - color: white; - font-family: sans-serif; - overflow: hidden; - } - - button:hover { - opacity: .75; - } - - button:active { - opacity: .5; - } - </style> -</head> -<body> -<div style="max-width: 65vw; margin-left: auto; margin-right: auto; height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center;"> - <div> - <img src="https://git.equestria.dev/equestria.dev/luna/raw/branch/mane/icons/logo.png" width="128px"> - <h1>Please login to Cold Haze</h1> - <p>To proceed with activating Luna on this Chromebook, you need to login to Cold Haze. You also need to make sure you properly enroled this computer into Chrome Enterprise.</p> - <button onclick='window.open("https://ponies.equestria.horse/-/login/?return=/api/close&mini", "_blank", "popup,top=100,width=100,height:250")' style="cursor: pointer; background: #5958ad; color: white; border: none; padding: 5px 10px; border-radius: 5px;">Login</button> - </div> -</div> - -<script> - setTimeout(async () => { - if (JSON.parse(await (await fetch("https://ponies.equestria.horse/api/chrome")).text())) { - window.close(); - } - }); - - setInterval(async () => { - if (JSON.parse(await (await fetch("https://ponies.equestria.horse/api/chrome")).text())) { - window.close(); - } - }, 5000); -</script> -</body> -</html> -<?php - - die(); - case "unique": - header("Content-Type: text/plain"); - die("Chromebook-" . strtoupper(substr(sha1($_COOKIE['PEH2_SESSION_TOKEN']), 0, 5))); - default: - header("Location: /"); - die(); - } -}
\ No newline at end of file diff --git a/pages/api/desktop.php b/pages/api/desktop.php deleted file mode 100644 index 5d79440..0000000 --- a/pages/api/desktop.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -die();
\ No newline at end of file diff --git a/pages/api/fronter.php b/pages/api/fronter.php deleted file mode 100644 index a908efa..0000000 --- a/pages/api/fronter.php +++ /dev/null @@ -1,177 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; -if (!$isLoggedIn || $isLowerLoggedIn) { - header("Location: /-/login"); - die(); -} - -$system = $_GET['s'] ?? null; -$member = $_GET['m'] ?? null; -$index = (int)$_GET['i'] ?? null; -$type = $_GET['t'] ?? null; -$date = $_GET['d'] ?? null; - -if (!isset($system) || trim($system) === "" || strlen($system) !== 5 || !preg_match("/[a-z]/i", $system) || ($system !== "gdapd" && $system !== "ynmuc")) { - peh_error("System not found", 404); -} - -if (!isset($type) || trim($type) === "") { - peh_error("Type not found", 404); -} - -if (!isset($date) || trim($date) === "" || strlen($date) !== 10 || !preg_match("/[\d-]/i", $date)) { - peh_error("Date not found", 404); -} - -$list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/$system.json"), true); - -function moveElement(&$array, $a, $b) { - $out = array_splice($array, $a, 1); - array_splice($array, $b, 0, $out); -} - -switch ($type) { - case "add": - if (!isset($member) || trim($member) === "" || strlen($member) !== 5 || !preg_match("/[a-z]/i", $member)) { - if ($member !== null && $member !== "null") peh_error("System member not found", 404); - } - - if (!isset($list[$date])) $list[$date] = []; - $list[$date][] = [$member, null]; - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); - createJob("RefreshCache", []); - break; - - case "cofront": - if (!isset($index) || trim($index) === "" || !is_integer($index)) { - if ($index !== null) peh_error("Invalid index", 400); - } - - $day = $list[$date]; - - if (!isset($day[$index])) { - if ($index !== null) peh_error("Index not found", 404); - } - - if (!isset($member) || trim($member) === "" || strlen($member) !== 5 || !preg_match("/[a-z]/i", $member)) { - if ($member !== null && $member !== "null") peh_error("System member not found", 404); - } - - $list[$date][$index][1] = $member; - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); - createJob("RefreshCache", []); - break; - - case "delete": - if (!isset($index) || trim($index) === "" || !is_integer($index)) { - if ($index !== null) peh_error("Invalid index", 400); - } - - $day = $list[$date]; - - if (!isset($day[$index])) { - if ($index !== null) peh_error("Index not found", 404); - } - - unset($day[$index]); - $list[$date] = array_values($day); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); - createJob("RefreshCache", []); - - break; - - case "codelete": - if (!isset($index) || trim($index) === "" || !is_integer($index)) { - if ($index !== null) peh_error("Invalid index", 400); - } - - $day = $list[$date]; - - if (!isset($day[$index])) { - if ($index !== null) peh_error("Index not found", 404); - } - - $list[$date][$index][1] = null; - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); - createJob("RefreshCache", []); - - break; - - case "down": - if (!isset($index) || trim($index) === "" || !is_integer($index)) { - if ($index !== null) peh_error("Invalid index", 400); - } - - $day = $list[$date]; - - if (!isset($day[$index])) { - if ($index !== null) peh_error("Index not found", 404); - } - - moveElement($list[$date], $index, $index + 1 < count($list[$date]) ? $index + 1 : $index); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); - createJob("RefreshCache", []); - - break; - - case "bottom": - if (!isset($index) || trim($index) === "" || !is_integer($index)) { - if ($index !== null) peh_error("Invalid index", 400); - } - - $day = $list[$date]; - - if (!isset($day[$index])) { - if ($index !== null) peh_error("Index not found", 404); - } - - moveElement($list[$date], $index, count($list[$date]) - 1); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); - createJob("RefreshCache", []); - - break; - - case "up": - if (!isset($index) || trim($index) === "" || !is_integer($index)) { - if ($index !== null) peh_error("Invalid index", 400); - } - - $day = $list[$date]; - - if (!isset($day[$index])) { - if ($index !== null) peh_error("Index not found", 404); - } - - moveElement($list[$date], $index, $index - 1 > -1 ? $index - 1 : $index); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); - createJob("RefreshCache", []); - - break; - - case "top": - if (!isset($index) || trim($index) === "" || !is_integer($index)) { - if ($index !== null) peh_error("Invalid index", 400); - } - - $day = $list[$date]; - - if (!isset($day[$index])) { - if ($index !== null) peh_error("Index not found", 404); - } - - moveElement($list[$date], $index, 0); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); - createJob("RefreshCache", []); - - break; - - default: - peh_error("Invalid type name", 400); - break; -} - -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/$system.json", json_encode($list)); - -die();
\ No newline at end of file diff --git a/pages/api/wear/schedule.php b/pages/api/wear/schedule.php deleted file mode 100644 index cf053d8..0000000 --- a/pages/api/wear/schedule.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -if (!$isLoggedIn) header("Location: /-/login") and die(); - -header("Content-Type: application/json"); - -$obj = [ - "today" => [], - "tomorrow" => [] -]; - -$raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/gdapd.json"), true); -$cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/ynmuc.json"), true); - -if (isset($raindrops[date('Y-m-d', time())]) || isset($cloudburst[date('Y-m-d', time())])) { - $rd = $raindrops[date('Y-m-d', time())]; - $cb = $cloudburst[date('Y-m-d', time())]; - $longest = max(count($rd), count($cb)); - - for ($x = 0; $x < $longest; $x++) { - $item = []; - $item["raindrops"] = null; - $item["cloudburst"] = null; - - if (isset($rd[$x])) { - $item["raindrops"] = array_map(function ($i) use ($x, $longest) { - $member = getMemberWithoutSystem($i); - - return [ - "id" => $member["id"], - "name" => $member["display_name"] ?? $member["name"], - "avatar" => "https://ponies.equestria.horse" . getAsset($member["_system"], $member["id"]), - "flags" => [ - "pacifier" => (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true)["pacifier"] ?? false) && ($x === ($longest - 1)), - "plush" => (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true)["sleep_plush"] ?? false) && ($x === ($longest - 1)), - ] - ]; - }, array_filter($rd[$x], function ($i) { return isset($i); })); - } else if (isset($obj["today"][$x - 1]["raindrops"])) { - $item["raindrops"] = $obj["today"][$x - 1]["raindrops"]; - } - - if (isset($cb[$x])) { - $item["cloudburst"] = array_map(function ($i) use ($x, $longest) { - $member = getMemberWithoutSystem($i); - - return [ - "id" => $member["id"], - "name" => $member["display_name"] ?? $member["name"], - "avatar" => "https://ponies.equestria.horse" . getAsset($member["_system"], $member["id"]), - "flags" => [ - "pacifier" => (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true)["pacifier"] ?? false) && ($x === ($longest - 1)), - "plush" => (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true)["sleep_plush"] ?? false) && ($x === ($longest - 1)), - ] - ]; - }, array_filter($cb[$x], function ($i) { return isset($i); })); - } else if (isset($obj["today"][$x - 1]["cloudburst"])) { - $item["cloudburst"] = $obj["today"][$x - 1]["cloudburst"]; - } - - $obj["today"][] = $item; - } -} - -if (isset($raindrops[date('Y-m-d', time() + 86400)]) || isset($cloudburst[date('Y-m-d', time() + 86400)])) { - $rd = $raindrops[date('Y-m-d', time() + 86400)]; - $cb = $cloudburst[date('Y-m-d', time() + 86400)]; - $longest = max(count($rd), count($cb)); - - for ($x = 0; $x < $longest; $x++) { - $item = []; - $item["raindrops"] = null; - $item["cloudburst"] = null; - - if (isset($rd[$x])) { - $item["raindrops"] = array_map(function ($i) use ($x, $longest) { - $member = getMemberWithoutSystem($i); - - return [ - "id" => $member["id"], - "name" => $member["display_name"] ?? $member["name"], - "avatar" => "https://ponies.equestria.horse" . getAsset($member["_system"], $member["id"]), - "flags" => [ - "pacifier" => (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true)["pacifier"] ?? false) && ($x === ($longest - 1)), - "plush" => (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true)["sleep_plush"] ?? false) && ($x === ($longest - 1)), - ] - ]; - }, array_filter($rd[$x], function ($i) { return isset($i); })); - } else if (isset($obj["tomorrow"][$x - 1]["raindrops"])) { - $item["raindrops"] = $obj["tomorrow"][$x - 1]["raindrops"]; - } - - if (isset($cb[$x])) { - $item["cloudburst"] = array_map(function ($i) use ($x, $longest) { - $member = getMemberWithoutSystem($i); - - return [ - "id" => $member["id"], - "name" => $member["display_name"] ?? $member["name"], - "avatar" => "https://ponies.equestria.horse" . getAsset($member["_system"], $member["id"]), - "flags" => [ - "pacifier" => (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true)["pacifier"] ?? false) && ($x === ($longest - 1)), - "plush" => (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true)["sleep_plush"] ?? false) && ($x === ($longest - 1)), - ] - ]; - }, array_filter($cb[$x], function ($i) { return isset($i); })); - } else if (isset($obj["tomorrow"][$x - 1]["cloudburst"])) { - $item["cloudburst"] = $obj["tomorrow"][$x - 1]["cloudburst"]; - } - - $obj["tomorrow"][] = $item; - } -} - -die(json_encode($obj, JSON_PRETTY_PRINT));
\ No newline at end of file diff --git a/pages/fronting.inc b/pages/fronting.inc deleted file mode 100644 index 1c16a80..0000000 --- a/pages/fronting.inc +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -if (time() >= 1686787200) { - header("Location: /evening"); - die(); -} - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -?> - -<br> -<div class="container"> - <div> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/planner.inc"; ?> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/games.inc b/pages/games.inc deleted file mode 100644 index ca881e4..0000000 --- a/pages/games.inc +++ /dev/null @@ -1,83 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $app; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -?> - -<style> - @media (max-width: 1000px) { - .games { - grid-template-columns: repeat(3, 1fr) !important; - grid-gap: 10px !important; - } - } -</style> - -<br> -<div class="container"> - <h1 style="text-align: center; margin-bottom: 20px;">51<sup>st</sup> Equestria Games</h1> - <p> - <b>June 30<sup>th</sup> โ July 6<sup>th</sup><br>Maretime Bay, Equestria</b> - </p> - <p> - <span class="btn btn-outline-light disabled">Apply now</span><br> - <span class="text-muted small" style="margin-top: 5px;">(applications open on April 1<sup>st</sup> until May 1<sup>st</sup>)</span> - </p> - <div> - <span style="vertical-align: middle;">Participating ponies (<?= count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/games.json"))) ?>): </span><?php foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/games.json")) as $player): $player = getMemberWithoutSystem($player); ?><img src="<?= getAsset($player["_system"], $player["id"], "heads") ?>" style="width: 24px;" title="<?= $player["display_name"] ?? $player["name"] ?>" data-bs-toggle="tooltip" class="tooltip-nohelp"><?php endforeach; ?> - </div> - - <hr> - <h2>List of games</h2> - - <div style="display: grid; grid-template-columns: repeat(5, 1fr); grid-gap: 20px;" class="games"> - <div style="border-radius: 10px; padding: 10px; text-align: center; background-color: rgba(255,128,128,0.15); border: 1px solid rgba(255,128,128,0.15);">Volleyball</div> - <div style="border-radius: 10px; padding: 10px; text-align: center; background-color: rgba(255,234,128,0.15); border: 1px solid rgba(255,234,128,0.15);">Paddleboat</div> - <div style="border-radius: 10px; padding: 10px; text-align: center; background-color: rgba(160,255,128,0.15); border: 1px solid rgba(159,255,128,0.15);">Magic</div> - <div style="border-radius: 10px; padding: 10px; text-align: center; background-color: rgba(128,153,255,0.15); border: 1px solid rgba(128,153,255,0.15);">Swimming</div> - <div style="border-radius: 10px; padding: 10px; text-align: center; background-color: rgba(194,128,255,0.15); border: 1px solid rgba(193,128,255,0.15);">Relay</div> - </div> - - <hr> - <h2>Schedule</h2> - <ul> - <li style="margin-bottom: 10px;"><b>June 30<sup>th</sup>, 5pm-7pm UTC</b><br>Initial Check-in<br>Equestria Games Control Center, Headspace, Raindrops System</li> - <li style="margin-bottom: 10px;"><b>June 30<sup>th</sup>, 8pm-10pm UTC</b><br>Final Check-in<br>Police Office, Maretime Bay, Equestria</li> - <li style="margin-bottom: 10px;"><b>July 1<sup>st</sup>, 1pm-2pm UTC</b><br>Opening Ceremony<br>Town Hall, Maretime Bay, Equestria</li> - <li style="margin-bottom: 10px;"><b>July 1<sup>st</sup>, 2pm-5pm UTC</b><br>Volleyball<br>West Coast, Maretime Bay, Equestria</li> - <li style="margin-bottom: 10px;"><b>July 2<sup>nd</sup>, 2pm-5pm UTC</b><br>Paddleboat<br>Ocean, Maretime Bay, Equestria</li> - <li style="margin-bottom: 10px;"><b>July 3<sup>rd</sup>, 2pm-5pm UTC</b><br>Magic<br>Crystal Brighthouse Garden, Maretime Bay, Equestria</li> - <li style="margin-bottom: 10px;"><b>July 4<sup>th</sup>, 2pm-5pm UTC</b><br>Swimming<br>Ocean, Maretime Bay, Equestria</li> - <li style="margin-bottom: 10px;"><b>July 5<sup>th</sup>, 2pm-5pm UTC</b><br>Relay<br>Town Garden, Maretime Bay, Equestria</li> - <li style="margin-bottom: 10px;"><b>July 6<sup>th</sup>, 12pm-2pm UTC</b><br>Winners Celebration<br>Town Hall, Maretime Bay, Equestria</li> - <li style="margin-bottom: 10px;"><b>July 6<sup>th</sup>, 2pm-5pm UTC</b><br>Closing Ceremony<br>Town Hall, Maretime Bay, Equestria</li> - </ul> - - <hr> - <h2>How does it work?</h2> - <ul> - <li>After initial check-in is completed, ponies will stay in Raindrops System. Departure to Equestria will happen at 7:30pm UTC.</li> - <li>After final check-in is completed, ponies are allowed to go back to their respective systems for the night.</li> - <li>Ponies are not required to be present during the opening ceremony. However, they are required to show up 15 minutes before each game starts.</li> - <li>Ponies are allowed to go back to their respective systems for the rest of the day 15 minutes after a game ends.</li> - <li>All participating ponies are required to be present during the winner celebration. They need to be present at least 30 minutes before, and they can go back to their respective systems as soon as the closing ceremony starts.</li> - <li>Ponies are not required to be present during the closing ceremony.</li> - <li>Princess Luna (Raindrops System), Princess Celestia, and Princess Cadance are not allowed to leave their respective systems to participate in the event.</li> - <li>Trains between Equestria and all 3 systems will leave every 15 minutes.</li> - <li>Ponies from Raindrops System or Cloudburst System are required to follow the fronting schedule regardless of the event.</li> - </ul> - - <hr> - <h2>Rules</h2> - <ul> - <li>Use of magic is not allowed during any of the games, except for the magic competition.</li> - <li>Any pony surprised cheating will be permanently excluded from the Equestria Games and any subsequent events.</li> - <li>Ponies who are not from Equestria are allowed to participate in the event as spectators only.</li> - <li>Ponies who are less than 16 years old will need to be accompanied by an adult pony.</li> - <li>Applications cannot be revoked 48 hours before the event starts. A pony who applied is required to go to the event.</li> - <li>Ponies arriving late may not be able to participate in the current game.</li> - </ul> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/home.inc b/pages/home.inc index e9a5426..62474d3 100644 --- a/pages/home.inc +++ b/pages/home.inc @@ -71,6 +71,11 @@ function members() { global $isLoggedIn; global $isLowerLoggedIn; global $app; ? </div> <?php endif; ?> + <div class="alert alert-warning alert-dismissible" id="gpuWarning" style="display: none;"> + <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button> + <b>GPU acceleration is turned off or not supported.</b> A lot of visual effects on this website rely on GPU acceleration, which is currently disabled on your browser, meaning the website's overall look will be affected. Please enable GPU acceleration in your browser settings. + </div> + <?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. diff --git a/pages/home.old.inc b/pages/home.old.inc deleted file mode 100644 index 085af58..0000000 --- a/pages/home.old.inc +++ /dev/null @@ -1,79 +0,0 @@ -<?php - -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; ?> - -<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(); ?> - <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);"> - <?php foreach ($byColor as $member): ?><a data-bs-html="true" class="rainbow-item tooltip-nohelp" title="<b><?= $member["display_name"] ?? $member["name"] ?></b><br><?= ($travelling[$member['id']]["travelling"] ? $member["_system"] === "ynmuc" : $member["_system"] === "gdapd") ? "Raindrops System" : ($member["_system"] === "ynmuc" ? "Cloudburst System" : $app["other"]["name"]) ?>" data-bs-toggle="tooltip" style="overflow: hidden;" href="/<?= $member["name"] ?>"><img src="<?= getAsset($member["_system"], $member["id"], "heads") ?>" style="height:32px;position:absolute;z-index:99;"></a><?php endforeach; ?> - </p> - <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);"> - <?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> - <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> - <?php else: ?> - <p><?= count($byColor) ?> <?= $lang["home"]["intro"] ?></p> - <?php endif; ?> - </div> - </div> - <hr style="border-color:rgba(255, 255, 255, .25);"> - - <div id="homepage-desktop" style="margin-top:10px;"> - - <?php cloudburst(false); ?> - <?php raindrops(false); ?> - <?php if ($isLoggedIn || $isLowerLoggedIn) other(false); ?> - - <hr> - - <div id="hpd-legacy" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px 10px 10px 20px;display:grid;grid-template-columns: 128px 1fr;margin-bottom:10px;"> - <a style="display:flex;margin: -10px -20px;align-items:center;justify-content:center;text-align:center;padding: 10px 20px;border-radius: 10px;background: #77777755;width: 148px;text-decoration:none;color:white;filter:none !important;" class="hpd-system"> - <div style="text-align:center;"><img src="/assets/icons/legacy.svg" style="width:64px;"><br>Pony Legacy</div> - </a> - - <div style="display:grid;grid-template-columns:repeat(6, 1fr);padding-left:10px;grid-gap:10px;"> - <?php foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy"), function ($i) { - return !str_starts_with($i, "."); - }) as $id): - $id = substr($id, 0, -5); - $member = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy/" . $id . ".json"), true); - - echo('<a style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;opacity:5;"><div> -<img alt="" src="' . $member["avatar"] . '" style="border-radius:999px;background-color:rgba(0, 0, 0, .25);height:48px;display:block;margin-left:auto;margin-right:auto;"> -<div style="text-decoration:none;color:white;margin-top:5px;">' . ($member['name'] ?? $id) . '</div> -<div style="text-decoration:none !important;color:white !important;">' . date('j M Y', strtotime($member["date"])) . '</div> -</div></div></a>'); - - endforeach; ?> - </div> - </div> - - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file diff --git a/pages/rules.inc b/pages/rules.inc deleted file mode 100644 index 0c57819..0000000 --- a/pages/rules.inc +++ /dev/null @@ -1,289 +0,0 @@ -<?php - -if (time() >= 1682985600) { - peh_error("Page not found: rules", 404); -} - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/Parsedown.php"; $Parsedown = new Parsedown(); - -if (isset($_POST["updateRules"])) { - header("Content-Type: text/plain"); - - if (!isset($_POST['payload'])) { - header("Location: /-/rules"); - die(); - } - - foreach ($_POST['payload'] as $index => $rule) { - if (!isset($rule["name"]) || !isset($rule["content"]) && !is_numeric($index)) { - header("Location: /-/rules"); - die(); - } - - if (trim($rule["name"]) === "") { - unset($_POST["payload"][$index]); - continue; - } - - if (!isset($rule["approved"])) $rule["approved"] = []; - if (isset($rule["approved"][0])) $rule["approved"][0] = true; else $rule["approved"][0] = false; - if (isset($rule["approved"][1])) $rule["approved"][1] = true; else $rule["approved"][1] = false; - - $_POST["payload"][$index] = $rule; - } - - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/rules.json", json_encode($_POST["payload"])); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json", "{}"); - createJob("RefreshCache", []); - - header("Location: /-/rules"); - die(); -} - -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; -if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json", "{}"); -$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json"), true); - -?> - -<br> -<div class="container"> - <div id="page-content"> - <h2>Rules</h2> - <p><a onclick="event.target.blur();" href="#" data-bs-toggle="modal" data-bs-target="#editor">Edit rules</a></p> - - <div class="alert alert-warning"> - The rules system will be removed on May 2<sup>nd</sup> 2023 at midnight UTC. This page will not be accessible anymore. If there is any data you want to keep, ask Raindrops System for a copy of the rules database. - </div> - - <?php - - $rules = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/rules.json"), true); - - $protectorCloudburst = array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "ynmuc" && $i["_metadata"]["leader"]; - })); - $protectorRaindrops = array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "gdapd" && $i["_metadata"]["leader"]; - })); - - ?> - - <?php foreach (array_values($rules) as $index => $rule): $index++; ?> - <h4 style="margin-top: 20px;"> - <b>Rule <?= $index ?>: <?= str_replace("<", "<", str_replace(">", ">", $rule["name"])) ?></b> - <?php if (in_array(false, $rule["approved"])): ?> - <span class="badge bg-warning text-black rounded-pill">Unapproved</span> - <?php endif; ?> - </h4> - <?php if (in_array(false, $rule["approved"])): ?> - <div style="margin-top:10px;" class="alert alert-warning"> - <b>This rule has not yet been approved.</b> All rules need to be approved by the leaders from both systems. This rule is still missing approval from <?php - - $list = []; - - if ($rule["approved"][0] === false) { - if ($rule["approved"][1] === false) { - array_push($list, ...array_map(function ($i) { - return $i["display_name"] ?? $i["name"]; - }, $protectorCloudburst)); - array_push($list, ...array_map(function ($i) { - return $i["display_name"] ?? $i["name"]; - }, $protectorRaindrops)); - } else { - array_push($list, ...array_map(function ($i) { - return $i["display_name"] ?? $i["name"]; - }, $protectorCloudburst)); - } - } else if ($rule["approved"][1] === false) { - array_push($list, ...array_map(function ($i) { - return $i["display_name"] ?? $i["name"]; - }, $protectorRaindrops)); - } - - foreach ($list as $index => $item) { - echo($item); - if ($index < count($list) - 2) { - echo(", "); - } else if ($index < count($list) - 1) { - echo(" and "); - } - } - - ?>. - </div> - <?php endif; ?> - <div> - <p><?= $Parsedown->text(str_replace("<", "<", str_replace(">", ">", $rule["content"]))) ?></p> - </div> - </li> - <?php $index++; endforeach; ?> - </div> -</div> - -<style> - .modal-dialog { - margin-bottom: 3.5rem; - } -</style> - -<div class="modal fade" id="editor"> - <div class="modal-dialog modal-xl"> - <div class="modal-content"> - <div class="modal-header"> - <h4 class="modal-title">Rules editor</h4> - <button type="button" class="btn-close" data-bs-dismiss="modal"></button> - </div> - - <div class="modal-body"> - <p>Rules with an empty name are automatically deleted. Buttons to add new rules and save the changes are at the bottom of the list.</p> - <hr> - <form method="post"> - <div id="rules-editor"> - <?php $index = 1; foreach ($rules as $rule): ?> - <div <?= $index === 1 ? 'id="default-rule"' : '' ?>> - <p><b <?= $index === 1 ? 'id="default-rule--number"' : '' ?>>Rule #<?= $index ?>:</b></p> - <input <?= $index === 1 ? 'id="default-rule--name"' : '' ?> type="text" placeholder="Rule name" class="form-control" style="margin-bottom:15px;color:white;background:#111;border-color:#222;" name="payload[<?= $index - 1 ?>][name]" value="<?= str_replace('"', """, str_replace("<", "<", str_replace(">", ">", $rule["name"]))) ?>"> - - <textarea <?= $index === 1 ? 'id="default-rule--content"' : '' ?> name="payload[<?= $index - 1 ?>][content]" rows="10" class="form-control" style="resize: none;color:white;background:#111;border-color:#222;" placeholder="Rule details"><?= str_replace("<", "<", str_replace(">", ">", $rule["content"] ?? "")) ?></textarea> - - <label style="margin-top:10px;margin-left:5px;"> - <input <?= $index === 1 ? 'id="default-rule--approval-1"' : '' ?> <?= ($rule["approved"][0] ?? false) ? "checked" : "" ?> type="checkbox" class="form-check-input" name="payload[<?= $index - 1 ?>][approved][0]"> - Approved by <?= implode("/", array_values(array_map(function ($i) { - return $i["display_name"] ?? $i["name"]; - }, $protectorCloudburst))) ?> - </label><br> - <label style="margin-left:5px;"> - <input <?= $index === 1 ? 'id="default-rule--approval-2"' : '' ?> <?= ($rule["approved"][1] ?? false) ? "checked" : "" ?> type="checkbox" class="form-check-input" name="payload[<?= $index - 1 ?>][approved][1]"> - Approved by <?= implode("/", array_values(array_map(function ($i) { - return $i["display_name"] ?? $i["name"]; - }, $protectorRaindrops))) ?> - </label><br> - - <hr> - </div> - <?php $index++; endforeach; ?> - </div> - <input type="submit" value="Save" class="btn btn-primary"> - <a onclick="editorNewRule();" class="btn btn-secondary">New rule</a> - <input type="hidden" name="updateRules"> - </form> - </div> - </div> - </div> -</div> - -<script> - window.numberOfRules = <?= count($rules) ?>; - - Array.from(document.getElementsByClassName("rule-outer")).forEach((el) => { - let details = el.children[0]; - - el.onclick = () => { - Array.from(document.getElementsByClassName("rule-outer")).forEach((sel) => { - if (el === sel) return; - sel.children[0].open = false; - sel.classList.remove("open"); - }); - - details.open = !details.open; - - if (details.open) { - el.classList.add("open"); - } else { - el.classList.remove("open"); - } - } - }) - - function editorNewRule() { - let id = Math.random(36).toString().split(".")[1]; - - document.getElementById("default-rule").id = "added-" + id + "-1"; - document.getElementById("default-rule--number").id = "added-" + id + "-2"; - document.getElementById("default-rule--name").id = "added-" + id + "-3"; - document.getElementById("default-rule--content").id = "added-" + id + "-4"; - document.getElementById("default-rule--approval-1").id = "added-" + id + "-5"; - document.getElementById("default-rule--approval-2").id = "added-" + id + "-6"; - - let child = document.createElement("div"); - child.id = "temp-" + id; - window.numberOfRules++; - - document.getElementById("rules-editor").appendChild(child); - document.getElementById("temp-" + id).outerHTML = document.getElementById("added-" + id + "-1").outerHTML; - - document.getElementById("added-" + id + "-1").id = "default-rule"; - document.getElementById("added-" + id + "-2").id = "default-rule--number"; - document.getElementById("added-" + id + "-3").id = "default-rule--name"; - document.getElementById("added-" + id + "-4").id = "default-rule--content"; - document.getElementById("added-" + id + "-5").id = "default-rule--approval-1"; - document.getElementById("added-" + id + "-6").id = "default-rule--approval-2"; - - document.getElementById("added-" + id + "-3").name = "payload[" + (numberOfRules - 1) + "][name]"; - document.getElementById("added-" + id + "-4").name = "payload[" + (numberOfRules - 1) + "][content]"; - document.getElementById("added-" + id + "-5").name = "payload[" + (numberOfRules - 1) + "][approved][0]"; - document.getElementById("added-" + id + "-6").name = "payload[" + (numberOfRules - 1) + "][approved][1]"; - - document.getElementById("added-" + id + "-5").checked = false; - document.getElementById("added-" + id + "-6").checked = false; - document.getElementById("added-" + id + "-3").value = ""; - document.getElementById("added-" + id + "-4").value = ""; - document.getElementById("added-" + id + "-2").innerText = "Rule #" + numberOfRules + ":"; - } -</script> - -<style> - .list-group-item { - color: #fff; - background-color: #222; - border: 1px solid rgba(255, 255, 255, .125); - } - - .list-group-item.disabled { - color: #fff; - background-color: #222; - border-color: rgba(255, 255, 255, .125); - opacity: .75; - } - - .rule-outer:hover { - background-color: #252525; - color: #ddd; - } - - .rule-outer:active, .rule-outer:focus { - background-color: #272727; - color: #bbb; - } - - .rule-outer.open { - background-color: #333; - } - - .rule { - list-style: none; - pointer-events: none; - } - - .rule-outer { - cursor: pointer; - } - - .modal-header { - border-bottom: 1px solid #353738; - } - - .modal-content { - border: 1px solid rgba(255, 255, 255, .2); - background-color: #111; - } - - .btn-close { - filter: invert(1); - } -</style> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/schedules.inc b/pages/schedules.inc index 04081fe..55f7670 100644 --- a/pages/schedules.inc +++ b/pages/schedules.inc @@ -3,9 +3,6 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $app; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; global $isNormallyLoggedIn; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php'; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/composer/ical/ical.php"; - ?> <style> @@ -49,29 +46,6 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/composer/ical/ical.php"; <h3 id="live-time-other">--:--</h3> </div> - <!--<?php - - $weekDay = (int)date('N'); - - if ($weekDay < 6 && !in_array(date('Y-m-d'), $app["other"]["work"]["off"])) { - $start = ($app["other"]["work"]["start"][0] * 3600) + ($app["other"]["work"]["start"][1] * 60); - $end = ($app["other"]["work"]["end"][0] * 3600) + ($app["other"]["work"]["end"][1] * 60); - $parts = explode("|", (new DateTime("now", new DateTimeZone("America/Chicago")))->format("H|i")); - $now = ((int)$parts[0] * 3600) + ((int)$parts[1] * 60); - - if ($start < $now && $now < $end) { - echo('<div class="alert alert-warning"><p><b><span class="invert">๐๏ธ</span> Currently at work</b></p>Started ' . timeAgo($now - $start, false, true, true) . '<br>Finishing ' . timeIn($end - $now, true) . '</div>'); - } elseif ($now > $end) { - echo('<div class="alert alert-success"><b><span class="invert">๐</span> Finally off work!</b></div>'); - } elseif ($now < $start) { - echo('<div class="alert alert-warning"><p><b><span class="invert">๐๏ธ</span> There\'s work today</b></p>Starting ' . timeIn($start - $now, true) . '<br>Working for ' . timeAgo($end - $start, false, true, true, false) . '</div>'); - } - } else { - echo('<div class="alert alert-success"><b><span class="invert">๐</span> No work today!</b></div>'); - } - - ?>--> - <hr style="display: none;" class="schedules-separator"> </div> @@ -81,33 +55,6 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/composer/ical/ical.php"; <h3 id="live-time-cloudburst">--:--</h3> </div> - <!--<?php - - $calendar = new \om\IcalParser(); - $calendar->parseFile($_SERVER['DOCUMENT_ROOT'] . "/includes/data/calendar.ics"); - - $college = array_values(array_filter((array)$calendar->getEvents()->sorted(), function ($i) { - return strtotime(((array)$i["DTEND"])["date"]) > time() && date('Y-m-d', strtotime(((array)$i["DTEND"])["date"])) === date('Y-m-d') && trim(strtolower($i["SUMMARY"])) === "(cloudburst) college"; - })); - - if (count($college) > 0) { - $start = strtotime(((array)$college[0]["DTSTART"])["date"]); - $end = strtotime(((array)$college[0]["DTEND"])["date"]); - $now = time(); - - if ($start < $now && $now < $end) { - echo('<div class="alert alert-warning"><p><b><span class="invert">๐ซ๏ธ</span> Currently in college</b></p>Started ' . timeAgo($now - $start, false, true, true) . '<br>Finishing ' . timeIn($end - $now, true) . '</div>'); - } elseif ($now > $end) { - echo('<div class="alert alert-success"><b><span class="invert">๐</span> Finally out of college!</b></div>'); - } elseif ($now < $start) { - echo('<div class="alert alert-warning"><p><b><span class="invert">๐ซ๏ธ</span> Getting ready for college</b></p>Starting ' . timeIn($start - $now, true) . '<br>In college for ' . timeAgo($end - $start, false, true, true, false) . '</div>'); - } - } else { - echo('<div class="alert alert-success"><b><span class="invert">๐</span> No college today!</b></div>'); - } - - ?>--> - <hr style="display: none;" class="schedules-separator"> </div> @@ -116,32 +63,6 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/composer/ical/ical.php"; <b>Raindrops System</b><br> <h3 id="live-time-raindrops">--:--</h3> </div> - - <!--<?php - - $school = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/school.json"), true); - - if (isset($school[date('Y-m-d')])) { - $today = $school[date('Y-m-d')]; - - if (count($college) > 0) { - $start = $today["firstClass"]["timestamp"] / 1000; - $end = strtotime($today["end"]); - $now = time(); - - if ($start < $now && $now < $end) { - echo('<div class="alert alert-warning"><p><b><span class="invert">๐๏ธ</span> Currently in school</b></p>Started ' . timeAgo($now - $start, false, true, true) . '<br>Finishing ' . timeIn($end - $now, true) . '</div>'); - } elseif ($now > $end) { - echo('<div class="alert alert-success"><b><span class="invert">๐</span> Finally out of school!</b></div>'); - } elseif ($now < $start) { - echo('<div class="alert alert-warning"><p><b><span class="invert">๐๏ธ</span> Getting ready for school</b></p>Starting ' . timeIn($start - $now, true) . '<br>In school for ' . timeAgo($end - $start, false, true, true, false) . '</div>'); - } - } else { - echo('<div class="alert alert-success"><b><span class="invert">๐</span> No school today!</b></div>'); - } - } - - ?>--> </div> </div> </div> diff --git a/pages/toys.inc b/pages/toys.inc deleted file mode 100644 index df34af0..0000000 --- a/pages/toys.inc +++ /dev/null @@ -1,697 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; - -if (isset($_POST['deleteAction'])) { - $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true); - - $selected = null; - $selectedIndex = -1; - $id = $_POST['action']; - - foreach ($data as $index => $item) { - if ($item["id"] === $id) { - $selectedIndex = $index; - $selected = $item; - break; - } - } - - if ($selected === null) { - header("Location: /-/toys"); - die(); - } - - unset($data[$selectedIndex]); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json", utf8_encode(json_encode($data))); - header("Location: /-/toys/?d&id=" . $id); - die(); -} - -if (isset($_POST['updateAction'])) { - $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true); - - $selected = null; - $selectedIndex = -1; - $id = $_POST['action']; - - foreach ($data as $index => $item) { - if ($item["id"] === $id) { - $selectedIndex = $index; - $selected = $item; - break; - } - } - - if ($selected === null) { - header("Location: /-/toys"); - die(); - } - - if (isset($_POST["sexual"])) { - $selected["sexual"] = true; - } else { - $selected["sexual"] = false; - } - - if (isset($_POST["name"])) $selected["name"] = strip_tags(trim($_POST["name"])); - if (isset($_POST["usage"])) $selected["usage"] = strip_tags(trim($_POST["usage"])); - if (isset($_POST["irl"])) $selected["irl"] = strip_tags(trim($_POST["irl"])); - if (isset($_POST["image"])) $selected["image"] = strip_tags(trim($_POST["image"])); - if (isset($_POST["usage_img"])) $selected["usage_img"] = strip_tags(trim($_POST["usage_img"])); - if (isset($_POST["keywords"])) $selected["keywords"] = array_map(function ($i) { - return trim($i); - }, explode(",", strip_tags(trim($_POST["keywords"])))); - if (isset($_POST["description"])) $selected["description"] = strip_tags(trim($_POST["description"])); - if (isset($_POST["water"])) $selected["water"] = match ($_POST["water"]) { - "0" => "out", - "1" => "in", - "2" => "both", - "3" => "playground" - }; - - if (isset($_POST["relations"])) { - $ponies = []; - - foreach ($_POST["relations"] as $relation => $d) { - $ponies[] = [ - "members" => explode("-", $relation), - "deprecated" => isset($d["deprecated"]), - "sexual" => isset($d["sexual"]) - ]; - } - - $selected["ponies"] = $ponies; - } - - global $_PROFILE; - if ($_PROFILE['login'] === "raindrops" && isset($_POST["verified"])) { - $selected["verified"] = true; - } else { - unset($selected["verified"]); - } - - if (isset($_POST["untested"])) { - $selected["untested"] = true; - } else { - unset($selected["untested"]); - } - - $data[$selectedIndex] = $selected; - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json", utf8_encode(json_encode($data))); - - header("Location: /-/toys/" . $id); - die(); -} - -if (isset($_POST['createAction'])) { - require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/random.inc"; - $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true); - - if (!isset($_POST["name"]) || !isset($_POST["water"])) { - header("Location: /-/toys"); - die(); - } - if (trim($_POST["name"]) === "" || !is_numeric($_POST["water"])) { - header("Location: /-/toys"); - die(); - } - - $water = match ($_POST["water"]) { - "0" => "out", - "1" => "in", - "2" => "both", - "3" => "playground" - }; - $name = strip_tags(trim($_POST["name"])); - $id = random(); - - $ponies = []; - - if (isset($_POST["relations"])) { - foreach ($_POST["relations"] as $relation => $_) { - $ponies[] = [ - "members" => explode("-", $relation), - "deprecated" => false - ]; - } - } - - if (isset($_POST["sexual"])) { - $sexual = true; - } else { - $sexual = false; - } - - $data[] = [ - "id" => $id, - "name" => $name, - "water" => $water, - "description" => null, - "ponies" => $ponies, - "usage" => null, - "irl" => null, - "image" => "", - "usage_img" => "", - "keywords" => [], - "sexual" => $sexual - ]; - - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json", utf8_encode(json_encode($data))); - header("Location: /-/toys/" . $id); - die(); -} - -global $pagename; -$parts = explode("/", $pagename); -$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true); - -$selected = null; - -if (isset($parts[1])) { - $id = $parts[1]; - - foreach ($data as $item) { - if ($item["id"] === $id) { - $selected = $item; - break; - } - } - - if ($selected === null) { - header("Location: /-/toys/?nf&id=" . $id); - die(); - } else { - $title = $selected["name"] . " ยท " . $title; - } -} - -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/util/keywords.inc'; - -if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json", "[]"); - -global $_PROFILE; -global $pagename; -$parts = explode("/", $pagename); - -?> - -<script>requestExplicit("back");</script> - -<style> - @media (max-width: 800px) { - #toy-grid-img { - display: block !important; - } - } - - @media (max-width: 900px) { - #toy-grid-img2 { - display: block !important; - } - } -</style> - - <script src="/assets/editor/fuse.js"></script> - - <br> - <div class="container"> - <div id="<?= isset($parts[1]) ? "page-content" : "" ?>"> - <?php if (isset($_GET['nf'])): ?> - <div class="alert alert-danger alert-dismissible"> - <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/-/toys/");' type="button" class="btn-close" data-bs-dismiss="alert" style="filter: none !important;"></button> - <b>Error: </b> The requested toy (<code><?= strip_tags($_GET['id'] ?? "-") ?></code>) was not found, it may have been deleted or has never existed. - </div> - <?php endif; ?> - - <?php if (isset($_GET['d'])): ?> - <div class="alert alert-success alert-dismissible"> - <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/-/toys");' type="button" class="btn-close" data-bs-dismiss="alert" style="filter: none !important;"></button> - <b>Success: </b> The toy with ID <code><?= strip_tags($_GET['id'] ?? "-") ?></code> has been successfully deleted. - </div> - <?php endif; ?> - - <?php if (isset($parts[1])): ?> - - <h2> - <span style="vertical-align: middle;"><?= $selected["name"] ?></span> - <a href="/-/toys" class="small btn btn-outline-light" style="float:right;margin-top:5px;vertical-align:middle;opacity:1 !important; color:white;">Back</a> - </h2> - - <p> - <a onclick="event.target.blur();" data-bs-toggle="modal" data-bs-target="#editor" href="#">Edit</a> ยท - <?php if (!isset($selected["verified"])): ?><span class="badge bg-warning rounded-pill text-black">Unverified</span><?php endif; ?> - <?php if ($selected["water"] === "in"): ?> - <span style="" class="badge rounded-pill bg-primary">Underwater</span> - <?php elseif ($selected["water"] === "out"): ?> - <span style="background-color:#d63384;" class="badge rounded-pill">Outside of water</span> - <?php else: ?> - <span style="" class="badge rounded-pill bg-primary">Underwater</span> - <span style="background-color:#d63384;" class="badge rounded-pill">Outside of water</span> - <?php endif; ?> - </p> - - <div id="toy-grid-img" style="display: grid; grid-template-columns: 1fr <?php if (isset($selected["usage_img"]) && trim($selected["usage_img"]) !== ""): ?>2fr<?php endif; ?> !important; grid-gap: 20px;"> - <?php if (isset($selected["usage_img"]) && trim($selected["usage_img"]) !== ""): ?> - <div> - <img src="<?= $selected["usage_img"] ?>" style="width: 100%; max-height: 100vh;"> - </div> - <?php endif; ?> - <div> - - <?php if (isset($selected["description"]) && trim($selected["description"]) !== ""): ?> - <?= replaceKeyWords(str_replace("\n", "<br>", strip_tags($selected["description"]))); ?> - <?php else: ?> - <p><i>No description provided for this toy. Enter edit mode to add a description to this toy.</i></p> - <?php endif; ?> - - <hr> - - <div style="margin-top:10px;"></div> - - <div id="toy-grid-img2" style="display: grid; grid-template-columns: <?php if (isset($selected["usage_img"]) && $selected["usage_img"] !== ""): ?>3fr <?php if (isset($selected["image"]) && trim($selected["image"]) !== ""): ?>1fr<?php endif; ?><?php else: ?>6fr <?php if (isset($selected["image"]) && trim($selected["image"]) !== ""): ?>1fr<?php endif; ?><?php endif; ?> !important; grid-gap: 20px;"><div> - <b>Usage:</b><br> - <?php if (isset($selected["usage"]) && trim($selected["usage"]) !== ""): ?> - <?php - - $lines = explode("\n", strip_tags($selected["usage"])); - - if (count($lines) > 1) echo("<ul>"); - - foreach ($lines as $line) { - if (count($lines) > 1) echo("<li>"); - - $parts = explode(":", $line); - - if (count($parts) > 1 && strlen($parts[0]) < 30) { - $p0 = $parts[0]; array_shift($parts); - echo(replaceKeyWords("<b>" . $p0 . ":</b>" . implode(":", $parts))); - } else { - echo(replaceKeyWords(implode(":", $parts))); - } - - if (count($lines) > 1) echo("</li>"); - } - - if (count($lines) > 1) echo("</ul>"); - - ?> - <?php else: ?> - <p><i>No usage provided for this toy. Enter edit mode to add usage information to this toy.</i></p> - <?php endif; ?> - <div style="margin-top:10px;"></div> - - <b>Instructions to obtain in real life:</b><br> - <?php if (isset($selected["irl"]) && trim($selected["irl"]) !== ""): ?> - <?= replaceKeyWords(strip_tags($selected["irl"])) ?> - <?php else: ?> - <p><i><?php if (isset($selected["image"]) && $selected["image"] !== ""): ?>This toy is obtainable in real life, but no instructions are provided.<?php else: ?>This toy is not obtainable in real life.<?php endif; ?></i></p> - <?php endif; ?> - - </div> - <?php if (isset($selected["image"]) && trim($selected["image"]) !== ""): ?> - <div> - <img src="<?= $selected["image"] ?>" style="width: 100%; max-height: 100vh;"> - </div> - <?php endif; ?> - </div> - - - <hr> - - <h4>Similar toys</h4> - <div class="row"> - <?php - - $names = []; - $currentName = $selected["name"]; - $namesByDistance = []; - - foreach ($data as $action) { - if ($action["name"] !== $currentName) $names[$action["name"]] = [ - "id" => $action["id"], - "water" => $action["water"], - "ponies" => $action["ponies"], - "sexual" => $action["sexual"], - "description" => $action["description"] - ]; - } - - foreach ($names as $name => $data) { - $namesByDistance[] = [ - "name" => $name, - "distance" => levenshtein($currentName, $name), - "id" => $data["id"], - "description" => $data["description"], - "water" => $data["water"], - "ponies" => $data["ponies"], - "sexual" => $data["sexual"] - ]; - } - - uasort($namesByDistance, function ($a, $b) use ($selected) { - return $a["distance"] - $b["distance"]; - }); - - foreach ($namesByDistance as $item) { - echo("<!-- " . $currentName . " <-> " . $item["name"] . " => " . $item["distance"] . ") -->"); - } - - $index = 0; - foreach ($namesByDistance as $item): if ($index < 3): - ?> - <div class="col-md-4" style="margin-bottom:20px;"> - <a class="linked-card" href="/-/toys/<?= $item["id"] ?>"><div class="card"> - <div class="card-body"> - <h4 class="card-title"><?= $item["name"] ?></h4> - <p class="card-text"> - <?= strlen(strip_tags($item["description"])) > 100 ? substr(strip_tags($item["description"]), 0, 100) . "โฆ" : strip_tags($item["description"]) ?> - </p> - <?php if ($item["water"] === "in"): ?> - <span style="" class="badge rounded-pill bg-primary">Underwater</span> - <?php elseif ($item["water"] === "out"): ?> - <span style="background-color:#d63384;" class="badge rounded-pill">Outside of water</span> - <?php elseif ($item["water"] === "playground"): ?> - <span class="badge rounded-pill" style="background-color:#20c997;">In playground</span> - <?php else: ?> - <span style="" class="badge rounded-pill bg-primary">Underwater</span> - <span style="background-color:#d63384;" class="badge rounded-pill">Outside of water</span> - <?php endif; ?> - </div> - </div></a> - </div> - <?php $index++; endif; endforeach; ?> - </div> - - <div class="modal fade" id="editor"> - <div class="modal-dialog modal-xl"> - <div class="modal-content"> - <div class="modal-header"> - <h4 class="modal-title">Edit toy</h4> - <button type="button" class="btn-close" data-bs-dismiss="modal"></button> - </div> - - <div class="modal-body"> - <form method="post" style="display:inline;"> - <input type="text" placeholder="Toy name" name="name" class="form-control" style="color:white;background:#111;border-color:#222;margin-bottom:10px;" value="<?= str_replace('"', '"', $selected["name"]) ?>"> - <select name="water" class="form-select" style='color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");'> - <option value="0" <?= $selected["water"] === "out" ? "selected" : "" ?>>Usable outside the water</option> - <option value="1" <?= $selected["water"] === "in" ? "selected" : "" ?>>Usable inside the water</option> - <option value="2" <?= $selected["water"] === "both" ? "selected" : "" ?>>Usable both inside and outside</option> - </select> - - <label style="margin-left:5px; display: none;"> - <input <?= ($selected["sexual"] ?? false) ? "checked" : "" ?> type="checkbox" name="sexual"> - Sexual toy - </label> - - <label style="margin-left:5px; margin-top: 12px;"> - <input class="form-check-input" <?= ($selected["verified"] ?? false) ? "checked" : "" ?> <?= $_PROFILE['login'] !== "raindrops" ? "disabled" : "" ?> type="checkbox" name="verified"> - Mark as verified - </label><br> - - <label style="margin-left:5px; display: none;"> - <input <?= ($selected["untested"] ?? false) ? "checked" : "" ?> type="checkbox" name="untested"> - Mark as untested - </label> - - <hr> - - <textarea rows="5" name="description" class="form-control" style="resize: none;color:white;background:#111;border-color:#222;margin-bottom:10px;" placeholder="Description"><?= strip_tags($selected["description"] ?? "") ?></textarea> - - <textarea rows="5" placeholder="Toy usage" name="usage" class="form-control" style="resize: none;color:white;background:#111;border-color:#222;margin-bottom:10px;"><?= strip_tags($selected["usage"] ?? "") ?></textarea> - - <hr> - - <input type="text" placeholder="Keywords (comma-separated)" name="keywords" class="form-control" style="color:white;background:#111;border-color:#222;margin-bottom:10px;" value="<?= str_replace('"', '"', implode(",", $selected["keywords"] ?? [])) ?>"> - - <input type="text" placeholder="Instructions to obtain IRL" name="irl" class="form-control" style="color:white;background:#111;border-color:#222;margin-bottom:10px;" value="<?= str_replace('"', '"', $selected["irl"] ?? "") ?>"> - - <input type="text" placeholder="URL to IRL image" name="image" class="form-control" style="color:white;background:#111;border-color:#222;margin-bottom:10px;" value="<?= str_replace('"', '"', $selected["image"] ?? "") ?>"> - - <input type="text" placeholder="URL to usage image" name="usage_img" class="form-control" style="color:white;background:#111;border-color:#222;" value="<?= str_replace('"', '"', $selected["usage_img"] ?? "") ?>"> - - <br> - <input type="hidden" name="updateAction"> - <input type="hidden" name="action" value="<?= $selected["id"] ?>"> - <input type="submit" class="btn btn-primary" value="Save"> - </form> - <form method="post" style="display:inline;"> - <input type="hidden" name="deleteAction"> - <input type="hidden" name="action" value="<?= $selected["id"] ?>"> - <input type="submit" class="btn btn-danger" value="Delete"> - </form> - </div> - </div> - </div> - </div> - </div></div> - - <?php else: ?> - - <h2>Toys database</h2> - <?php $complete = count(array_filter($data, function ($i) { - return (isset($i["description"]) && trim($i["description"]) === "") || !isset($i["description"]); - })); ?> - <p><?= count($data) ?> toys<?php if ($complete > 0): ?> (<?= $complete ?> incomplete)<?php endif; ?></p> - - <input type="text" placeholder="Search for a toy..." class="form-control" style="margin-bottom:15px;color:white;background:#111;border-color:#222;" onchange="search();" onkeydown="search();" onkeyup="search();" id="search"> - - <div id="list"> - <div class="list-group"> - <?php - - $init = []; - foreach ($data as $value) { - $init[$value["name"]] = $value; - } - - ksort($init); - - $sorted = array_values($init); - - foreach ($sorted as $item): ?> - <a href="/-/toys/<?= $item["id"] ?>" id="action-<?= $item["id"] ?>" style="display:grid;grid-template-columns: 1fr 0.2fr;" class="list-group-item list-group-item-action action-listing"> - <div> - <span class="<?= trim($item["description"]) === "" ? "text-danger" : "" ?>"><?= $item["name"] ?></span> - <?php if (!isset($item["verified"])): ?><span class="badge bg-warning rounded-pill text-black">Unverified</span><?php endif; ?> - </div> - </a> - <?php endforeach; ?> - </div> - </div> - - <div id="search-results" class="list-group"></div> - - <div id="page-content"> - <hr> - <p>Not finding what you are looking for? <a onclick="event.target.blur(); document.getElementById('creator-title').focus();" href="#" data-bs-toggle="modal" data-bs-target="#creator">Add a toy.</a></p> - </div> - - <script> - window.actions = JSON.parse(atob(`<?= base64_encode(json_encode(array_values(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true)))) ?>`)); - </script> - - <div class="modal fade" id="creator"> - <div class="modal-dialog"> - <div class="modal-content"> - <div class="modal-header"> - <h4 class="modal-title">Add a new toy</h4> - <button type="button" class="btn-close" data-bs-dismiss="modal"></button> - </div> - - <div class="modal-body"> - <form method="post"> - <input id="creator-title" type="text" placeholder="Toy name" name="name" class="form-control" style="color:white;background:#111;border-color:#222;margin-bottom:10px;"> - <select name="water" class="form-select" style='color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");'> - <option value="0" selected>Usable outside of the water</option> - <option value="1">Usable inside of the water</option> - <option value="2">Usable both inside and outside</option> - <option value="3">Usable in a playground</option> - </select> - - <p style="margin-top:10px;">You can add additional data (description, how to use) after adding the toy.</p> - <input type="hidden" name="createAction"> - <input type="submit" class="btn btn-primary" value="Add"> - </form> - </div> - </div> - </div> - </div> - - <?php endif; ?> - </div> - </div> - - <!--suppress JSUnresolvedFunction --> - <script> - Array.from(document.getElementsByClassName("checkbox-input")).forEach((el) => { - el.onchange = () => { - let parent = el.parentElement; - - if (el.checked) { - parent.classList.add("checked"); - } else { - parent.classList.remove("checked"); - } - } - }); - - const fuse = new Fuse(window.actions, { - includeScore: true, - keys: [ - { - name: 'name', - weight: 1 - }, - { - name: 'description', - weight: 1 - }, - { - name: 'example', - weight: 0.7 - }, - { - name: 'irl', - weight: 0.5 - } - ] - }) - - function search() { - let query = document.getElementById("search").value; - let results = fuse.search(query).map((i) => { - return { - id: i.item.id, - score: i.score - }; - }); - - let unfiltered = results; - - results = results.filter((i) => { - return i.score < 0.7; - }); - - console.log("Before:", unfiltered, "After:", results); - - document.getElementById("list").style.display = "none"; - document.getElementById("search-results").style.display = "block"; - document.getElementById("search-results").innerHTML = ""; - - for (let result of results) { - document.getElementById("search-results").innerHTML += document.getElementById("action-" + result.id).outerHTML; - } - - console.log(results); - - if (query.trim() === "") { - document.getElementById("list").style.display = "block"; - document.getElementById("search-results").style.display = "none"; - } - } - - function changeMixed() { - let value = document.getElementById("editor-type").value; - console.log(value); - - if (value === "2") { - Array.from(document.getElementsByClassName("creator-relation")).forEach((el) => { - el.classList.add("mixed"); - }); - } else { - Array.from(document.getElementsByClassName("creator-relation")).forEach((el) => { - el.classList.remove("mixed"); - }); - } - } - </script> - - <style> - .modal-header { - border-bottom: 1px solid #353738; - } - - .modal-content { - border: 1px solid rgba(255, 255, 255, .2); - background-color: #111; - } - - .btn-close { - filter: invert(1); - } - - .creator-relation { - border-radius: 10px; - padding: 5px 10px; - opacity: .5; - } - - .creator-relation.checked { - background-color: rgba(255, 255, 255, .1); - opacity: 1; - } - - .creator-relation:hover { - background-color: rgba(255, 255, 255, .1); - } - - .creator-relation.checked:hover { - background-color: rgba(255, 255, 255, .25) !important; - } - - .creator-relation.checked .deprecated { - display: block !important; - } - - .creator-relation.mixed.checked .sexual { - display: block !important; - } - - .list-group-item { - color: #fff; - background-color: #222; - border: 1px solid rgba(255, 255, 255, .125); - } - - .list-group-item.disabled { - color: #fff; - background-color: #222; - border-color: rgba(255, 255, 255, .125); - opacity: .75; - } - - .list-group-item:hover { - background-color: #252525; - color: #ddd; - } - - .list-group-item:active, .list-group-item:focus { - background-color: #272727; - color: #bbb; - } - - @media (max-width: 991px) { - .action-listing { - grid-template-columns: 1fr !important; - text-align: center !important; - } - - .action-listing > * { - margin-bottom: 10px; - text-align: center !important; - } - - .action-listing > *:nth-last-child(1) { - margin-bottom: 0 !important; - } - - .action-listing img { - width: 32px !important; - } - } - </style> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file |