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/RemoveTransaction | |
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/RemoveTransaction')
-rw-r--r-- | Application/RemoveTransaction/index.php | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Application/RemoveTransaction/index.php b/Application/RemoveTransaction/index.php index 138f6a8..be78185 100644 --- a/Application/RemoveTransaction/index.php +++ b/Application/RemoveTransaction/index.php @@ -43,11 +43,18 @@ if (!isset($_GET['Transaction'])) { die(); } -$list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions.json"), true); +$list = array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions"), function ($i) { + return !str_starts_with($i, ".") && str_ends_with($i, ".json"); +}); -$list = array_filter($list, function ($item) { - return ($item["date"] !== base64url_decode($_GET['Transaction'])); +$list = array_filter(array_map(function ($item) { + $i = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions/" . $item), true); + $i["__file_id"] = $item; + return $i; +}, $list), function ($item) { + return ($item["date"] === base64url_decode($_GET['Transaction'])); }); +sort($list); +var_dump($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 +unlink($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions/" . $list[0]["__file_id"]);
\ No newline at end of file |