summaryrefslogtreecommitdiff
path: root/Application/RemoveTransaction/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'Application/RemoveTransaction/index.php')
-rw-r--r--Application/RemoveTransaction/index.php17
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