diff options
Diffstat (limited to 'pages/api/money/account.php')
-rw-r--r-- | pages/api/money/account.php | 62 |
1 files changed, 0 insertions, 62 deletions
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 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -if (!$isLoggedIn) header("Location: /-/login") and die(); -header("Content-Type: application/json"); - -$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 = []; - -if (!isset($_GET["id"])) { - die(json_encode($obj, JSON_PRETTY_PRINT)); -} - -foreach ($accounts as $account) { - if ($account["_name"] === $_GET["id"]) { - $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"] = []; - - foreach ($account["transactions"] as $index => $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 |