Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
feat: add danish translation
Miguel Ribeiro0cfefc7f0705
diff --git a/endpoints/notifications/testgotifynotifications.php b/endpoints/notifications/testgotifynotifications.phpindex 16f6d03..dfab43f 100644--- a/endpoints/notifications/testgotifynotifications.php+++ b/endpoints/notifications/testgotifynotifications.php@@ -50,20 +50,24 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {// Execute the request$response = curl_exec($ch);+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);// Close the cURL sessioncurl_close($ch);// Check if the message was sent successfully- if ($response === false) {+ if ($response === false || $httpCode < 200 || $httpCode >= 300) {die(json_encode(["success" => false,- "message" => translate('notification_failed', $i18n)+ "message" => translate('notification_failed', $i18n),+ "response" => $response,+ "http_code" => $httpCode]));} else {die(json_encode(["success" => true,- "message" => translate('notification_sent_successfuly', $i18n)+ "message" => translate('notification_sent_successfuly', $i18n),+ "response" => $response]));}}diff --git a/endpoints/payments/add.php b/endpoints/payments/add.phpindex e1dce09..57b99c6 100644--- a/endpoints/payments/add.php+++ b/endpoints/payments/add.php@@ -25,9 +25,31 @@ function validateFileExtension($fileExtension)function getLogoFromUrl($url, $uploadDir, $name, $i18n, $settings){+ if (!filter_var($url, FILTER_VALIDATE_URL) || !preg_match('/^https?:\/\//i', $url)) {+ $response = [+ "success" => false,+ "errorMessage" => "Invalid URL format."+ ];+ echo json_encode($response);+ exit();+ }++ $host = parse_url($url, PHP_URL_HOST);+ $ip = gethostbyname($host);+ if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) === false) {+ $response = [+ "success" => false,+ "errorMessage" => "Invalid IP Address."+ ];+ echo json_encode($response);+ exit();+ }$ch = curl_init($url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);+ curl_setopt($ch, CURLOPT_MAXREDIRS, 3);$imageData = curl_exec($ch);@@ -51,6 +73,7 @@ function getLogoFromUrl($url, $uploadDir, $name, $i18n, $settings)}}+function saveLogo($imageData, $uploadFile, $name, $settings){$image = imagecreatefromstring($imageData);diff --git a/endpoints/subscription/add.php b/endpoints/subscription/add.phpindex 348ac81..790f92d 100644--- a/endpoints/subscription/add.php+++ b/endpoints/subscription/add.php@@ -25,9 +25,31 @@ function validateFileExtension($fileExtension)function getLogoFromUrl($url, $uploadDir, $name, $settings, $i18n){+ if (!filter_var($url, FILTER_VALIDATE_URL) || !preg_match('/^https?:\/\//i', $url)) {+ $response = [+ "success" => false,+ "errorMessage" => "Invalid URL format."+ ];+ echo json_encode($response);+ exit();+ }++ $host = parse_url($url, PHP_URL_HOST);+ $ip = gethostbyname($host);+ if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) === false) {+ $response = [+ "success" => false,+ "errorMessage" => "Invalid IP Address."+ ];+ echo json_encode($response);+ exit();+ }$ch = curl_init($url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);+ curl_setopt($ch, CURLOPT_MAXREDIRS, 3);$imageData = curl_exec($ch);@@ -41,17 +63,19 @@ function getLogoFromUrl($url, $uploadDir, $name, $settings, $i18n)curl_close($ch);return $fileName;} else {- curl_close($ch);echo translate('error_fetching_image', $i18n) . ": " . curl_error($ch);+ curl_close($ch);return "";}} else {echo translate('error_fetching_image', $i18n) . ": " . curl_error($ch);+ curl_close($ch);return "";}}+function saveLogo($imageData, $uploadFile, $name, $settings){$image = imagecreatefromstring($imageData);diff --git a/endpoints/user/disable_totp.php b/endpoints/user/disable_totp.phpindex a376bd7..ecdaa55 100644--- a/endpoints/user/disable_totp.php+++ b/endpoints/user/disable_totp.php@@ -86,12 +86,24 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {]));} else {// Compare the TOTP code agains the backup codes+ // Normalize TOTP input+ $totp_code = strtolower(trim((string) $totp_code));++ // Decode and normalize backup codes$backupCodes = json_decode($backupCodes, true);- if (($key = array_search($totp_code, $backupCodes)) !== false) {- unset($backupCodes[$key]);- $statement = $db->prepare('UPDATE totp SET backup_codes = :backup_codes WHERE user_id = :id');+ $normalizedBackupCodes = array_map(function ($code) {+ return strtolower(trim((string) $code));+ }, $backupCodes);++ // Search for the normalized code+ if (($key = array_search($totp_code, $normalizedBackupCodes)) !== false) {+ // Match found, disable TOTP+ $statement = $db->prepare('UPDATE user SET totp_enabled = 0 WHERE id = :id');+ $statement->bindValue(':id', $userId, SQLITE3_INTEGER);+ $statement->execute();++ $statement = $db->prepare('DELETE FROM totp WHERE user_id = :id');$statement->bindValue(':id', $userId, SQLITE3_INTEGER);- $statement->bindValue(':backup_codes', json_encode($backupCodes), SQLITE3_TEXT);$statement->execute();die(json_encode([@@ -106,6 +118,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {"reload" => false]));}+}} else {diff --git a/includes/version.php b/includes/version.phpindex bfbd750..ce9106e 100644--- a/includes/version.php+++ b/includes/version.php@@ -1,3 +1,3 @@<?php-$version = "v3.0.2";+$version = "v3.1.0";?>\ No newline at end of file