Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

feat: enable deployment in subdirectory

Jadeiine2af9afc32bf
diff --git a/endpoints/user/save_user.php b/endpoints/user/save_user.php
index 07c63f1..94a47bf 100644
--- a/endpoints/user/save_user.php
+++ b/endpoints/user/save_user.php
@@ -125,7 +125,9 @@
if ($result) {
$cookieExpire = time() + (30 * 24 * 60 * 60);
$oldLanguage = isset($_COOKIE['language']) ? $_COOKIE['language'] : "en";
- setcookie('language', $language, $cookieExpire, '/');
+ $root = str_replace('/endpoints/user', '', dirname($_SERVER['PHP_SELF']));
+ $root = $root == '' ? '/' : $root;
+ setcookie('language', $language, $cookieExpire, $root);
if ($username != $oldUsername) {
$_SESSION['username'] = $username;
if (isset($_COOKIE['wallos_login'])) {
@@ -166,4 +168,4 @@
echo json_encode($response);
exit();
}
-?>
\ No newline at end of file
+?>
diff --git a/images/icon/site.webmanifest b/images/icon/site.webmanifest
index 3087a36..0b5a830 100644
--- a/images/icon/site.webmanifest
+++ b/images/icon/site.webmanifest
@@ -1 +1 @@
-{"name":"","short_name":"","icons":[{"src":"/images/icon/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/images/icon/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
\ No newline at end of file
+{"name":"","short_name":"","icons":[{"src":"android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
diff --git a/includes/header.php b/includes/header.php
index 4218b42..0a9f7e5 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -47,7 +47,7 @@
<header>
<div class="contain">
<div class="logo">
- <a href="/">
+ <a href=".">
<div class="logo-image"></div>
</a>
</div>
@@ -58,7 +58,7 @@
<span id="user"><?= $username ?></span>
</button>
<div class="dropdown-content">
- <a href="/"><i class="fa-solid fa-list"></i><?= translate('subscriptions', $i18n) ?></a>
+ <a href="."><i class="fa-solid fa-list"></i><?= translate('subscriptions', $i18n) ?></a>
<a href="stats.php"><i class="fa-solid fa-chart-simple"></i><?= translate('stats', $i18n) ?></a>
<a href="settings.php"><i class="fa-solid fa-gear"></i><?= translate('settings', $i18n) ?></a>
<a href="about.php"><i class="fa-solid fa-info-circle"></i><?= translate('about', $i18n) ?></a>
diff --git a/login.php b/login.php
index 6cf2a92..7f0a5a8 100644
--- a/login.php
+++ b/login.php
@@ -16,7 +16,7 @@ if ($userCount == 0) {
session_start();
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
$db->close();
- header("Location: /");
+ header("Location: .");
exit();
}
@@ -47,7 +47,7 @@ if (isset($_POST['username']) && isset($_POST['password'])) {
$_SESSION['loggedin'] = true;
$_SESSION['main_currency'] = $main_currency;
$cookieExpire = time() + (30 * 24 * 60 * 60);
- setcookie('language', $language, $cookieExpire, '/');
+ setcookie('language', $language, $cookieExpire);
if ($rememberMe) {
$token = bin2hex(random_bytes(32));
$addLoginTokens = "INSERT INTO login_tokens (user_id, token) VALUES (?, ?)";
@@ -57,10 +57,10 @@ if (isset($_POST['username']) && isset($_POST['password'])) {
$addLoginTokensStmt->execute();
$_SESSION['token'] = $token;
$cookieValue = $username . "|" . $token . "|" . $main_currency;
- setcookie('wallos_login', $cookieValue, $cookieExpire, '/');
+ setcookie('wallos_login', $cookieValue, $cookieExpire);
}
$db->close();
- header("Location: /");
+ header("Location: .");
exit();
} else {
$loginFailed = true;
diff --git a/logout.php b/logout.php
index 4e2fc5f..700b087 100644
--- a/logout.php
+++ b/logout.php
@@ -12,8 +12,8 @@
$_SESSION = array();
session_destroy();
$cookieExpire = time() - 3600;
- setcookie('wallos_login', '', $cookieExpire, '/');
+ setcookie('wallos_login', '', $cookieExpire);
$db->close();
- header("Location: /");
+ header("Location: .");
exit();
?>
\ No newline at end of file
diff --git a/scripts/dashboard.js b/scripts/dashboard.js
index cf08b08..6ee6d70 100644
--- a/scripts/dashboard.js
+++ b/scripts/dashboard.js
@@ -266,7 +266,7 @@ function setSortOption(sortOption) {
const daysToExpire = 30;
const expirationDate = new Date();
expirationDate.setDate(expirationDate.getDate() + daysToExpire);
- const cookieValue = encodeURIComponent(sortOption) + '; expires=' + expirationDate.toUTCString() + '; path=/';
+ const cookieValue = encodeURIComponent(sortOption) + '; expires=' + expirationDate.toUTCString();
document.cookie = 'sortOrder=' + cookieValue;
fetchSubscriptions();
toggleSortOptions();
@@ -314,4 +314,4 @@ document.addEventListener('DOMContentLoaded', function() {
document.querySelector('#sort-options').addEventListener('focus', function() {
isSortOptionsOpen = true;
});
-});
\ No newline at end of file
+});
diff --git a/scripts/registration.js b/scripts/registration.js
index 5bd231a..90fc8e6 100644
--- a/scripts/registration.js
+++ b/scripts/registration.js
@@ -5,7 +5,7 @@ function setCookie(name, value, days) {
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
- document.cookie = name + "=" + value + expires + "; path=/";
+ document.cookie = name + "=" + value + expires;
}
function storeFormFieldValue(fieldId) {
@@ -66,4 +66,4 @@ window.onload = function () {
restoreFormFields();
removeFromStorage();
runDatabaseMigration();
-};
\ No newline at end of file
+};
diff --git a/scripts/settings.js b/scripts/settings.js
index c0bc291..a09ca56 100644
--- a/scripts/settings.js
+++ b/scripts/settings.js
@@ -522,7 +522,7 @@ function saveNotificationsButton() {
fromemail: fromEmail
};
- fetch('/endpoints/notifications/save.php', {
+ fetch('endpoints/notifications/save.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -562,7 +562,7 @@ function testNotificationButton() {
fromemail: fromEmail
};
- fetch('/endpoints/notifications/sendtestmail.php', {
+ fetch('endpoints/notifications/sendtestmail.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -589,27 +589,27 @@ function switchTheme() {
darkThemeCss.disabled = !darkThemeCss.disabled;
const themeChoice = darkThemeCss.disabled ? 'light' : 'dark';
- document.cookie = `theme=${themeChoice}; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/`;
+ document.cookie = `theme=${themeChoice}; expires=Fri, 31 Dec 9999 23:59:59 GMT`;
}
function setShowMonthlyPriceCookie() {
const showMonthlyPriceCheckbox = document.querySelector("#monthlyprice");
const value = showMonthlyPriceCheckbox.checked;
- document.cookie = `showMonthlyPrice=${value}; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/`;
+ document.cookie = `showMonthlyPrice=${value}; expires=Fri, 31 Dec 9999 23:59:59 GMT`;
}
function setConvertCurrencyCookie() {
const convertCurrencyCheckbox = document.querySelector("#convertcurrency");
const value = convertCurrencyCheckbox.checked;
- document.cookie = `convertCurrency=${value}; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/`;
+ document.cookie = `convertCurrency=${value}; expires=Fri, 31 Dec 9999 23:59:59 GMT`;
}
function setRemoveBackgroundCookie() {
const removeBackgroundCheckbox = document.querySelector("#removebackground");
const value = removeBackgroundCheckbox.checked;
- document.cookie = `removeBackground=${value}; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/`;
+ document.cookie = `removeBackground=${value}; expires=Fri, 31 Dec 9999 23:59:59 GMT`;
}
function exportToJson() {
window.location.href = "endpoints/subscriptions/export.php";
-}
\ No newline at end of file
+}