Return to page if mod clicked on a link to a moderator page but was not logged in
This commit is contained in:
parent
8d6c3d655d
commit
a655d930d0
|
@ -37,7 +37,7 @@
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function loginForm($error=false, $username=false) {
|
function loginForm($error=false, $username=false, $redirect=false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if(function_exists('sql_close')) sql_close();
|
if(function_exists('sql_close')) sql_close();
|
||||||
|
@ -47,7 +47,8 @@
|
||||||
'body'=>Element('login.html', Array(
|
'body'=>Element('login.html', Array(
|
||||||
'index'=>$config['root'],
|
'index'=>$config['root'],
|
||||||
'error'=>$error,
|
'error'=>$error,
|
||||||
'username'=>$username
|
'username'=>$username,
|
||||||
|
'redirect'=>$redirect
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
|
|
13
mod.php
13
mod.php
|
@ -25,6 +25,8 @@
|
||||||
$_POST = strip_array($_POST);
|
$_POST = strip_array($_POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
|
||||||
|
|
||||||
// If not logged in
|
// If not logged in
|
||||||
if(!$mod) {
|
if(!$mod) {
|
||||||
if(isset($_POST['login'])) {
|
if(isset($_POST['login'])) {
|
||||||
|
@ -33,11 +35,11 @@
|
||||||
!isset($_POST['password']) ||
|
!isset($_POST['password']) ||
|
||||||
empty($_POST['username']) ||
|
empty($_POST['username']) ||
|
||||||
empty($_POST['password'])
|
empty($_POST['password'])
|
||||||
) loginForm($config['error']['invalid'], $_POST['username']);
|
) loginForm($config['error']['invalid'], $_POST['username'], '?' . $query);
|
||||||
|
|
||||||
|
|
||||||
if(!login($_POST['username'], $_POST['password']))
|
if(!login($_POST['username'], $_POST['password']))
|
||||||
loginForm($config['error']['invalid'], $_POST['username']);
|
loginForm($config['error']['invalid'], $_POST['username'], '?' . $query);
|
||||||
|
|
||||||
modLog("Logged in.");
|
modLog("Logged in.");
|
||||||
|
|
||||||
|
@ -46,16 +48,17 @@
|
||||||
setCookies();
|
setCookies();
|
||||||
|
|
||||||
// Redirect
|
// Redirect
|
||||||
|
if(isset($_POST['redirect']))
|
||||||
|
header('Location: ' . $_POST['redirect'], true, $config['redirect_http']);
|
||||||
|
else
|
||||||
header('Location: ?' . $config['mod']['default'], true, $config['redirect_http']);
|
header('Location: ?' . $config['mod']['default'], true, $config['redirect_http']);
|
||||||
|
|
||||||
// Close connection
|
// Close connection
|
||||||
sql_close();
|
sql_close();
|
||||||
} else {
|
} else {
|
||||||
loginForm();
|
loginForm(false, false, '?' . $query);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
|
|
||||||
|
|
||||||
// A sort of "cache"
|
// A sort of "cache"
|
||||||
// Stops calling preg_quote and str_replace when not needed; only does it once
|
// Stops calling preg_quote and str_replace when not needed; only does it once
|
||||||
$regex = Array(
|
$regex = Array(
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<center>
|
<center>
|
||||||
{error?<h2>{error}</h2>}
|
{error?<h2>{error}</h2>}
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
|
{redirect?<input type="hidden" name="redirect" value="{redirect}" />}
|
||||||
<table style="margin-top:25px;">
|
<table style="margin-top:25px;">
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
|
|
Loading…
Reference in New Issue