diff options
author | Minteck <contact@minteck.org> | 2022-06-17 15:23:02 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-06-17 15:23:02 +0200 |
commit | d67f6a0547700aded74e2429c4f13d6a9dbf29ce (patch) | |
tree | 6b4a533fe5057b55c9cf79d25041607132170105 /Application/AddTransaction/index.php | |
parent | 01a7ea3c92861529e22f8df52d6005cafcedc334 (diff) | |
download | bits-server-d67f6a0547700aded74e2429c4f13d6a9dbf29ce.tar.gz bits-server-d67f6a0547700aded74e2429c4f13d6a9dbf29ce.tar.bz2 bits-server-d67f6a0547700aded74e2429c4f13d6a9dbf29ce.zip |
Fix major bug
Diffstat (limited to 'Application/AddTransaction/index.php')
-rw-r--r-- | Application/AddTransaction/index.php | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/Application/AddTransaction/index.php b/Application/AddTransaction/index.php index e6b7d34..ef2f339 100644 --- a/Application/AddTransaction/index.php +++ b/Application/AddTransaction/index.php @@ -43,16 +43,14 @@ if (!isset($_GET['Currency']) || !isset($_GET['Amount']) || !is_numeric($_GET['A die(); } -$list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions.json"), true); +$transaction = []; $exchangeRate = (float)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/ExchangeRate.txt"); $eurToGbp = $exchangeRate; $gbpToEur = 1 / $eurToGbp; -$list = array_reverse($list); - if ($_GET['Currency'] === "€") { - $list[] = [ + $transaction = [ 'author' => $_PROFILE['id'], 'type' => $_GET['Operation'] === "+" || $_GET['Operation'] === " " ? "gain" : "pay", 'amount' => [ @@ -64,7 +62,7 @@ if ($_GET['Currency'] === "€") { 'description' => base64url_decode($_GET['Description']) ]; } else { - $list[] = [ + $transaction = [ 'author' => $_PROFILE['id'], 'type' => $_GET['Operation'] === "+" || $_GET['Operation'] === " " ? "gain" : "pay", 'amount' => [ @@ -77,7 +75,4 @@ if ($_GET['Currency'] === "€") { ]; } -$list = array_reverse($list); - -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions." . str_replace(":", "-", date('c')) . ".json", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions.json")); -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions.json", json_encode($list));
\ No newline at end of file +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions/" . date('U') . ".json", json_encode($transaction));
\ No newline at end of file |