diff options
Diffstat (limited to 'pages/api')
-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 |
6 files changed, 3 insertions, 391 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 |