From 10b1ace835d908d32f99874facf8811534087d5b Mon Sep 17 00:00:00 2001 From: Minteck Date: Mon, 6 Jun 2022 17:10:14 +0200 Subject: Initial commit --- Application/TransactionsList/index.php | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Application/TransactionsList/index.php (limited to 'Application/TransactionsList/index.php') diff --git a/Application/TransactionsList/index.php b/Application/TransactionsList/index.php new file mode 100644 index 0000000..185e94b --- /dev/null +++ b/Application/TransactionsList/index.php @@ -0,0 +1,52 @@ += 0) { + return $tense = "now"; + } elseif ($difference > 0) { + $tense = "ago"; + } else { + $tense = "later"; + } + + for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { + $difference /= $lengths[$j]; + } + + $difference = round($difference); + + $period = $periods[$j] . ($difference >1 ? "s" :''); + return "{$difference} {$period} {$tense} "; +} + +require_once $_SERVER['DOCUMENT_ROOT'] . "/Private/SessionManager.php"; +header("Content-Type: application/json"); + +$users = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Users.json"), true); +$list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Transactions.json"), true); +$plist = []; + +foreach ($list as $item) { + $item["author"] = [ + "id" => $item["author"], + "name" => $users[$item["author"]] ?? $item["author"], + "avatar" => "https://account.minteck.org/hub/api/rest/avatar/" . $item["author"] . "?dpr=2&size=48" + ]; + $item["date"] = [ + "absolute" => $item["date"], + "relative" => trim(timeAgo($item["date"])) + ]; + $plist[] = $item; +} + +die(json_encode($plist)); \ No newline at end of file -- cgit