summaryrefslogtreecommitdiff
path: root/pages/api
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api')
-rw-r--r--pages/api/emergency-real.php31
-rw-r--r--pages/api/emergency.php31
-rw-r--r--pages/api/pleasure-real.php23
-rw-r--r--pages/api/pleasure.php23
4 files changed, 64 insertions, 44 deletions
diff --git a/pages/api/emergency-real.php b/pages/api/emergency-real.php
index a67f549..700a6a7 100644
--- a/pages/api/emergency-real.php
+++ b/pages/api/emergency-real.php
@@ -1,6 +1,7 @@
<?php
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE;
+if ($_PROFILE["login"] === "cloudburst") die();
if (!$isLoggedIn && !$isLowerLoggedIn) {
header("Location: /-/login");
@@ -10,31 +11,27 @@ if (!$isLoggedIn && !$isLowerLoggedIn) {
global $_PROFILE;
$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"];
+$channels = [];
-file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([
- 'http' => [
- 'method' => 'POST',
- 'header' =>
- "Content-Type: text/plain\r\n" .
- "Title: " . formatPonypush("⚠️🆘 EMERGENCY ⚠️🆘") . "\r\n" .
- "Priority: urgent\r\n" .
- "Tags: emergency\r\n" .
- "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => formatPonypush("This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now!")
- ]
-]));
+if (isset($_GET["raindrops"])) $channels[] = "emergency-raindrops";
+if (isset($_GET["moonglow"])) $channels[] = "emergency-moonglow";
+if (isset($_GET[$GLOBALS["ColdHazeApp"]["other"]["slug"]])) $channels[] = "emergency";
-file_get_contents('https://' . $ntfy["server"] . '/emergency', false, stream_context_create([
+$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' =>
"Content-Type: text/plain\r\n" .
- "Title: " . formatPonypush("⚠️🆘 EMERGENCY ⚠️🆘") . "\r\n" .
+ "Title: " . formatPonypush("⚠️ Emergency alert") . "\r\n" .
"Priority: urgent\r\n" .
"Tags: emergency\r\n" .
"Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => formatPonypush("This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now!")
+ 'content' => formatPonypush("This is an emergency, " . $_PROFILE['name'] . " is in need of immediate help. Please act now!")
]
-]));
+]);
+
+foreach ($channels as $channel) {
+ file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context);
+}
die(); \ No newline at end of file
diff --git a/pages/api/emergency.php b/pages/api/emergency.php
index 24c975a..a8a6e20 100644
--- a/pages/api/emergency.php
+++ b/pages/api/emergency.php
@@ -1,6 +1,7 @@
<?php
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE;
+if ($_PROFILE["login"] === "cloudburst") die();
if (!$isLoggedIn && !$isLowerLoggedIn) {
header("Location: /-/login");
@@ -10,31 +11,27 @@ if (!$isLoggedIn && !$isLowerLoggedIn) {
global $_PROFILE;
$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"];
+$channels = [];
-file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([
- 'http' => [
- 'method' => 'POST',
- 'header' =>
- "Content-Type: text/plain\r\n" .
- "Title: " . formatPonypush("[Test] ⚠️🆘 EMERGENCY ⚠️🆘") . "\r\n" .
- "Priority: urgent\r\n" .
- "Tags: emergency\r\n" .
- "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => formatPonypush("[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now! [This notification is test]")
- ]
-]));
+if (isset($_GET["raindrops"])) $channels[] = "emergency-raindrops";
+if (isset($_GET["moonglow"])) $channels[] = "emergency-moonglow";
+if (isset($_GET[$GLOBALS["ColdHazeApp"]["other"]["slug"]])) $channels[] = "emergency";
-file_get_contents('https://' . $ntfy["server"] . '/emergency', false, stream_context_create([
+$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' =>
"Content-Type: text/plain\r\n" .
- "Title: " . formatPonypush("[Test] ⚠️🆘 EMERGENCY ⚠️🆘") . "\r\n" .
+ "Title: " . formatPonypush("[Test] ⚠️ Emergency alert") . "\r\n" .
"Priority: urgent\r\n" .
"Tags: emergency\r\n" .
"Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => formatPonypush("[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now! [This notification is test]")
+ 'content' => formatPonypush("[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of immediate help. Please act now! [This notification is test]")
]
-]));
+]);
+
+foreach ($channels as $channel) {
+ file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context);
+}
die(); \ No newline at end of file
diff --git a/pages/api/pleasure-real.php b/pages/api/pleasure-real.php
index b523c1a..adfe732 100644
--- a/pages/api/pleasure-real.php
+++ b/pages/api/pleasure-real.php
@@ -1,6 +1,7 @@
<?php
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE;
+if ($_PROFILE["login"] === "cloudburst") die();
if (!$isLoggedIn && !$isLowerLoggedIn) {
header("Location: /-/login");
@@ -11,18 +12,26 @@ global $_PROFILE;
$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"];
+$frontMoonglow = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/hrbom/fronters.json"), true)["members"];
if ($_PROFILE["login"] === "raindrops" && isset($frontRaindrops[0])) {
$pony = $frontRaindrops[0]["display_name"] ?? $frontRaindrops[0]["name"];
-} else if ($_PROFILE["login"] !== "raindrops" && isset($frontOther[0])) {
+} else if ($_PROFILE["login"] === "Moonwind" && isset($frontMoonglow[0])) {
+ $pony = $frontMoonglow[0]["display_name"] ?? $frontMoonglow[0]["name"];
+} else if ($_PROFILE["login"] !== "raindrops" && $_PROFILE["login"] !== "Moonwind" && isset($frontOther[0])) {
$pony = $frontOther[0]["display_name"] ?? $frontOther[0]["name"];
} else {
$pony = "somepony";
}
$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"];
+$channels = [];
-file_get_contents('https://' . $ntfy["server"] . '/pleasure', false, stream_context_create([
+if (isset($_GET["raindrops"])) $channels[] = "emergency-raindrops";
+if (isset($_GET["moonglow"])) $channels[] = "emergency-moonglow";
+if (isset($_GET[$GLOBALS["ColdHazeApp"]["other"]["slug"]])) $channels[] = "pleasure";
+
+$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' =>
@@ -31,8 +40,12 @@ file_get_contents('https://' . $ntfy["server"] . '/pleasure', false, stream_cont
"Priority: high\r\n" .
"Tags: pleasure\r\n" .
"Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => formatPonypush("Hey, $pony wants to play and have fun for a bit, get up!")
+ 'content' => formatPonypush("Hey, $pony wants to play and have fun with you, get up!")
]
-]));
+]);
+
+foreach ($channels as $channel) {
+ file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context);
+}
die(); \ No newline at end of file
diff --git a/pages/api/pleasure.php b/pages/api/pleasure.php
index 58def71..7d331ce 100644
--- a/pages/api/pleasure.php
+++ b/pages/api/pleasure.php
@@ -1,6 +1,7 @@
<?php
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE;
+if ($_PROFILE["login"] === "cloudburst") die();
if (!$isLoggedIn && !$isLowerLoggedIn) {
header("Location: /-/login");
@@ -11,18 +12,26 @@ global $_PROFILE;
$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"];
+$frontMoonglow = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/hrbom/fronters.json"), true)["members"];
if ($_PROFILE["login"] === "raindrops" && isset($frontRaindrops[0])) {
$pony = $frontRaindrops[0]["display_name"] ?? $frontRaindrops[0]["name"];
-} else if ($_PROFILE["login"] !== "raindrops" && isset($frontOther[0])) {
+} else if ($_PROFILE["login"] === "Moonwind" && isset($frontMoonglow[0])) {
+ $pony = $frontMoonglow[0]["display_name"] ?? $frontMoonglow[0]["name"];
+} else if ($_PROFILE["login"] !== "raindrops" && $_PROFILE["login"] !== "Moonwind" && isset($frontOther[0])) {
$pony = $frontOther[0]["display_name"] ?? $frontOther[0]["name"];
} else {
$pony = "somepony";
}
$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"];
+$channels = [];
-file_get_contents('https://' . $ntfy["server"] . '/pleasure', false, stream_context_create([
+if (isset($_GET["raindrops"])) $channels[] = "emergency-raindrops";
+if (isset($_GET["moonglow"])) $channels[] = "emergency-moonglow";
+if (isset($_GET[$GLOBALS["ColdHazeApp"]["other"]["slug"]])) $channels[] = "pleasure";
+
+$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' =>
@@ -31,8 +40,12 @@ file_get_contents('https://' . $ntfy["server"] . '/pleasure', false, stream_cont
"Priority: high\r\n" .
"Tags: pleasure\r\n" .
"Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => formatPonypush("[This is a test] Hey, $pony wants to play and have fun for a bit, get up!")
+ 'content' => formatPonypush("[This notification is a test] Hey, $pony wants to play and have fun with you, get up! [This notification is a test]")
]
-]));
+]);
+
+foreach ($channels as $channel) {
+ file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context);
+}
die(); \ No newline at end of file