summaryrefslogtreecommitdiff
path: root/pages/api/emergency.php
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api/emergency.php')
-rw-r--r--pages/api/emergency.php22
1 files changed, 22 insertions, 0 deletions
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