Browse Source

php - add a login failure message

master
kanoi 10 years ago
parent
commit
7283af34e5
  1. 22
      pool/base.php
  2. 4
      pool/page.php
  3. 3
      pool/prime.php

22
pool/base.php

@ -334,7 +334,9 @@ function validUserPass($user, $pass)
$key = 'ckp'.rand(1000000,9999999); $key = 'ckp'.rand(1000000,9999999);
$_SESSION['ckpkey'] = $key; $_SESSION['ckpkey'] = $key;
$_SESSION[$key] = array('who' => $user, 'id' => $user); $_SESSION[$key] = array('who' => $user, 'id' => $user);
return true;
} }
return false;
} }
# #
function logout() function logout()
@ -364,6 +366,8 @@ function requestRegister()
# #
function tryLogInOut() function tryLogInOut()
{ {
global $loginfailed;
// If already logged in, it will ignore User/Pass // If already logged in, it will ignore User/Pass
if (isset($_SESSION['ckpkey'])) if (isset($_SESSION['ckpkey']))
{ {
@ -373,21 +377,29 @@ function tryLogInOut()
} }
else else
{ {
$login = getparam('Login', false);
if (nuem($login))
return;
$user = getparam('User', false); $user = getparam('User', false);
if ($user !== NULL) if ($user !== NULL)
$user = loginStr($user); $user = loginStr($user);
if (nuem($user)) if (nuem($user))
{
$loginfailed = true;
return; return;
}
$pass = getparam('Pass', false); $pass = getparam('Pass', false);
if (nuem($pass)) if (nuem($pass))
{
$loginfailed = true;
return; return;
}
$login = getparam('Login', false); $valid = validUserPass($user, $pass);
if (nuem($login)) if (!$valid)
return; $loginfailed = true;
validUserPass($user, $pass);
} }
} }
# #

4
pool/page.php

@ -163,7 +163,7 @@ h1 {margin-top: 20px; float:middle; font-size: 20px;}
# #
function pgtop($info, $dotop, $user, $douser) function pgtop($info, $dotop, $user, $douser)
{ {
global $site_title; global $site_title, $loginfailed;
$phr = '?THs'; $phr = '?THs';
$plb = '?'; $plb = '?';
@ -288,6 +288,8 @@ function pgtop($info, $dotop, $user, $douser)
$top .= " You need to enable javascript to use"; $top .= " You need to enable javascript to use";
$top .= " the $site_title web site.</div>"; $top .= " the $site_title web site.</div>";
if ($loginfailed === true)
$top .= '<div class=accwarn>Login Failed</div>';
if (isset($info['u_nopayaddr'])) if (isset($info['u_nopayaddr']))
$top .= '<div class=accwarn>Please set a payout address on your account!</div>'; $top .= '<div class=accwarn>Please set a payout address on your account!</div>';
if (isset($info['u_noemail'])) if (isset($info['u_noemail']))

3
pool/prime.php

@ -3,6 +3,9 @@
global $stt; global $stt;
$stt = microtime(); $stt = microtime();
# #
global $loginfailed;
$loginfailed = false;
#
include_once('param.php'); include_once('param.php');
include_once('base.php'); include_once('base.php');
# #

Loading…
Cancel
Save