summaryrefslogtreecommitdiff
path: root/pages/api
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2023-11-18 11:34:36 +0100
committerRaindropsSys <raindrops@equestria.dev>2023-11-18 11:34:36 +0100
commit9337aae8b1c87fad34884dacd5cd79d9591c60db (patch)
tree5340f9fa67cd6236e4c879f0057d51d0b1e21361 /pages/api
parent953ddd82e48dd206cef5ac94456549aed13b3ad5 (diff)
downloadpluralconnect-9337aae8b1c87fad34884dacd5cd79d9591c60db.tar.gz
pluralconnect-9337aae8b1c87fad34884dacd5cd79d9591c60db.tar.bz2
pluralconnect-9337aae8b1c87fad34884dacd5cd79d9591c60db.zip
Updated 39 files, added 86 files, deleted 40 files and renamed 2 files (automated)
Diffstat (limited to 'pages/api')
-rw-r--r--pages/api/2023ui.php5
-rw-r--r--pages/api/close.php1
-rw-r--r--pages/api/computer.php68
-rw-r--r--pages/api/computername.php12
-rw-r--r--pages/api/data.php12
-rw-r--r--pages/api/design.php58
-rw-r--r--pages/api/evening.php155
-rw-r--r--pages/api/overage.php47
-rw-r--r--pages/api/pleasure-real.php2
-rw-r--r--pages/api/pleasure.php2
-rw-r--r--pages/api/ponytown.php2
11 files changed, 1 insertions, 363 deletions
diff --git a/pages/api/2023ui.php b/pages/api/2023ui.php
deleted file mode 100644
index 0501b9a..0000000
--- a/pages/api/2023ui.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-setcookie("new2023UI", "yes", time() + 86400*365, "/", "", true, true);
-header("Location: /?ui2023intro");
-die(); \ No newline at end of file
diff --git a/pages/api/close.php b/pages/api/close.php
deleted file mode 100644
index 07d1cff..0000000
--- a/pages/api/close.php
+++ /dev/null
@@ -1 +0,0 @@
-<script>window.close();</script> \ No newline at end of file
diff --git a/pages/api/computer.php b/pages/api/computer.php
deleted file mode 100644
index 2c75183..0000000
--- a/pages/api/computer.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-if (time() >= 1688169600) die();
-
-if (isset($_GET["chrome"])) {
- header("Access-Control-Allow-Origin: chrome-extension://" . preg_replace("/[^a-z]/m", "", $_GET["chrome"]));
- header("Access-Control-Allow-Credentials: true");
-}
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE;
-
-if (!$isLoggedIn || !isset($_PROFILE) || !isset($_PROFILE["login"])) {
- header("Location: /-/login");
- die();
-}
-
-$request_raw = file_get_contents('php://input');
-$json_object = json_decode($request_raw, true);
-
-$host = md5($json_object['host'] ?? $_GET["host"]);
-
-switch ($_GET['type']) {
- case "heartbeat":
- if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json")) {
- $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json"), true);
- $data["date"] = date('c');
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json", json_encode($data));
- }
- break;
-
- case "screenshot":
- $id = $json_object['id'];
- $data = base64_decode($json_object['data']);
-
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens");
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens/" . $_PROFILE['login'] . "-" . $host . "-" . $id . ".jpg", $data);
- break;
-
- case "window":
- $id = sha1($json_object['id']);
- $data = base64_decode($json_object['data']);
-
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows");
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows/" . $_PROFILE['login'] . "-" . $host . "-" . $id . ".jpg", $data);
-
- if (isset($json_object['icon'])) {
- $data2 = base64_decode($json_object['icon']);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows/" . $_PROFILE['login'] . "-" . $host . "-" . $id . ".png", $data2);
- } else {
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/windows/" . $_PROFILE['login'] . "-" . $host . "-" . $id . ".png", "");
- }
-
- break;
-
- case "data":
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata");
- if (isset($json_object["_session"])) unset($json_object["_session"]);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json", json_encode($json_object));
- break;
-}
-
-if (isset($_GET["json"])) {
- die(json_encode([
- "id" => $_PROFILE['login'] . "-" . $host
- ]));
-} else {
- die($_PROFILE['login'] . "-" . $host);
-} \ No newline at end of file
diff --git a/pages/api/computername.php b/pages/api/computername.php
deleted file mode 100644
index 477a8e6..0000000
--- a/pages/api/computername.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-if (time() >= 1688169600) die();
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE;
-if (!$isLoggedIn) header("Location: /-/login") and die();
-
-$names = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/names.json"), true);
-$names[$_GET["id"]] = $_GET["name"];
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/names.json", json_encode($names));
-
-die(); \ No newline at end of file
diff --git a/pages/api/data.php b/pages/api/data.php
deleted file mode 100644
index eb07824..0000000
--- a/pages/api/data.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn;
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/bitset.inc";
-if (!$isLoggedIn) header("Location: /-/login") and die();
-
-if (!isset($_GET['f']) || !file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $_GET['f'])) {
- die();
-} else {
- header("Content-Type: " . mime_content_type($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $_GET['f']));
- die(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $_GET['f']));
-} \ No newline at end of file
diff --git a/pages/api/design.php b/pages/api/design.php
deleted file mode 100644
index 1894a75..0000000
--- a/pages/api/design.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn;
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/random.inc";
-
-if (!$isLoggedIn || !isset($_GET["type"]) || !isset($_GET["member"])) die("Not logged in or missing operand");
-if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $_GET["member"] . ".png")) die("No initial Pony Town character");
-
-$designs = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/designs/" . $_GET["member"] . ".json"), true);
-
-$inputJSON = file_get_contents('php://input');
-$input = json_decode($inputJSON, true);
-
-switch ($_GET["type"]) {
- case "name":
- $designs[$_GET["id"]]["name"] = trim(strip_tags(substr(base64_decode($_GET["value"]), 0, 100)));
-
- if (trim(strip_tags(substr(base64_decode($_GET["value"]), 0, 100))) === "" && $_GET["id"] !== "_main") {
- unset($designs[$_GET["id"]]);
- echo("&");
- }
-
- break;
-
- case "note":
- $designs[$_GET["id"]]["note"] = trim(strip_tags(substr(base64_decode($_GET["value"]), 0, 100)));
- break;
-
- case "upload":
- $id = random();
-
- $file = base64_decode($input["file"]);
- $image = @imagecreatefromstring($file);
-
- imagealphablending($image, false);
- imagesavealpha($image, true);
-
- imagepng($image, "/tmp/temp-" . $id . ".png");
- $text = base64_encode(file_get_contents("/tmp/temp-" . $id . ".png"));
- unlink("/tmp/temp-" . $id . ".png");
-
- $designs[$id] = [
- "name" => "Untitled",
- "note" => "ID: " . $id,
- "image" => $text
- ];
-
- break;
-
- default:
- die("Invalid type");
-}
-
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/designs/" . $_GET["member"] . ".json", json_encode($designs));
-
-while (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/designs/" . $_GET["member"] . ".json")) === "") {
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/designs/" . $_GET["member"] . ".json", json_encode($designs));
-} \ No newline at end of file
diff --git a/pages/api/evening.php b/pages/api/evening.php
deleted file mode 100644
index 4d420ab..0000000
--- a/pages/api/evening.php
+++ /dev/null
@@ -1,155 +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();
-}
-
-$pairs = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/pairs.json"), true);
-$ignored = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/ignored.json"), true);
-$locked = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/locked.json"), true);
-$data = [];
-
-$members = $members = [
- ...array_map(function ($i) {
- $system = "ynmuc";
- $i["_lastFronted"] = -1;
- $id = $i["id"];
- $memberData = $i;
-
- $fronters = array_map(function ($item) {
- return $item["id"];
- }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]);
-
- if (in_array($id, $fronters)) {
- $i["_lastFronted"] = time();
- } else {
- $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true);
-
- $thisMember = array_filter($switches, function ($item) use ($memberData) {
- return in_array($memberData["id"], $item["members"]);
- });
-
- $thisMember = array_values($thisMember);
- $frontingEnd = null;
-
- if (count($thisMember) > 0) {
- $thisIndex = array_search($thisMember[0], $switches);
-
- $frontingStart = $thisMember[0];
- $frontingEnd = $switches[$thisIndex - 1];
- }
-
- if ($frontingEnd !== null && isset($frontingStart)) {
- $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]);
- }
- }
-
- return $i;
- }, array_values(array_filter(scoreOrderGlobal(), function ($i) {
- return $i["_system"] === "ynmuc";
- }))),
- ...array_map(function ($i) {
- $system = "gdapd";
- $i["_lastFronted"] = -1;
- $id = $i["id"];
- $memberData = $i;
-
- $fronters = array_map(function ($item) {
- return $item["id"];
- }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]);
-
- if (in_array($id, $fronters)) {
- $i["_lastFronted"] = time();
- } else {
- $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true);
-
- $thisMember = array_filter($switches, function ($item) use ($memberData) {
- return in_array($memberData["id"], $item["members"]);
- });
-
- $thisMember = array_values($thisMember);
- $frontingEnd = null;
-
- if (count($thisMember) > 0) {
- $thisIndex = array_search($thisMember[0], $switches);
-
- $frontingStart = $thisMember[0];
- $frontingEnd = $switches[$thisIndex - 1];
- }
-
- if ($frontingEnd !== null && isset($frontingStart)) {
- $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]);
- }
- }
-
- return $i;
- }, array_values(array_filter(scoreOrderGlobal(), function ($i) {
- return $i["_system"] === "gdapd";
- })))
-];
-
-usort($pairs, function ($a, $b) use ($members) {
- $times = [];
-
- foreach ($a[0] as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
- foreach ($a[1] as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
-
- $timeA = time() - min($times);
- $times = [];
-
- foreach ($b[0] as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
- foreach ($b[1] as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
-
- $timeB = time() - min($times);
-
- return $timeB - $timeA;
-}); $pairs = array_values($pairs); foreach ($pairs as $pair): $times = [];
- foreach ($pair[0] as $id): $times[] = getLastFronted($members, $id); endforeach;
- foreach ($pair[1] as $id): $times[] = getLastFronted($members, $id); endforeach;
-endforeach;
-
-$listI = 0; for ($i = 0; $i < 7; $i++): $pair = $pairs[$listI];
- $realPair = $pair;
-
- if (isset($locked[date('Y-m-d', time() + 86400 * $i)])) {
- $pair = array_map(function ($i) {
- return explode(",", $i);
- }, explode("|", $locked[date('Y-m-d', time() + 86400 * $i)]));
- }
-
- $data[$i] = [];
- if (!in_array(date('Y-m-d', time() + 86400 * $i), $ignored)) {
- $data[$i][0] = [];
- $data[$i][1] = [];
- foreach ($pair[0] as $id):
- $data[$i][0][] = (getMemberWithoutSystem($id)["display_name"] ?? getMemberWithoutSystem($id)["name"]) . (isset($locked[date('Y-m-d', time() + 86400 * $i)]) ? "*" : "");
- endforeach;
- foreach ($pair[1] as $id):
- $data[$i][1][] = (getMemberWithoutSystem($id)["display_name"] ?? getMemberWithoutSystem($id)["name"]) . (isset($locked[date('Y-m-d', time() + 86400 * $i)]) ? "*" : "");
- endforeach;
- } else {
- $data[$i] = null;
- }
-
- if (
- (!isset($locked[date('Y-m-d', time() + 86400 * $i)]) && !in_array(date('Y-m-d', time() + 86400 * $i), $ignored))
- || (isset($locked[date('Y-m-d', time() + 86400 * $i)]) && $locked[date('Y-m-d', time() + 86400 * $i)] === implode(",", $realPair[0]) . "|" . implode(",", $realPair[1]))
- ) {
- $listI++;
- }
-
- if ($listI === count($pairs)) $listI = 0; endfor;
-
-header("Content-Type: application/json");
-die(json_encode($data, JSON_PRETTY_PRINT)); \ No newline at end of file
diff --git a/pages/api/overage.php b/pages/api/overage.php
deleted file mode 100644
index aef4ac6..0000000
--- a/pages/api/overage.php
+++ /dev/null
@@ -1,47 +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 = [
- "raindrops" => null,
- "cloudburst" => null
-];
-
-foreach (["raindrops", "cloudburst"] as $userName) {
- $allowNsfw = null;
- $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($userName === "raindrops" ? "gdapd" : "ynmuc") . "/fronters.json"), true);
-
- if (count($fronters["members"]) > 0) {
- $id = $fronters["members"][0]["id"];
-
- if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $id . ".json")) {
- $info = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $id . ".json"), true);
-
- if (isset($info["birth"]["age"]) && $info["birth"]["age"] < 15 && $info["birth"]["age"] > 0) {
- $allowNsfw = false;
- } else if (isset($info["birth"]["year"]) && $info["birth"]["year"] > 1900) {
- if (!isset($info["birth"]["date"])) $info["birth"]["date"] = "01-01";
-
- $age = (int)date('Y') - $info["birth"]["year"] + (strtotime(date('Y') . "-" . $info["birth"]["date"]) <= time() ? 0 : -1);
-
- if ($age < 15) {
- $allowNsfw = false;
- } else {
- $allowNsfw = true;
- }
- } else if ((!isset($info["birth"]["age"]) || $info["birth"]["age"] === 0) && (!isset($info["birth"]["year"]) || $info["birth"]["year"] > 1900)) {
- $allowNsfw = false;
- } else {
- $allowNsfw = true;
- }
- }
- }
-
- $obj[$userName] = $allowNsfw;
-}
-
-die(json_encode($obj, JSON_PRETTY_PRINT)); \ No newline at end of file
diff --git a/pages/api/pleasure-real.php b/pages/api/pleasure-real.php
index 122d994..b523c1a 100644
--- a/pages/api/pleasure-real.php
+++ b/pages/api/pleasure-real.php
@@ -9,8 +9,6 @@ if (!$isLoggedIn && !$isLowerLoggedIn) {
global $_PROFILE;
-if ($_PROFILE["login"] === "cloudburst") return;
-
$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true)["members"];
$frontOther = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/fronters.json"), true)["members"];
diff --git a/pages/api/pleasure.php b/pages/api/pleasure.php
index 14abada..58def71 100644
--- a/pages/api/pleasure.php
+++ b/pages/api/pleasure.php
@@ -9,8 +9,6 @@ if (!$isLoggedIn && !$isLowerLoggedIn) {
global $_PROFILE;
-if ($_PROFILE["login"] === "cloudburst") return;
-
$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true)["members"];
$frontOther = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/fronters.json"), true)["members"];
diff --git a/pages/api/ponytown.php b/pages/api/ponytown.php
index 6deec43..bc40975 100644
--- a/pages/api/ponytown.php
+++ b/pages/api/ponytown.php
@@ -20,7 +20,7 @@ if (getMemberWithoutSystem($select) === null) {
$member = getMemberWithoutSystem($select);
-if ($isLowerLoggedIn && $member["_system"] !== $app["other"]["id"]) {
+if ($isLowerLoggedIn && $member["_system"] !== $app["other"]["id"] && $member["_system"] !== "hrbom") {
peh_error("System member not found", 404);
return;
}