From 2b192b3840ac344c456b98304ea400f0af90da15 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Sat, 13 Jan 2024 16:12:11 +0100 Subject: Updated 46 files and deleted 19 files (automated) --- pages/api/cloudburst-img-round.php | 18 ------- pages/api/cloudburst-img.php | 11 ----- pages/api/cloudburst-img2-round.php | 18 ------- pages/api/cloudburst-two.php | 8 --- pages/api/cloudburst.php | 6 --- pages/api/emergency-real.php | 2 +- pages/api/emergency.php | 2 +- pages/api/me.php | 10 ++-- pages/api/money/account.php | 62 ----------------------- pages/api/money/accounts.php | 96 ----------------------------------- pages/api/money/create.php | 99 ------------------------------------- pages/api/pleasure-real.php | 5 +- pages/api/pleasure.php | 5 +- pages/api/pluralkit-integration.php | 3 -- pages/api/raindrops-img-round.php | 18 ------- pages/api/raindrops-img-round2.php | 20 -------- pages/api/raindrops-img.php | 11 ----- pages/api/raindrops-img2-round.php | 18 ------- pages/api/raindrops-img2-round2.php | 20 -------- pages/api/raindrops-two.php | 8 --- pages/api/raindrops.php | 6 --- pages/api/timeline.php | 2 +- pages/api/wakeup-real.php | 33 ------------- pages/api/wakeup.php | 33 ------------- 24 files changed, 12 insertions(+), 502 deletions(-) delete mode 100644 pages/api/cloudburst-img-round.php delete mode 100644 pages/api/cloudburst-img.php delete mode 100644 pages/api/cloudburst-img2-round.php delete mode 100644 pages/api/cloudburst-two.php delete mode 100644 pages/api/cloudburst.php delete mode 100644 pages/api/money/account.php delete mode 100644 pages/api/money/accounts.php delete mode 100644 pages/api/money/create.php delete mode 100644 pages/api/raindrops-img-round.php delete mode 100644 pages/api/raindrops-img-round2.php delete mode 100644 pages/api/raindrops-img.php delete mode 100644 pages/api/raindrops-img2-round.php delete mode 100644 pages/api/raindrops-img2-round2.php delete mode 100644 pages/api/raindrops-two.php delete mode 100644 pages/api/raindrops.php delete mode 100644 pages/api/wakeup-real.php delete mode 100644 pages/api/wakeup.php (limited to 'pages/api') diff --git a/pages/api/cloudburst-img-round.php b/pages/api/cloudburst-img-round.php deleted file mode 100644 index 3238696..0000000 --- a/pages/api/cloudburst-img-round.php +++ /dev/null @@ -1,18 +0,0 @@ - count($fronters["members"]) > 1 -])); \ No newline at end of file diff --git a/pages/api/cloudburst.php b/pages/api/cloudburst.php deleted file mode 100644 index 2750a98..0000000 --- a/pages/api/cloudburst.php +++ /dev/null @@ -1,6 +0,0 @@ - getAsset("gdapd"), "email" => $_PROFILE["profile"]["email"]["email"] ])); -} else if ($_PROFILE["login"] === "cloudburst") { +} else if ($_PROFILE["login"] === "Moonglow") { die(json_encode([ "valid" => true, - "name" => "Cloudburst System", - "id" => "cloudburst", - "pluralkit" => "ynmuc", - "avatar" => getAsset("ynmuc"), + "name" => "Moonglow", + "id" => "moonglow", + "pluralkit" => "hrbom", + "avatar" => getAsset("hrbom"), "email" => $_PROFILE["profile"]["email"]["email"] ])); } else { diff --git a/pages/api/money/account.php b/pages/api/money/account.php deleted file mode 100644 index 1801b28..0000000 --- a/pages/api/money/account.php +++ /dev/null @@ -1,62 +0,0 @@ - $transaction) { - $member = getMemberWithoutSystem($transaction["author"]) ?? getMemberWithoutSystem("zdtsg"); - $trans = [ - "id" => $index, - "author" => [ - "avatar" => getAsset($member["_system"], $member["id"]), - "name" => $member["display_name"] ?? $member["name"] - ], - "type" => $transaction["amount"] < 0 ? "REMOVE" : "ADD", - "amount" => round(abs($transaction["amount"]), 2), - "date" => [ - "ts" => strtotime($transaction["date"]), - "iso" => date('c', strtotime($transaction["date"])), - "relative" => timeAgo($transaction["date"]) - ], - "description" => (isset($transaction["description"]) && trim($transaction["description"]) !== "") ? trim($transaction["description"]) : null - ]; - - $acc["transactions"][] = $trans; - } - - $obj = $acc; - } -} - -/* ------------------- */ - -die(json_encode($obj, JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/pages/api/money/accounts.php b/pages/api/money/accounts.php deleted file mode 100644 index 9f85323..0000000 --- a/pages/api/money/accounts.php +++ /dev/null @@ -1,96 +0,0 @@ - 0, - "exchange_rate" => $rate, - "users" => [ - "cloudburst" => [ - "total" => 0, - "accounts" => [] - ], - "raindrops" => [ - "total" => 0, - "accounts" => [] - ] - ] -]; - -$allAccounts = array_reduce(array_map(function ($i) { - return calculateFullAmount($i, true, true); -}, $accounts), function ($a, $b) { - return $a + $b; -}); -$obj["total"] = [ - "gbp" => round($allAccounts, 2), - "eur" => round($allAccounts * (1 / $rate), 2) -]; - -/* ------------------- */ - -$allAccounts = array_reduce(array_map(function ($i) { - return calculateFullAmount($i, true, true); -}, array_values(array_filter($accounts, function ($i) { return $i["owner"] === "cloudburst"; }))), function ($a, $b) { - return $a + $b; -}); - -$obj["users"]["cloudburst"]["total"] = $allAccounts; - -foreach ($accounts as $index => $account) { - if ($account["owner"] === "cloudburst") { - $acc = []; - - $acc["id"] = $account["_name"]; - $acc["name"] = $account["name"]; - $acc["currency"] = $account["currency"]; - $acc["default"] = $account["default"]; - $acc["total"] = round(calculateFullAmount($account, true), 2); - $acc["interests"] = $account["interests"]; - $acc["max"] = $account["max"]; - $acc["used_percentage"] = isset($account["max"]) ? round((calculateFullAmount($account, true) / $account["max"]) * 100, 2) : null; - - $obj["users"]["cloudburst"]["accounts"][] = $acc; - } -} -/* ------------------- */ - -$allAccounts = array_reduce(array_map(function ($i) { - return calculateFullAmount($i, true, true); -}, array_values(array_filter($accounts, function ($i) { return $i["owner"] === "raindrops"; }))), function ($a, $b) { - return $a + $b; -}); - -$obj["users"]["raindrops"]["total"] = $allAccounts; - -foreach ($accounts as $index => $account) { - if ($account["owner"] === "raindrops") { - $acc = []; - - $acc["id"] = $account["_name"]; - $acc["name"] = $account["name"]; - $acc["currency"] = $account["currency"]; - $acc["default"] = $account["default"]; - $acc["total"] = round(calculateFullAmount($account, true), 2); - $acc["interests"] = $account["interests"]; - $acc["max"] = $account["max"]; - $acc["used_percentage"] = isset($account["max"]) ? round((calculateFullAmount($account, true) / $account["max"]) * 100, 2) : null; - $acc["transactions"] = null; - - $obj["users"]["raindrops"]["accounts"][] = $acc; - } -} - -/* ------------------- */ - -die(json_encode($obj, JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/pages/api/money/create.php b/pages/api/money/create.php deleted file mode 100644 index 12cc7c9..0000000 --- a/pages/api/money/create.php +++ /dev/null @@ -1,99 +0,0 @@ - 0) { - $myId = $fronters[0]["id"]; -} else { - $myId = "zdtsg"; -} - -$accounts = array_map(function ($i) { - $name = substr($i, 0, -5); - $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/money/" . $i), true); - $data["_name"] = $name; - return $data; -}, array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/money"), function ($i) { return !str_starts_with($i, "."); }))); -$rate = (float)trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/exchange.txt")); - -$obj = [ - "success" => false, - "error" => null -]; - -if ($_SERVER["REQUEST_METHOD"] !== "POST") { - $obj["success"] = false; - $obj["error"] = "INVALID_METHOD"; - die(json_encode($obj, JSON_PRETTY_PRINT)); -} - -if (!isset($data["amount"]) || !isset($data["id"]) || !isset($data["description"])) { - $obj["success"] = false; - $obj["error"] = "MISSING_OPERAND"; - die(json_encode($obj, JSON_PRETTY_PRINT)); -} - -$account = array_values(array_filter($accounts, function ($i) use ($data) { return $i["_name"] === $data["id"]; }))[0] ?? null; - -if (!isset($account)) { - $obj["success"] = false; - $obj["error"] = "ACCOUNT_NOT_FOUND"; - die(json_encode($obj, JSON_PRETTY_PRINT)); -} - -if (!(isset($data["amount"]) && is_numeric($data["amount"]) && (float)$data["amount"] < 9999 && (float)$data["amount"] > -9999)) { - $obj["success"] = false; - $obj["error"] = "INVALID_AMOUNT"; - die(json_encode($obj, JSON_PRETTY_PRINT)); -} -if (!isset($data["description"])) $data["description"] = ""; - -if (strlen($data["description"]) > 150) { - $obj["success"] = false; - $obj["error"] = "DESCRIPTION_TOO_LONG"; - die(json_encode($obj, JSON_PRETTY_PRINT)); -} - -if ($data["amount"] === 0) { - $obj["success"] = false; - $obj["error"] = "AMOUNT_IS_ZERO"; - die(json_encode($obj, JSON_PRETTY_PRINT)); -} - -$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; -file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush((getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " created a transaction to " . $account["name"] . " (" . ucfirst($account["owner"]) . ")") . "\r\n" . - "Tags: bits\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush(($account["currency"] === "gbp" ? "£" : "€") . abs((float)$data["amount"]) . " were " . ((float)$data["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($data["description"]) !== "" ? ": " . $data["description"] : "")) - ] -])); - -array_unshift($account["transactions"], [ - "author" => $myId, - "description" => $data["description"], - "amount" => (float)$data["amount"], - "date" => date('c') -]); - -$name = $account["_name"]; -unset($account["_name"]); - -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/money/" . $name . ".json", json_encode($account, JSON_PRETTY_PRINT)); - -$obj["success"] = true; -die(json_encode($obj, JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/pages/api/pleasure-real.php b/pages/api/pleasure-real.php index adfe732..c1cbd59 100644 --- a/pages/api/pleasure-real.php +++ b/pages/api/pleasure-real.php @@ -1,7 +1,6 @@ count($fronters["members"]) > 1 -])); \ No newline at end of file diff --git a/pages/api/raindrops.php b/pages/api/raindrops.php deleted file mode 100644 index c44faa6..0000000 --- a/pages/api/raindrops.php +++ /dev/null @@ -1,6 +0,0 @@ - [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("🥱 Wake up!") . "\r\n" . - "Priority: high\r\n" . - "Tags: wakeup\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("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 deleted file mode 100644 index a5d2b9f..0000000 --- a/pages/api/wakeup.php +++ /dev/null @@ -1,33 +0,0 @@ - [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("[Test] 🥱 Wake up!") . "\r\n" . - "Priority: high\r\n" . - "Tags: wakeup\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("[This notification is test] Hey, $pony wants you to wake up! [This notification is test]") - ] -])); - -die(); \ No newline at end of file -- cgit