summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-02-17 18:32:46 +0100
committerMinteck <contact@minteck.org>2023-02-17 18:32:46 +0100
commit3bbc6588912bb42b124cca295447d4e537a8c763 (patch)
tree696a05fbb0b8d3772d3574f2aa4994daf553e4ae
parentad01942b407c5dde212f8c2ee7d6f0f04cb6c797 (diff)
downloadpluralconnect-3bbc6588912bb42b124cca295447d4e537a8c763.tar.gz
pluralconnect-3bbc6588912bb42b124cca295447d4e537a8c763.tar.bz2
pluralconnect-3bbc6588912bb42b124cca295447d4e537a8c763.zip
Updated 2 files (automated)
-rw-r--r--includes/navigation.inc2
-rw-r--r--pages/money.inc32
2 files changed, 30 insertions, 4 deletions
diff --git a/includes/navigation.inc b/includes/navigation.inc
index b61c069..7f744b9 100644
--- a/includes/navigation.inc
+++ b/includes/navigation.inc
@@ -68,7 +68,7 @@ $navigation_admin = [
"stepped" => null
],
[
- "name" => $pages["money"]["name"][$lang["_name"]] . " <span class='badge bg-success rounded-pill'>Beta</span>",
+ "name" => $pages["money"]["name"][$lang["_name"]],
"icon" => "/assets/icons/money.svg",
"invert" => true,
"link" => "/-/money",
diff --git a/pages/money.inc b/pages/money.inc
index 609ff6c..9036aff 100644
--- a/pages/money.inc
+++ b/pages/money.inc
@@ -10,6 +10,8 @@ $accounts = array_map(function ($i) {
return $data;
}, array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/money"), function ($i) { return !str_starts_with($i, "."); })));
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc";
+
function calculateFullAmount($account, $asNumber = false, $gbpOnly = false): string|float|int {
global $rate;
$total = 0;
@@ -37,6 +39,7 @@ if (isset($parts[2])) {
}
}
+$systemID = $_PROFILE["login"] === "cloudburst" ? "ynmuc" : "gdapd";
$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($_PROFILE["login"] === "cloudburst" ? "ynmuc" : "gdapd") . "/fronters.json"), true)["members"];
if (count($fronters) > 0) {
@@ -49,7 +52,6 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) {
$account = array_values(array_filter($accounts, function ($i) use ($parts) { return $i["_name"] === $parts[2]; }))[0];
header("Content-Type: text/plain");
- //var_dump($_GET);
if (isset($_GET["create"])) {
if (!(isset($_GET["amount"]) && is_numeric($_GET["amount"]) && (float)$_GET["amount"] < 9999 && (float)$_GET["amount"] > -9999)) {
@@ -59,6 +61,19 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) {
if (!isset($_GET["description"])) $_GET["description"] = "";
$_GET["description"] = substr($_GET["description"], 0, 150);
+ $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: " . (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' => $account["currency"] === "gbp" ? "£" : "€" . abs((float)$_GET["amount"]) . " were " . ((float)$_GET["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($_GET["description"]) !== "" ? ": " . $_GET["description"] : "")
+ ]
+ ]));
+
array_unshift($account["transactions"], [
"author" => $myId,
"description" => $_GET["description"],
@@ -72,6 +87,19 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/money/" . $name . ".json", json_encode($account, JSON_PRETTY_PRINT));
} else {
if (isset($_GET["id"]) && is_numeric($_GET["id"]) && isset($account["transactions"][(int)$_GET["id"]])) {
+ $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: " . (getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " deleted a transaction from " . $account["name"] . " (" . ucfirst($account["owner"]) . ")\r\n" .
+ "Tags: bits\r\n" .
+ "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
+ 'content' => $account["currency"] === "gbp" ? "£" : "€" . abs((float)$account["transactions"][(int)$_GET["id"]]["amount"]) . " " . ((float)$account["transactions"][(int)$_GET["id"]]["amount"] >= 0 ? "advance" : "withdrawal") . " created by " . (getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["display_name"] ?? getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["name"]) . " " . timeAgo($account["transactions"][(int)$_GET["id"]]["date"])
+ ]
+ ]));
+
unset($account["transactions"][(int)$_GET["id"]]);
$name = $account["_name"];
@@ -81,8 +109,6 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) {
}
}
- //die();
-
header("Location: /-/money/" . $parts[2]);
die();
}