summaryrefslogtreecommitdiff
path: root/includes/util
diff options
context:
space:
mode:
Diffstat (limited to 'includes/util')
-rw-r--r--includes/util/agewarning.inc10
-rw-r--r--includes/util/banner.inc13
-rw-r--r--includes/util/functions.inc16
-rw-r--r--includes/util/score.inc2
-rw-r--r--includes/util/session.inc6
-rw-r--r--includes/util/travelling.inc2
6 files changed, 31 insertions, 18 deletions
diff --git a/includes/util/agewarning.inc b/includes/util/agewarning.inc
index 1f51647..f8bc650 100644
--- a/includes/util/agewarning.inc
+++ b/includes/util/agewarning.inc
@@ -1,7 +1,7 @@
<?php
function showWarning($name, $id, $system) {
- $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
+ $ntfy = $GLOBALS["ColdHazeApp"]["ntfy"];
if (time() > 1677628800) {
file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy['topic'], false, stream_context_create([
@@ -9,12 +9,12 @@ function showWarning($name, $id, $system) {
'method' => 'POST',
'header' =>
"Content-Type: text/plain\r\n" .
- "Title: ⚠️ $name does not have an age or birth year set\r\n" .
+ "Title: " . formatPonypush("⚠️ $name does not have an age or birth year set") . "\r\n" .
"Priority: max\r\n" .
"Tags: switch\r\n" .
"Actions: view, Edit on Cold Haze, https://ponies.equestria.horse/-/metadata/" . ($system === "gdapd" ? "raindrops" : "cloudburst") . "/" . $id . "/, clear=true\r\n" .
"Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => "To make sure they appear on the fronting schedule (and to make sure they can front again), they need to set an age or birth year now."
+ 'content' => formatPonypush("To make sure they appear on the fronting schedule (and to make sure they can front again), they need to set an age or birth year now.")
]
]));
} else {
@@ -23,12 +23,12 @@ function showWarning($name, $id, $system) {
'method' => 'POST',
'header' =>
"Content-Type: text/plain\r\n" .
- "Title: ⚠️ $name does not have an age or birth year set\r\n" .
+ "Title: " . formatPonypush("⚠️ $name does not have an age or birth year set") . "\r\n" .
"Priority: max\r\n" .
"Tags: switch\r\n" .
"Actions: view, Edit on Cold Haze, https://ponies.equestria.horse/-/metadata/" . ($system === "gdapd" ? "raindrops" : "cloudburst") . "/" . $id . "/, clear=true\r\n" .
"Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => "To make sure they still appear on the fronting schedule after March 1st, they need to set an age or birth year now."
+ 'content' => formatPonypush("To make sure they still appear on the fronting schedule after March 1st, they need to set an age or birth year now.")
]
]));
}
diff --git a/includes/util/banner.inc b/includes/util/banner.inc
index 1657233..947e5c6 100644
--- a/includes/util/banner.inc
+++ b/includes/util/banner.inc
@@ -1,6 +1,6 @@
<?php
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $lang; global $pages;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $lang; global $pages; global $isLowerLoggedIn;
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/pronouns.inc";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/Parsedown.php"; $Parsedown = new Parsedown();
@@ -21,6 +21,7 @@ function _header_getMember(string $id, $system) {
function getMemberBannerData(string $id, string $system, bool $french = false) {
global $travelling;
global $isLoggedIn;
+ global $isLowerLoggedIn;
global $lang;
global $Parsedown;
@@ -155,7 +156,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) {
];
}
- $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+ $app = $GLOBALS["ColdHazeApp"];
$systemData = [];
$systemData['page'] = "/" . ($system === "gdapd" ? "raindrops" : ($system === $app["other"]["id"] ? $app["other"]["slug"] : "cloudburst"));
@@ -190,7 +191,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) {
sort($mfMember);
$mfMember = $mfMember[0];
- $marefriends[] = [
+ if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)) $marefriends[] = [
"id" => $marefriend,
"link" => "/" . ($mfMember["name"]),
"icon" => getAsset($mfSystem, $mfMemberID, "heads"),
@@ -212,7 +213,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) {
sort($mfMember);
$mfMember = $mfMember[0];
- $sexfriends[] = [
+ if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)) $sexfriends[] = [
"id" => $marefriend,
"link" => "/" . ($mfMember["name"]),
"icon" => getAsset($mfSystem, $mfMemberID, "heads"),
@@ -232,7 +233,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) {
sort($mfMember);
$mfMember = $mfMember[0];
- $sisters[] = [
+ if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)) $sisters[] = [
"id" => $marefriend,
"link" => "/" . ($mfMember["name"]),
"icon" => getAsset($mfSystem, $mfMemberID, "heads"),
@@ -254,7 +255,7 @@ function getMemberBannerData(string $id, string $system, bool $french = false) {
sort($mfMember);
$mfMember = $mfMember[0];
- $caretakers[] = [
+ if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)) $caretakers[] = [
"id" => $marefriend,
"link" => "/" . ($mfMember["name"]),
"icon" => getAsset($mfSystem, $mfMemberID, "heads"),
diff --git a/includes/util/functions.inc b/includes/util/functions.inc
index 5b5b6b5..79a47c6 100644
--- a/includes/util/functions.inc
+++ b/includes/util/functions.inc
@@ -17,6 +17,12 @@ if (!function_exists("createJob")) {
}
}
+if (!function_exists("formatPonypush")) {
+ function formatPonypush($message) {
+ return "Update to Ponypush 3.1.0 or later — (\$PA1$\$" . base64_encode($message) . "\$\$)";
+ }
+}
+
if (!function_exists("peh_error")) {
function peh_error($message, $code = 500): void {
header("Location: /?em=" . urlencode(base64_encode($message)) . "&ec=" . $code);
@@ -26,7 +32,7 @@ if (!function_exists("peh_error")) {
if (!function_exists("getAsset")) {
function getAsset($systemID, $memberID = null, $type = "avatars") {
- $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+ $app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
$systemFile = (isset($app["other"]) && $systemID === $app["other"]["id"]) ? "other" : $systemID;
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemFile/general.json")) {
@@ -234,7 +240,7 @@ if (!function_exists("withCaretakersDown")) {
if (!function_exists("getSystemMember")) {
function getSystemMember(string $system, string $id) {
- $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+ $app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
$systemID = $system;
$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === $app["other"]["id"] ? "other" : $systemID) . "/members.json"), true);
@@ -270,7 +276,7 @@ if (!function_exists("getMemberWithoutSystem")) {
}
if ($isLowerLoggedIn || $isLoggedIn) {
- $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+ $app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
$members3 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true);
foreach ($members3 as $m) {
@@ -316,7 +322,7 @@ if (!function_exists("prettySize")) {
if (!function_exists("showSystem")) {
function showSystem(string $id, string $name, string $color, bool $hideTitle) {
- $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+ $app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
global $travelling;
$global = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . (isset($app["other"]) && $id === $app["other"]["id"] ? "other" : $id) . "/general.json"), true);
@@ -381,7 +387,7 @@ if (!function_exists("raindrops")) {
if (!function_exists("other")) {
function other(bool $hideTitle): void {
- $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+ $app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
showSystem($app["other"]["id"], $app["other"]["name"], "#" . $app["other"]["color"] . "a6", $hideTitle);
}
}
diff --git a/includes/util/score.inc b/includes/util/score.inc
index ad3c8e4..9deacca 100644
--- a/includes/util/score.inc
+++ b/includes/util/score.inc
@@ -113,7 +113,7 @@ function scoreOrderGlobal() {
}
if ($isLowerLoggedIn || $isLoggedIn) {
- $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+ $app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true) as $member) {
if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) {
if (isset($member["color"])) {
diff --git a/includes/util/session.inc b/includes/util/session.inc
index 7a6b931..72dd34d 100644
--- a/includes/util/session.inc
+++ b/includes/util/session.inc
@@ -9,6 +9,12 @@ global $_PROFILE;
$isLoggedIn = false;
$isLowerLoggedIn = false;
+if (!function_exists("formatPonypush")) {
+ function formatPonypush($message) {
+ return "Update to Ponypush 3.1.0 or later — (\$PA1$\$" . base64_encode($message) . "\$\$)";
+ }
+}
+
if (isset($_COOKIE['PEH2_SESSION_TOKEN'])) {
if (!(str_contains($_COOKIE['PEH2_SESSION_TOKEN'], ".") || str_contains($_COOKIE['PEH2_SESSION_TOKEN'], "/") || trim($_COOKIE["PEH2_SESSION_TOKEN"]) === "")) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN'])))) {
diff --git a/includes/util/travelling.inc b/includes/util/travelling.inc
index 0d1696a..eced4f2 100644
--- a/includes/util/travelling.inc
+++ b/includes/util/travelling.inc
@@ -1,6 +1,6 @@
<?php
-$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+$app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true);
$json_cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true);