summaryrefslogtreecommitdiff
path: root/Application
diff options
context:
space:
mode:
Diffstat (limited to 'Application')
-rw-r--r--Application/AddTransaction/index.php9
-rw-r--r--Application/SetCurrentIdentity/index.php22
-rw-r--r--Application/SetDefaultIdentity/index.php13
-rw-r--r--Application/TransactionsList/index.php4
4 files changed, 44 insertions, 4 deletions
diff --git a/Application/AddTransaction/index.php b/Application/AddTransaction/index.php
index ef2f339..2a56696 100644
--- a/Application/AddTransaction/index.php
+++ b/Application/AddTransaction/index.php
@@ -45,6 +45,7 @@ if (!isset($_GET['Currency']) || !isset($_GET['Amount']) || !is_numeric($_GET['A
$transaction = [];
$exchangeRate = (float)file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/ExchangeRate.txt");
+$identities = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Identities.json"), true);
$eurToGbp = $exchangeRate;
$gbpToEur = 1 / $eurToGbp;
@@ -59,7 +60,9 @@ if ($_GET['Currency'] === "€") {
'original' => 'eur'
],
'date' => date("c"),
- 'description' => base64url_decode($_GET['Description'])
+ 'description' => base64url_decode($_GET['Description']),
+ 'name' => $identities[$_PROFILE["id"]]["name"],
+ 'picture' => $identities[$_PROFILE["id"]]["picture"]
];
} else {
$transaction = [
@@ -71,7 +74,9 @@ if ($_GET['Currency'] === "€") {
'original' => 'gbp'
],
'date' => date("c"),
- 'description' => base64url_decode($_GET['Description'])
+ 'description' => base64url_decode($_GET['Description']),
+ 'name' => $identities[$_PROFILE["id"]]["name"],
+ 'picture' => $identities[$_PROFILE["id"]]["picture"]
];
}
diff --git a/Application/SetCurrentIdentity/index.php b/Application/SetCurrentIdentity/index.php
new file mode 100644
index 0000000..d7603dd
--- /dev/null
+++ b/Application/SetCurrentIdentity/index.php
@@ -0,0 +1,22 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/Private/SessionManager.php"; global $_PROFILE;
+header("Content-Type: application/json");
+
+$identities = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Identities.json"), true);
+
+if (!isset($_GET['Name']) || !isset($_GET['Picture'])) {
+ die();
+}
+
+function base64url_decode($data, $strict = false): string {
+ $b64 = strtr($data, '-_', '+/');
+ return base64_decode($b64, $strict);
+}
+
+$identities[$_PROFILE["id"]]["name"] = base64url_decode($_GET['Name']);
+$identities[$_PROFILE["id"]]["picture"] = base64url_decode($_GET['Picture']);
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Identities.json", json_encode($identities, JSON_PRETTY_PRINT));
+
+die(); \ No newline at end of file
diff --git a/Application/SetDefaultIdentity/index.php b/Application/SetDefaultIdentity/index.php
new file mode 100644
index 0000000..d35eb6a
--- /dev/null
+++ b/Application/SetDefaultIdentity/index.php
@@ -0,0 +1,13 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/Private/SessionManager.php"; global $_PROFILE;
+header("Content-Type: application/json");
+
+$identities = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Identities.json"), true);
+
+$identities[$_PROFILE["id"]]["name"] = $_PROFILE["name"];
+$identities[$_PROFILE["id"]]["picture"] = "https://privateauth.equestria.dev/hub/api/rest/avatar/" . $_PROFILE['id'] . "?dpr=2&size=64";
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/Private/Data/Identities.json", json_encode($identities, JSON_PRETTY_PRINT));
+
+die(); \ No newline at end of file
diff --git a/Application/TransactionsList/index.php b/Application/TransactionsList/index.php
index 64d2d2a..d4c5691 100644
--- a/Application/TransactionsList/index.php
+++ b/Application/TransactionsList/index.php
@@ -44,8 +44,8 @@ foreach ($list as $id) {
$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"
+ "name" => $item["name"] ?? $users[$item["author"]] ?? $item["author"],
+ "avatar" => $item["picture"] ?? "https://privateauth.equestria.dev/hub/api/rest/avatar/" . $item["author"] . "?dpr=2&size=48"
];
$item["date"] = [
"absolute" => $item["date"],