summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/external/matrix/index.js4
-rw-r--r--includes/util/functions.inc2
-rw-r--r--pages/api/overage.php47
-rw-r--r--pages/api/schedule.php69
-rw-r--r--pages/rules.inc12
5 files changed, 127 insertions, 7 deletions
diff --git a/includes/external/matrix/index.js b/includes/external/matrix/index.js
index 1bfb8d4..b8ae194 100644
--- a/includes/external/matrix/index.js
+++ b/includes/external/matrix/index.js
@@ -66,8 +66,8 @@ client.once("sync", async function (state, prevState, res) {
fs.writeFileSync("/tmp/chm-" + user + "-1", img1);
fs.writeFileSync("/tmp/chm-" + user + "-2", img2);
- child_process.execSync("convert /tmp/chm-" + user + "-1 -gravity center -crop 50%x100% /tmp/chm-" + user + "-1.webp");
- child_process.execSync("convert /tmp/chm-" + user + "-2 -gravity center -crop 50%x100% /tmp/chm-" + user + "-2.webp");
+ child_process.execSync("convert /tmp/chm-" + user + "-1 -gravity center -resize 512x512 -crop 50%x100% /tmp/chm-" + user + "-1.webp");
+ child_process.execSync("convert /tmp/chm-" + user + "-2 -gravity center -resize 512x512 -crop 50%x100% /tmp/chm-" + user + "-2.webp");
child_process.execSync("montage -mode concatenate -tile x1 /tmp/chm-" + user + "-1.webp /tmp/chm-" + user + "-2.webp /tmp/chm-" + user + ".webp");
pfp = fs.readFileSync("/tmp/chm-" + user + ".webp");
diff --git a/includes/util/functions.inc b/includes/util/functions.inc
index fe97980..16e2bdd 100644
--- a/includes/util/functions.inc
+++ b/includes/util/functions.inc
@@ -13,7 +13,7 @@ if (!function_exists("createJob")) {
"date" => date('c')
];
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/jobs/" . round(microtime(true) * 1000) . "-" . random() . ".json", json_encode($job));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/jobs/" . round(microtime(true) * 1000000) . "-" . random() . ".json", json_encode($job));
}
}
diff --git a/pages/api/overage.php b/pages/api/overage.php
new file mode 100644
index 0000000..aef4ac6
--- /dev/null
+++ b/pages/api/overage.php
@@ -0,0 +1,47 @@
+<?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/schedule.php b/pages/api/schedule.php
new file mode 100644
index 0000000..489e28f
--- /dev/null
+++ b/pages/api/schedule.php
@@ -0,0 +1,69 @@
+<?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) { return getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]; }, 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) { return getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]; }, 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) { return getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]; }, 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) { return getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]; }, 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["tomorrow"][] = $item;
+ }
+}
+
+die(json_encode($obj, JSON_PRETTY_PRINT)); \ No newline at end of file
diff --git a/pages/rules.inc b/pages/rules.inc
index 23447f2..0c57819 100644
--- a/pages/rules.inc
+++ b/pages/rules.inc
@@ -1,5 +1,9 @@
<?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();
@@ -44,14 +48,16 @@ $cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/da
?>
-<?php if (!isset($cache["content"])): ob_start(); ?>
-
<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);
@@ -279,7 +285,5 @@ $cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/da
filter: invert(1);
}
</style>
-<?php $cache["content"] = ob_get_contents(); ob_end_clean(); endif;
-echo($cache["content"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/rules.json", json_encode($cache)); ?>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>