From a98bafed63f9322d54422861521c0c3c5d110d9a Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Sun, 14 May 2023 14:02:50 +0200 Subject: Updated 7 files and added 4 files (automated) --- includes/exchange.txt | 2 +- includes/util/functions.inc | 21 +++++++ pages/api.inc | 17 ++++-- pages/api/chrome.php | 4 +- pages/api/cloudburst-img-round.php | 78 +----------------------- pages/api/cloudburst-img2-round.php | 78 +----------------------- pages/api/money/account.php | 62 +++++++++++++++++++ pages/api/money/accounts.php | 96 +++++++++++++++++++++++++++++ pages/api/money/create.php | 99 ++++++++++++++++++++++++++++++ pages/api/wear/schedule.php | 117 ++++++++++++++++++++++++++++++++++++ pages/money.inc | 21 +------ 11 files changed, 412 insertions(+), 183 deletions(-) create mode 100644 pages/api/money/account.php create mode 100644 pages/api/money/accounts.php create mode 100644 pages/api/money/create.php create mode 100644 pages/api/wear/schedule.php diff --git a/includes/exchange.txt b/includes/exchange.txt index d04fb11..643c34f 100644 --- a/includes/exchange.txt +++ b/includes/exchange.txt @@ -1 +1 @@ -0.885 \ No newline at end of file +0.871 \ No newline at end of file diff --git a/includes/util/functions.inc b/includes/util/functions.inc index 3d84bb7..3bc8091 100644 --- a/includes/util/functions.inc +++ b/includes/util/functions.inc @@ -598,4 +598,25 @@ if (!function_exists("resolveMember")) { return $name; } } +} + +if (!function_exists("calculateFullAmount")) { + function calculateFullAmount($account, $asNumber = false, $gbpOnly = false): string|float|int { + global $rate; + $total = 0; + + foreach ($account["transactions"] as $transaction) { + $total += $transaction["amount"]; + } + + if ($asNumber) { + if ($gbpOnly && $account["currency"] === "eur") { + return $total * $rate; + } else { + return $total; + } + } else { + return number_format($total, 2, '.', ','); + } + } } \ No newline at end of file diff --git a/pages/api.inc b/pages/api.inc index 5c13bac..418df76 100644 --- a/pages/api.inc +++ b/pages/api.inc @@ -7,12 +7,17 @@ if (str_ends_with($_GET['_'], "/")) { } $toplevel = explode("/", $pagename)[1]; +$middlelevel = explode("/", $pagename)[2]; -if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php")) { - require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php"; +if (isset($middlelevel) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . "/" . $middlelevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . "/" . $middlelevel . ".php")) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . "/" . $middlelevel . ".php"; } else { - header("HTTP/1.1 500 Internal Server Error"); - header("Content-Type: text/plain"); - echo("Endpoint not found"); - die(); + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php")) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php"; + } else { + header("HTTP/1.1 500 Internal Server Error"); + header("Content-Type: text/plain"); + echo("Endpoint not found"); + die(); + } } \ No newline at end of file diff --git a/pages/api/chrome.php b/pages/api/chrome.php index c50599a..db32511 100644 --- a/pages/api/chrome.php +++ b/pages/api/chrome.php @@ -33,7 +33,7 @@ if (!isset($_GET["t"])) { - + Luna for Chrome OS