From d67f6a0547700aded74e2429c4f13d6a9dbf29ce Mon Sep 17 00:00:00 2001 From: Minteck Date: Fri, 17 Jun 2022 15:23:02 +0200 Subject: Fix major bug --- Application/AddTransaction/index.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'Application/AddTransaction') 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 -- cgit