From 11c9c5502e50a15230c5395262b0132daa3fefbb Mon Sep 17 00:00:00 2001
From: Michael Erdely
Date: Fri, 18 Oct 2024 23:52:01 -0400
Subject: [PATCH] pass query string and from page to login page to the
bookmarklet works properly when not logged in
---
src/item.php | 2 +-
src/login.php | 17 +++++++++++++----
src/templates/help.tpl | 1 +
src/templates/login.tpl | 2 +-
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/item.php b/src/item.php
index 524373c..14f3018 100644
--- a/src/item.php
+++ b/src/item.php
@@ -20,7 +20,7 @@ $opt = $smarty->opt();
session_start();
if (!isset($_SESSION["userid"])) {
- header("Location: " . getFullPath("login.php") . "?from=item.php");
+ header("Location: " . getFullPath("login.php") . "?from=item.php&querystring=" . urlencode($_SERVER['QUERY_STRING']));
exit;
}
else {
diff --git a/src/login.php b/src/login.php
index b691c67..282eb99 100644
--- a/src/login.php
+++ b/src/login.php
@@ -31,8 +31,14 @@ if (isset($_GET["action"])) {
if (isset($_GET["from"])) {
$from = filter_var(trim($_GET["from"], FILTER_SANITIZE_STRING));;
$from = htmlspecialchars($from, ENT_QUOTES, 'UTF-8');
+} else {
+ $from = "";
+}
+
+if (isset($_GET["querystring"])) {
+ $querystring = trim($_GET["querystring"]);
} else
- $from = "";
+ $querystring = "";
if (!empty($_POST["username"])) {
$username = filter_var(strtolower(trim($_REQUEST["username"])), FILTER_SANITIZE_STRING);
@@ -53,10 +59,11 @@ if (!empty($_POST["username"])) {
$_SESSION["show_helptext"] = $row["show_helptext"];
$opt['show_helptext'] = $row["show_helptext"];
- if (in_array($from, $pages))
- header("Location: " . getFullPath($from));
- else
+ if (in_array($from, $pages)) {
+ header("Location: " . getFullPath($from) . "?" . urldecode($querystring));
+ } else {
header("Location: " . getFullPath("index.php"));
+ }
exit;
}
}
@@ -65,11 +72,13 @@ if (!empty($_POST["username"])) {
}
$smarty->assign('from', $from);
+ $smarty->assign('querystring', urlencode($querystring));
$smarty->assign('username', $username);
$smarty->display('login.tpl');
}
else {
$smarty->assign('from', $from);
+ $smarty->assign('querystring', urlencode($querystring));
$smarty->display('login.tpl');
}
?>
diff --git a/src/templates/help.tpl b/src/templates/help.tpl
index c0d3ae8..98b49cc 100644
--- a/src/templates/help.tpl
+++ b/src/templates/help.tpl
@@ -65,6 +65,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
}
appURL += '&bookmarklet=1';
+ appURL += '&wishlist=1';
window.open(appURL);
})();
">🎁 Add to Wishlist
diff --git a/src/templates/login.tpl b/src/templates/login.tpl
index 3a72898..1862634 100644
--- a/src/templates/login.tpl
+++ b/src/templates/login.tpl
@@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA