0) {
$myId = $fronters[0]["id"];
} else {
$myId = "zdtsg";
}
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");
if (isset($_GET["create"])) {
if (!(isset($_GET["amount"]) && is_numeric($_GET["amount"]) && (float)$_GET["amount"] < 9999 && (float)$_GET["amount"] > -9999)) {
header("Location: /-/money/" . $parts[2]);
die();
}
if (!isset($_GET["description"])) $_GET["description"] = "";
$_GET["description"] = substr($_GET["description"], 0, 150);
$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)$_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"],
"amount" => (float)$_GET["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));
} else {
if (isset($_GET["id"]) && is_numeric($_GET["id"]) && isset($account["transactions"][(int)$_GET["id"]])) {
$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"]) . " deleted a transaction from " . $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)$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"];
unset($account["_name"]);
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/money/" . $name . ".json", json_encode($account, JSON_PRETTY_PRINT));
}
}
header("Location: /-/money/" . $parts[2]);
die();
}
$rate = (float)trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/exchange.txt"));
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
?>
As of = date('j F Y') ?> · €1 = £= $rate ?>
">£= number_format($difference, 2, '.', ',') ?> $minimumCloudburst): ?> (= round($part2 * 100, 2) ?>%) = $allAccounts > $minimumCloudburst ? "over" : "under" ?> the minimum
">€= number_format($difference, 2, '.', ',') ?> $minimumCloudburst): ?> (= round($part2 * 100, 2) ?>%) = $allAccounts > $minimumRaindrops ? "over" : "under" ?> the minimum