summaryrefslogtreecommitdiff
path: root/pages/api
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
committerMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
commit3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch)
tree75be5fba4368472fb11c8015aee026b2b9a71888 /pages/api
parent8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff)
downloadpluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'pages/api')
-rw-r--r--pages/api/cloudburst-img-round.php94
-rw-r--r--pages/api/cloudburst-img.php11
-rw-r--r--pages/api/cloudburst-img2-round.php94
-rw-r--r--pages/api/cloudburst-two.php8
-rw-r--r--pages/api/cloudburst.php6
-rw-r--r--pages/api/computer.php50
-rw-r--r--pages/api/data.php12
-rw-r--r--pages/api/docs.php29
-rw-r--r--pages/api/emergency-real.php22
-rw-r--r--pages/api/emergency.php22
-rw-r--r--pages/api/fronter.php113
-rw-r--r--pages/api/pluralkit-integration.php176
-rw-r--r--pages/api/raindrops-img-round.php94
-rw-r--r--pages/api/raindrops-img.php11
-rw-r--r--pages/api/raindrops-img2-round.php94
-rw-r--r--pages/api/raindrops-two.php8
-rw-r--r--pages/api/raindrops.php6
-rw-r--r--pages/api/save-private.php35
-rw-r--r--pages/api/save.php37
-rw-r--r--pages/api/token.php7
-rw-r--r--pages/api/wakeup-real.php28
-rw-r--r--pages/api/wakeup.php28
22 files changed, 985 insertions, 0 deletions
diff --git a/pages/api/cloudburst-img-round.php b/pages/api/cloudburst-img-round.php
new file mode 100644
index 0000000..6400499
--- /dev/null
+++ b/pages/api/cloudburst-img-round.php
@@ -0,0 +1,94 @@
+<?php
+
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/fronters.json"), true);
+
+$url = isset($fronters['members'][0]) ? ($fronters['members'][0]["avatar_url"] ?? "/assets/uploads/raindrops.png") : "/assets/uploads/raindrops.png";
+file_put_contents("/tmp/temp", file_get_contents($url));
+
+function imageCreateCorners($sourceImageFile, $radius) {
+ # test source image
+ if (file_exists($sourceImageFile)) {
+ $res = is_array($info = getimagesize($sourceImageFile));
+ }
+ else $res = false;
+
+ # open image
+ if ($res) {
+ $w = $info[0];
+ $h = $info[1];
+ switch ($info['mime']) {
+ case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile);
+ break;
+ case 'image/gif': $src = imagecreatefromgif($sourceImageFile);
+ break;
+ case 'image/png': $src = imagecreatefrompng($sourceImageFile);
+ break;
+ default:
+ $res = false;
+ }
+ }
+
+ # create corners
+ if ($res) {
+
+ $q = 10; # change this if you want
+ $radius *= $q;
+
+ # find unique color
+ do {
+ $r = rand(0, 255);
+ $g = rand(0, 255);
+ $b = rand(0, 255);
+ }
+ while (imagecolorexact($src, $r, $g, $b) < 0);
+
+ $nw = $w*$q;
+ $nh = $h*$q;
+
+ $img = imagecreatetruecolor($nw, $nh);
+ $alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127);
+ imagealphablending($img, false);
+ imagesavealpha($img, true);
+ imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor);
+
+ imagefill($img, 0, 0, $alphacolor);
+ imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h);
+
+ imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor);
+ imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor);
+ imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor);
+ imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor);
+ imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor);
+ imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor);
+ imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor);
+ imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor);
+ imagealphablending($img, true);
+ imagecolortransparent($img, $alphacolor);
+
+ # resize image down
+ $dest = imagecreatetruecolor($w, $h);
+ imagealphablending($dest, false);
+ imagesavealpha($dest, true);
+ imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor);
+ imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh);
+
+ # output image
+ $res = $dest;
+ imagedestroy($src);
+ imagedestroy($img);
+ }
+
+ return $res;
+}
+
+header("Content-Type: image/png");
+
+$id = bin2hex(random_bytes(8));
+exec('convert -size 128x128 xc:none -draw "roundrectangle 0,0,128,128,128,128" /tmp/' . $id . '-mask.png', $out);
+
+exec('convert -resize 128x128 "/tmp/temp" /tmp/' . $id . '-source.png');
+exec('convert /tmp/' . $id . '-source.png -matte /tmp/' . $id . '-mask.png -compose DstIn -composite /tmp/' . $id . '.png', $out2);
+
+unlink("/tmp/temp");
+
+echo(file_get_contents('/tmp/' . $id . '.png')); \ No newline at end of file
diff --git a/pages/api/cloudburst-img.php b/pages/api/cloudburst-img.php
new file mode 100644
index 0000000..1967a90
--- /dev/null
+++ b/pages/api/cloudburst-img.php
@@ -0,0 +1,11 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc";
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/fronters.json"), true);
+
+$url = isset($fronters['members'][0]) ? ($fronters['members'][0]["avatar_url"] ? $_SERVER['DOCUMENT_ROOT'] . getAsset("ynmuc", $fronters['members'][0]["id"]) : $_SERVER['DOCUMENT_ROOT'] . "/uploads/raindrops.png") : $_SERVER['DOCUMENT_ROOT'] . "/uploads/raindrops.png";
+file_put_contents("/tmp/temp", file_get_contents($url));
+header("Content-Type: " . mime_content_type("/tmp/temp"));
+unlink("/tmp/temp");
+
+echo(file_get_contents($url)); \ No newline at end of file
diff --git a/pages/api/cloudburst-img2-round.php b/pages/api/cloudburst-img2-round.php
new file mode 100644
index 0000000..4ca772f
--- /dev/null
+++ b/pages/api/cloudburst-img2-round.php
@@ -0,0 +1,94 @@
+<?php
+
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/fronters.json"), true);
+
+$url = isset($fronters['members'][1]) ? ($fronters['members'][1]["avatar_url"] ?? "/assets/uploads/raindrops.png") : "/assets/uploads/raindrops.png";
+file_put_contents("/tmp/temp", file_get_contents($url));
+
+function imageCreateCorners($sourceImageFile, $radius) {
+ # test source image
+ if (file_exists($sourceImageFile)) {
+ $res = is_array($info = getimagesize($sourceImageFile));
+ }
+ else $res = false;
+
+ # open image
+ if ($res) {
+ $w = $info[0];
+ $h = $info[1];
+ switch ($info['mime']) {
+ case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile);
+ break;
+ case 'image/gif': $src = imagecreatefromgif($sourceImageFile);
+ break;
+ case 'image/png': $src = imagecreatefrompng($sourceImageFile);
+ break;
+ default:
+ $res = false;
+ }
+ }
+
+ # create corners
+ if ($res) {
+
+ $q = 10; # change this if you want
+ $radius *= $q;
+
+ # find unique color
+ do {
+ $r = rand(0, 255);
+ $g = rand(0, 255);
+ $b = rand(0, 255);
+ }
+ while (imagecolorexact($src, $r, $g, $b) < 0);
+
+ $nw = $w*$q;
+ $nh = $h*$q;
+
+ $img = imagecreatetruecolor($nw, $nh);
+ $alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127);
+ imagealphablending($img, false);
+ imagesavealpha($img, true);
+ imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor);
+
+ imagefill($img, 0, 0, $alphacolor);
+ imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h);
+
+ imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor);
+ imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor);
+ imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor);
+ imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor);
+ imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor);
+ imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor);
+ imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor);
+ imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor);
+ imagealphablending($img, true);
+ imagecolortransparent($img, $alphacolor);
+
+ # resize image down
+ $dest = imagecreatetruecolor($w, $h);
+ imagealphablending($dest, false);
+ imagesavealpha($dest, true);
+ imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor);
+ imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh);
+
+ # output image
+ $res = $dest;
+ imagedestroy($src);
+ imagedestroy($img);
+ }
+
+ return $res;
+}
+
+header("Content-Type: image/png");
+
+$id = bin2hex(random_bytes(8));
+exec('convert -size 128x128 xc:none -draw "roundrectangle 0,0,128,128,128,128" /tmp/' . $id . '-mask.png', $out);
+
+exec('convert -resize 128x128 "/tmp/temp" /tmp/' . $id . '-source.png');
+exec('convert /tmp/' . $id . '-source.png -matte /tmp/' . $id . '-mask.png -compose DstIn -composite /tmp/' . $id . '.png', $out2);
+
+unlink("/tmp/temp");
+
+echo(file_get_contents('/tmp/' . $id . '.png')); \ No newline at end of file
diff --git a/pages/api/cloudburst-two.php b/pages/api/cloudburst-two.php
new file mode 100644
index 0000000..8272d81
--- /dev/null
+++ b/pages/api/cloudburst-two.php
@@ -0,0 +1,8 @@
+<?php
+
+header("Content-Type: text/plain");
+
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/fronters.json"), true);
+echo(json_encode([
+ "multiple" => count($fronters["members"]) > 1
+])); \ No newline at end of file
diff --git a/pages/api/cloudburst.php b/pages/api/cloudburst.php
new file mode 100644
index 0000000..2750a98
--- /dev/null
+++ b/pages/api/cloudburst.php
@@ -0,0 +1,6 @@
+<?php
+
+header("Content-Type: text/plain");
+
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/fronters.json"), true);
+echo($fronters['members'][0]['display_name'] ?? $fronters['members'][0]['name']); \ No newline at end of file
diff --git a/pages/api/computer.php b/pages/api/computer.php
new file mode 100644
index 0000000..cd065e7
--- /dev/null
+++ b/pages/api/computer.php
@@ -0,0 +1,50 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; global $_PROFILE;
+if (!$isLoggedIn) header("Location: /-/login") and die();
+
+$request_raw = file_get_contents('php://input');
+$json_object = json_decode($request_raw, true);
+
+$host = md5($json_object['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");
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $_PROFILE['login'] . "-" . $host . ".json", json_encode($json_object));
+ break;
+}
+
+die("OK"); \ No newline at end of file
diff --git a/pages/api/data.php b/pages/api/data.php
new file mode 100644
index 0000000..0a1b01b
--- /dev/null
+++ b/pages/api/data.php
@@ -0,0 +1,12 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/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/docs.php b/pages/api/docs.php
new file mode 100644
index 0000000..89e9216
--- /dev/null
+++ b/pages/api/docs.php
@@ -0,0 +1,29 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; global $_PROFILE;
+if (!$isLoggedIn) header("Location: /-/login") and die();
+
+$request_raw = file_get_contents('php://input');
+$json_object = json_decode($request_raw, true);
+
+$select = $_GET['id'] ?? null;
+
+if (isset($select)) {
+ if (ctype_alnum($select) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json")) {
+ $id = $select;
+ $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json"), true);
+ } else {
+ die("Not found");
+ }
+} else {
+ die("Not set");
+}
+
+if ($json_object["content"]) $data["contents"] = $json_object["content"];
+if ($json_object["name"]) $data["name"] = $json_object["name"];
+if ($json_object["category"]) $data["category"] = trim($json_object["category"]) !== "" && trim($json_object["category"]) !== "Unsorted" && trim($json_object["category"]) !== "unsorted" && trim($json_object["category"]) !== "/no" && trim($json_object["category"]) !== "Unsort" && trim($json_object["category"]) !== "unsort" ? $json_object["category"] : null;
+
+$data["last"]["date"] = time();
+$data["last"]["author"] = $_PROFILE['login'];
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json", utf8_encode(json_encode($data))); \ No newline at end of file
diff --git a/pages/api/emergency-real.php b/pages/api/emergency-real.php
new file mode 100644
index 0000000..2dd7172
--- /dev/null
+++ b/pages/api/emergency-real.php
@@ -0,0 +1,22 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn;
+if (!$isLoggedIn) header("Location: /-/login") and die();
+global $_PROFILE;
+
+$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
+
+file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: ⚠️🆘 EMERGENCY ⚠️🆘\r\n" .
+ "Priority: urgent\r\n" .
+ "Tags: emergency\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => "This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now!"
+ ]
+]));
+
+die(); \ No newline at end of file
diff --git a/pages/api/emergency.php b/pages/api/emergency.php
new file mode 100644
index 0000000..e0726e7
--- /dev/null
+++ b/pages/api/emergency.php
@@ -0,0 +1,22 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn;
+if (!$isLoggedIn) header("Location: /-/login") and die();
+global $_PROFILE;
+
+$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
+
+file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: [Test] ⚠️🆘 EMERGENCY ⚠️🆘\r\n" .
+ "Priority: urgent\r\n" .
+ "Tags: emergency\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => "[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now! [This notification is test]"
+ ]
+]));
+
+die(); \ No newline at end of file
diff --git a/pages/api/fronter.php b/pages/api/fronter.php
new file mode 100644
index 0000000..51ee4ee
--- /dev/null
+++ b/pages/api/fronter.php
@@ -0,0 +1,113 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/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];
+ break;
+
+ case "cofront":
+ if (!isset($index) || trim($index) === "" || is_integer($index))
+ if ($index !== null && $index !== "null") peh_error("Invalid index", 400);
+
+ $day = $list[$date];
+
+ if (!isset($day[$index]))
+ if ($index !== null && $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;
+ break;
+
+ case "delete":
+ if (!isset($index) || trim($index) === "" || is_integer($index))
+ if ($index !== null && $index !== "null") peh_error("Invalid index", 400);
+
+ $day = $list[$date];
+
+ if (!isset($day[$index]))
+ if ($index !== null && $index !== "null") peh_error("Index not found", 404);
+
+ unset($day[$index]);
+ $list[$date] = array_values($day);
+
+ break;
+
+ case "codelete":
+ if (!isset($index) || trim($index) === "" || is_integer($index))
+ if ($index !== null && $index !== "null") peh_error("Invalid index", 400);
+
+ $day = $list[$date];
+
+ if (!isset($day[$index]))
+ if ($index !== null && $index !== "null") peh_error("Index not found", 404);
+
+ $list[$date][$index][1] = null;
+
+ break;
+
+ case "down":
+ if (!isset($index) || trim($index) === "" || is_integer($index))
+ if ($index !== null && $index !== "null") peh_error("Invalid index", 400);
+
+ if (!isset($day[$index]))
+ if ($index !== null && $index !== "null") peh_error("Index not found", 404);
+
+ $day = $list[$date];
+ moveElement($list[$date], $index, $index + 1 < count($list[$date]) ? $index + 1 : $index);
+
+ break;
+
+ case "up":
+ if (!isset($index) || trim($index) === "" || is_integer($index))
+ if ($index !== null && $index !== "null") peh_error("Invalid index", 400);
+
+ if (!isset($day[$index]))
+ if ($index !== null && $index !== "null") peh_error("Index not found", 404);
+
+ $day = $list[$date];
+ moveElement($list[$date], $index, $index - 1 > -1 ? $index - 1 : $index);
+
+ 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/pluralkit-integration.php b/pages/api/pluralkit-integration.php
new file mode 100644
index 0000000..0793873
--- /dev/null
+++ b/pages/api/pluralkit-integration.php
@@ -0,0 +1,176 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/agewarning.inc";
+
+$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+$user = $_GET['user'] ?? null;
+$inputJSON = file_get_contents('php://input');
+$input = json_decode($inputJSON, true);
+$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["webhook"];
+
+if (isset(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ponytown"][$user])) {
+ $ponytown = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ponytown"][$user];
+} else {
+ header("HTTP/1.1 404 Not Found") and die();
+}
+
+if ($user === null) {
+ header("HTTP/1.1 500 Internal Server Error") and die();
+}
+
+if (!in_array($user, array_keys($data))) {
+ header("HTTP/1.1 404 Not Found") and die();
+}
+
+if ($input["signing_token"] !== $data[$user]) {
+ header("HTTP/1.1 401 Unauthorized") and die();
+}
+
+if ($input['system_id'] === "7d9f543e-f742-40f6-9d07-86c3f2983124") {
+ $system = "gdapd";
+ $name = "Raindrops System";
+} elseif ($input['system_id'] === "ade46823-206b-4b0c-ad3c-caae934a5f3b") {
+ $system = "ynmuc";
+ $name = "Cloudburst System";
+} elseif (isset($app["other"]) && $input["system_id"] === $app["other"]["uuid"]) {
+ $system = $app["other"]["id"];
+ $name = $app["other"]["name"];
+} else {
+ die();
+}
+
+$lastFronter = json_decode(@file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/last.json"), true) ?? "";
+
+if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || $input["type"] === "DELETE_SWITCH") {
+ if ($system === $app["other"]["id"]) {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/fronters"), false, stream_context_create([
+ 'http' => [
+ 'method' => 'GET',
+ 'header' =>
+ "Authorization: " . $app["other"]["token"] . "\r\n"
+ ]
+ ]));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/switches"), false, stream_context_create([
+ 'http' => [
+ 'method' => 'GET',
+ 'header' =>
+ "Authorization: " . $app["other"]["token"] . "\r\n"
+ ]
+ ]));
+ } else {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/fronters"));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/switches"));
+ }
+
+ $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true);
+ $currentFronter = $fronters["members"][0]["id"];
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/last.json", json_encode($currentFronter));
+
+ $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
+
+ if (count($fronters["members"]) > 0 && ($system !== $app["other"]["id"] || !isset($app["other"]))) {
+ foreach ($fronters["members"] as $member) {
+ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json")) {
+ $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true);
+
+ if (!isset($metadata["birth"])) {
+ showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
+ } else if (isset($metadata['birth']["age"]) && $metadata["birth"]["age"] === 0 && (!isset($metadata['birth']["year"]) || $metadata["birth"]["year"] < 1900)) {
+ showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
+ } else if (isset($metadata['birth']["year"]) && $metadata["birth"]["year"] < 1900) {
+ showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
+ } else if (!isset($metadata['birth']["year"]) && !isset($metadata['birth']["age"])) {
+ showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
+ }
+ }
+ }
+ }
+
+ if ($system !== $app["other"]["id"] || !isset($app["other"])) {
+ if (count($fronters["members"]) > 1) {
+ $context = stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🐴 Switch occurred in the $name\r\n" .
+ "Priority: default\r\n" .
+ "Tags: switch\r\n" .
+ "Actions: view, Open " . $fronters["members"][0]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true;view, Open " . $fronters["members"][1]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][1]["name"] . "/, clear=true\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " and " . ($fronters["members"][1]["display_name"] ?? $fronters["members"][1]["name"]) . " switched in just now"
+ ]
+ ]);
+ } else if (count($fronters["members"]) > 0) {
+ $context = stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🐴 Switch occurred in the $name\r\n" .
+ "Priority: default\r\n" .
+ "Tags: switch\r\n" .
+ "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now"
+ ]
+ ]);
+ } else {
+ $context = stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🐴 Switch occurred in the $name\r\n" .
+ "Priority: default\r\n" .
+ "Tags: switch\r\n" .
+ "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/, clear=true\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => "The fallback pony switched in just now"
+ ]
+ ]);
+ }
+
+ file_get_contents('https://' . $ntfy["server"] . '/public-switches', false, $context);
+ }
+
+ if ($system === "gdapd") {
+ $topic = "public-switches-raindrops";
+
+ if (count($fronters["members"]) > 0) {
+ file_get_contents('https://' . $ntfy["server"] . '/public-switches-fr', false, stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🐴 $name vient de switch\r\n" .
+ "Priority: default\r\n" .
+ "Tags: switch\r\n" .
+ "Actions: view, Voir sur Cold Haze, https://fr.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " est désormais au front"
+ ]
+ ]));
+ } else {
+ file_get_contents('https://' . $ntfy["server"] . '/public-switches-fr', false, stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🐴 $name vient de switch\r\n" .
+ "Priority: default\r\n" .
+ "Tags: switch\r\n" .
+ "Actions: view, Voir sur Cold Haze, https://fr.equestria.horse/, clear=true\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => "Le poney de trait est désormais au front"
+ ]
+ ]));
+ }
+ } else if ($system === "ynmuc") {
+ $topic = "public-switches-cloudburst";
+ } else {
+ $topic = "main";
+ }
+
+ file_get_contents('https://' . $ntfy["server"] . '/' . $topic, false, $context);
+} \ No newline at end of file
diff --git a/pages/api/raindrops-img-round.php b/pages/api/raindrops-img-round.php
new file mode 100644
index 0000000..f733cc8
--- /dev/null
+++ b/pages/api/raindrops-img-round.php
@@ -0,0 +1,94 @@
+<?php
+
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true);
+
+$url = isset($fronters['members'][0]) ? ($fronters['members'][0]["avatar_url"] ?? "/assets/uploads/raindrops.png") : "/assets/uploads/raindrops.png";
+file_put_contents("/tmp/temp", file_get_contents($url));
+
+function imageCreateCorners($sourceImageFile, $radius) {
+ # test source image
+ if (file_exists($sourceImageFile)) {
+ $res = is_array($info = getimagesize($sourceImageFile));
+ }
+ else $res = false;
+
+ # open image
+ if ($res) {
+ $w = $info[0];
+ $h = $info[1];
+ switch ($info['mime']) {
+ case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile);
+ break;
+ case 'image/gif': $src = imagecreatefromgif($sourceImageFile);
+ break;
+ case 'image/png': $src = imagecreatefrompng($sourceImageFile);
+ break;
+ default:
+ $res = false;
+ }
+ }
+
+ # create corners
+ if ($res) {
+
+ $q = 10; # change this if you want
+ $radius *= $q;
+
+ # find unique color
+ do {
+ $r = rand(0, 255);
+ $g = rand(0, 255);
+ $b = rand(0, 255);
+ }
+ while (imagecolorexact($src, $r, $g, $b) < 0);
+
+ $nw = $w*$q;
+ $nh = $h*$q;
+
+ $img = imagecreatetruecolor($nw, $nh);
+ $alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127);
+ imagealphablending($img, false);
+ imagesavealpha($img, true);
+ imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor);
+
+ imagefill($img, 0, 0, $alphacolor);
+ imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h);
+
+ imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor);
+ imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor);
+ imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor);
+ imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor);
+ imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor);
+ imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor);
+ imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor);
+ imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor);
+ imagealphablending($img, true);
+ imagecolortransparent($img, $alphacolor);
+
+ # resize image down
+ $dest = imagecreatetruecolor($w, $h);
+ imagealphablending($dest, false);
+ imagesavealpha($dest, true);
+ imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor);
+ imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh);
+
+ # output image
+ $res = $dest;
+ imagedestroy($src);
+ imagedestroy($img);
+ }
+
+ return $res;
+}
+
+header("Content-Type: image/png");
+
+$id = bin2hex(random_bytes(8));
+exec('convert -size 128x128 xc:none -draw "roundrectangle 0,0,128,128,128,128" /tmp/' . $id . '-mask.png', $out);
+
+exec('convert -resize 128x128 "/tmp/temp" /tmp/' . $id . '-source.png');
+exec('convert /tmp/' . $id . '-source.png -matte /tmp/' . $id . '-mask.png -compose DstIn -composite /tmp/' . $id . '.png', $out2);
+
+unlink("/tmp/temp");
+
+echo(file_get_contents('/tmp/' . $id . '.png')); \ No newline at end of file
diff --git a/pages/api/raindrops-img.php b/pages/api/raindrops-img.php
new file mode 100644
index 0000000..4cbac6b
--- /dev/null
+++ b/pages/api/raindrops-img.php
@@ -0,0 +1,11 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc";
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true);
+
+$url = isset($fronters['members'][0]) ? ($fronters['members'][0]["avatar_url"] ? $_SERVER['DOCUMENT_ROOT'] . getAsset("gdapd", $fronters['members'][0]["id"]) : $_SERVER['DOCUMENT_ROOT'] . "/uploads/raindrops.png") : $_SERVER['DOCUMENT_ROOT'] . "/uploads/raindrops.png";
+file_put_contents("/tmp/temp", file_get_contents($url));
+header("Content-Type: " . mime_content_type("/tmp/temp"));
+unlink("/tmp/temp");
+
+echo(file_get_contents($url)); \ No newline at end of file
diff --git a/pages/api/raindrops-img2-round.php b/pages/api/raindrops-img2-round.php
new file mode 100644
index 0000000..8ca6c81
--- /dev/null
+++ b/pages/api/raindrops-img2-round.php
@@ -0,0 +1,94 @@
+<?php
+
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true);
+
+$url = isset($fronters['members'][1]) ? ($fronters['members'][1]["avatar_url"] ?? "/assets/uploads/raindrops.png") : "/assets/uploads/raindrops.png";
+file_put_contents("/tmp/temp", file_get_contents($url));
+
+function imageCreateCorners($sourceImageFile, $radius) {
+ # test source image
+ if (file_exists($sourceImageFile)) {
+ $res = is_array($info = getimagesize($sourceImageFile));
+ }
+ else $res = false;
+
+ # open image
+ if ($res) {
+ $w = $info[0];
+ $h = $info[1];
+ switch ($info['mime']) {
+ case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile);
+ break;
+ case 'image/gif': $src = imagecreatefromgif($sourceImageFile);
+ break;
+ case 'image/png': $src = imagecreatefrompng($sourceImageFile);
+ break;
+ default:
+ $res = false;
+ }
+ }
+
+ # create corners
+ if ($res) {
+
+ $q = 10; # change this if you want
+ $radius *= $q;
+
+ # find unique color
+ do {
+ $r = rand(0, 255);
+ $g = rand(0, 255);
+ $b = rand(0, 255);
+ }
+ while (imagecolorexact($src, $r, $g, $b) < 0);
+
+ $nw = $w*$q;
+ $nh = $h*$q;
+
+ $img = imagecreatetruecolor($nw, $nh);
+ $alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127);
+ imagealphablending($img, false);
+ imagesavealpha($img, true);
+ imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor);
+
+ imagefill($img, 0, 0, $alphacolor);
+ imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h);
+
+ imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor);
+ imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor);
+ imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor);
+ imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor);
+ imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor);
+ imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor);
+ imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor);
+ imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor);
+ imagealphablending($img, true);
+ imagecolortransparent($img, $alphacolor);
+
+ # resize image down
+ $dest = imagecreatetruecolor($w, $h);
+ imagealphablending($dest, false);
+ imagesavealpha($dest, true);
+ imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor);
+ imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh);
+
+ # output image
+ $res = $dest;
+ imagedestroy($src);
+ imagedestroy($img);
+ }
+
+ return $res;
+}
+
+header("Content-Type: image/png");
+
+$id = bin2hex(random_bytes(8));
+exec('convert -size 128x128 xc:none -draw "roundrectangle 0,0,128,128,128,128" /tmp/' . $id . '-mask.png', $out);
+
+exec('convert -resize 128x128 "/tmp/temp" /tmp/' . $id . '-source.png');
+exec('convert /tmp/' . $id . '-source.png -matte /tmp/' . $id . '-mask.png -compose DstIn -composite /tmp/' . $id . '.png', $out2);
+
+unlink("/tmp/temp");
+
+echo(file_get_contents('/tmp/' . $id . '.png')); \ No newline at end of file
diff --git a/pages/api/raindrops-two.php b/pages/api/raindrops-two.php
new file mode 100644
index 0000000..2fa09f2
--- /dev/null
+++ b/pages/api/raindrops-two.php
@@ -0,0 +1,8 @@
+<?php
+
+header("Content-Type: text/plain");
+
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true);
+echo(json_encode([
+ "multiple" => count($fronters["members"]) > 1
+])); \ No newline at end of file
diff --git a/pages/api/raindrops.php b/pages/api/raindrops.php
new file mode 100644
index 0000000..c44faa6
--- /dev/null
+++ b/pages/api/raindrops.php
@@ -0,0 +1,6 @@
+<?php
+
+header("Content-Type: text/plain");
+
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true);
+echo($fronters['members'][0]['display_name'] ?? $fronters['members'][0]['name']); \ No newline at end of file
diff --git a/pages/api/save-private.php b/pages/api/save-private.php
new file mode 100644
index 0000000..de7d505
--- /dev/null
+++ b/pages/api/save-private.php
@@ -0,0 +1,35 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn;
+if (!$isLoggedIn) header("Location: /-/login") and die();
+
+$request_raw = file_get_contents('php://input');
+$json_object = json_decode($request_raw, true);
+
+$system = $_GET['system'] ?? null;
+$member = $_GET['member'] ?? null;
+$content = $json_object['content'] ?? null;
+
+if (!isset($system) || trim($system) === "" || strlen($system) !== 5 || !preg_match("/[a-z]/i", $system))
+ peh_error("System 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);
+
+if (!isset($content))
+ peh_error("No content", 400);
+
+if ($member !== null && $member !== "null") {
+ $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member . "-private.html";
+} else {
+ $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $system . ".html";
+}
+
+if (trim($content) === "") {
+ if (file_exists($file)) {
+ unlink($file);
+ }
+ die();
+}
+
+file_put_contents($file, $content); \ No newline at end of file
diff --git a/pages/api/save.php b/pages/api/save.php
new file mode 100644
index 0000000..2ea3663
--- /dev/null
+++ b/pages/api/save.php
@@ -0,0 +1,37 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $app;
+if (!$isLoggedIn && !$isLowerLoggedIn) header("Location: /-/login") and die();
+
+$request_raw = file_get_contents('php://input');
+$json_object = json_decode($request_raw, true);
+
+$system = $_GET['system'] ?? null;
+$member = $_GET['member'] ?? null;
+$content = $json_object['content'] ?? null;
+
+if (!isset($system) || trim($system) === "" || strlen($system) !== 5 || !preg_match("/[a-z]/i", $system))
+ peh_error("System 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);
+
+if ($isLowerLoggedIn && $system !== $app["other"]["id"]) die();
+
+if (!isset($content))
+ peh_error("No content", 400);
+
+if ($member !== null && $member !== "null") {
+ $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member . ".html";
+} else {
+ $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $system . "/content.html";
+}
+
+if (trim($content) === "") {
+ if (file_exists($file)) {
+ unlink($file);
+ }
+ die();
+}
+
+file_put_contents($file, $content); \ No newline at end of file
diff --git a/pages/api/token.php b/pages/api/token.php
new file mode 100644
index 0000000..99b9158
--- /dev/null
+++ b/pages/api/token.php
@@ -0,0 +1,7 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn;
+if (!$isLoggedIn) header("Location: /-/login") and die();
+
+header("Content-Type: text/plain");
+die($_COOKIE['PEH2_SESSION_TOKEN']); \ No newline at end of file
diff --git a/pages/api/wakeup-real.php b/pages/api/wakeup-real.php
new file mode 100644
index 0000000..2267a4e
--- /dev/null
+++ b/pages/api/wakeup-real.php
@@ -0,0 +1,28 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn;
+if (!$isLoggedIn) header("Location: /-/login") and die();
+global $_PROFILE;
+
+$frontCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/fronters.json"), true)["members"];
+$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true)["members"];
+
+$pony = "somepony";
+if ($_PROFILE['login'] === "raindrops") $pony = $frontRaindrops[0]["display_name"]; else $pony = $frontCloudburst[0]["display_name"];
+
+$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
+
+file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🥱 Wake up!\r\n" .
+ "Priority: high\r\n" .
+ "Tags: wakeup\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => "Hey, $pony wants you to wake up!"
+ ]
+]));
+
+die(); \ No newline at end of file
diff --git a/pages/api/wakeup.php b/pages/api/wakeup.php
new file mode 100644
index 0000000..69b0a68
--- /dev/null
+++ b/pages/api/wakeup.php
@@ -0,0 +1,28 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn;
+if (!$isLoggedIn) header("Location: /-/login") and die();
+global $_PROFILE;
+
+$frontCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/fronters.json"), true)["members"];
+$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true)["members"];
+
+$pony = "somepony";
+if ($_PROFILE['login'] === "raindrops") $pony = $frontRaindrops[0]["display_name"]; else $pony = $frontCloudburst[0]["display_name"];
+
+$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
+
+file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: [Test] 🥱 Wake up!\r\n" .
+ "Priority: high\r\n" .
+ "Tags: wakeup\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => "[This notification is test] Hey, $pony wants you to wake up! [This notification is test]"
+ ]
+]));
+
+die(); \ No newline at end of file