pass query string and from page to login page to the bookmarklet works properly when not logged in

This commit is contained in:
Michael Erdely 2024-10-18 23:52:01 -04:00
parent 1b02ad896d
commit 11c9c5502e
4 changed files with 16 additions and 6 deletions

View file

@ -20,7 +20,7 @@ $opt = $smarty->opt();
session_start(); session_start();
if (!isset($_SESSION["userid"])) { 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; exit;
} }
else { else {

View file

@ -31,8 +31,14 @@ if (isset($_GET["action"])) {
if (isset($_GET["from"])) { if (isset($_GET["from"])) {
$from = filter_var(trim($_GET["from"], FILTER_SANITIZE_STRING));; $from = filter_var(trim($_GET["from"], FILTER_SANITIZE_STRING));;
$from = htmlspecialchars($from, ENT_QUOTES, 'UTF-8'); $from = htmlspecialchars($from, ENT_QUOTES, 'UTF-8');
} else {
$from = "";
}
if (isset($_GET["querystring"])) {
$querystring = trim($_GET["querystring"]);
} else } else
$from = ""; $querystring = "";
if (!empty($_POST["username"])) { if (!empty($_POST["username"])) {
$username = filter_var(strtolower(trim($_REQUEST["username"])), FILTER_SANITIZE_STRING); $username = filter_var(strtolower(trim($_REQUEST["username"])), FILTER_SANITIZE_STRING);
@ -53,10 +59,11 @@ if (!empty($_POST["username"])) {
$_SESSION["show_helptext"] = $row["show_helptext"]; $_SESSION["show_helptext"] = $row["show_helptext"];
$opt['show_helptext'] = $row["show_helptext"]; $opt['show_helptext'] = $row["show_helptext"];
if (in_array($from, $pages)) if (in_array($from, $pages)) {
header("Location: " . getFullPath($from)); header("Location: " . getFullPath($from) . "?" . urldecode($querystring));
else } else {
header("Location: " . getFullPath("index.php")); header("Location: " . getFullPath("index.php"));
}
exit; exit;
} }
} }
@ -65,11 +72,13 @@ if (!empty($_POST["username"])) {
} }
$smarty->assign('from', $from); $smarty->assign('from', $from);
$smarty->assign('querystring', urlencode($querystring));
$smarty->assign('username', $username); $smarty->assign('username', $username);
$smarty->display('login.tpl'); $smarty->display('login.tpl');
} }
else { else {
$smarty->assign('from', $from); $smarty->assign('from', $from);
$smarty->assign('querystring', urlencode($querystring));
$smarty->display('login.tpl'); $smarty->display('login.tpl');
} }
?> ?>

View file

@ -65,6 +65,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
} }
} }
appURL += '&bookmarklet=1'; appURL += '&bookmarklet=1';
appURL += '&wishlist=1';
window.open(appURL); window.open(appURL);
})(); })();
">🎁 Add to Wishlist</a></p> ">🎁 Add to Wishlist</a></p>

View file

@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-sm" style="max-width: 500px;"> <div class="col-sm" style="max-width: 500px;">
<div class="card mt-3"> <div class="card mt-3">
<form name="loginform" id="loginform" method="post" action="login.php{if isset($from)}?from={$from}{/if}" class="well form-horizontal"> <form name="loginform" id="loginform" method="post" action="login.php{if isset($from)}?from={$from}{if isset($querystring)}&querystring={$querystring}{/if}{/if}" class="well form-horizontal">
<div class="card-header"><h1>Gift Registry</h1></div> <div class="card-header"><h1>Gift Registry</h1></div>
<div class="card-body"> <div class="card-body">
{if isset($username)} {if isset($username)}