Added last login time/ip address popup on login w/ close button
Info/blue if your ip matches, warning/yellow if not
This commit is contained in:
parent
3efe979ae3
commit
74dec2796d
@ -43,6 +43,9 @@ class User extends Base {
|
|||||||
public function getUserIp($id) {
|
public function getUserIp($id) {
|
||||||
return $this->getSingle($id, 'loggedIp', 'id');
|
return $this->getSingle($id, 'loggedIp', 'id');
|
||||||
}
|
}
|
||||||
|
public function getLastLogin($id) {
|
||||||
|
return $this->getSingle($id, 'last_login', 'id');
|
||||||
|
}
|
||||||
public function getEmail($email) {
|
public function getEmail($email) {
|
||||||
return $this->getSingle($email, 'email', 'email', 's');
|
return $this->getSingle($email, 'email', 'email', 's');
|
||||||
}
|
}
|
||||||
@ -138,9 +141,13 @@ class User extends Base {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($this->checkUserPassword($username, $password)) {
|
if ($this->checkUserPassword($username, $password)) {
|
||||||
$this->updateLoginTimestamp($this->getUserId($username));
|
$uid = $this->getUserId($username);
|
||||||
$this->createSession($username);
|
$this->updateLoginTimestamp($uid);
|
||||||
if ($this->setUserIp($this->getUserId($username), $_SERVER['REMOTE_ADDR'])) {
|
$getIPAddress = $this->getUserIp($uid);
|
||||||
|
$setIPAddress = $this->setUserIp($uid, $_SERVER['REMOTE_ADDR']);
|
||||||
|
$lastLoginTime = $this->getLastLogin($uid);
|
||||||
|
$this->createSession($username, $getIPAddress, $lastLoginTime);
|
||||||
|
if ($setIPAddress) {
|
||||||
// send a notification if success_login is active
|
// send a notification if success_login is active
|
||||||
$uid = $this->getUserId($username);
|
$uid = $this->getUserId($username);
|
||||||
$notifs = new Notification();
|
$notifs = new Notification();
|
||||||
@ -490,9 +497,12 @@ class User extends Base {
|
|||||||
* @param username string Username to create session for
|
* @param username string Username to create session for
|
||||||
* @return none
|
* @return none
|
||||||
**/
|
**/
|
||||||
private function createSession($username) {
|
private function createSession($username, $lastIP='', $lastLoginTime='') {
|
||||||
$this->debug->append("STA " . __METHOD__, 4);
|
$this->debug->append("STA " . __METHOD__, 4);
|
||||||
$this->debug->append("Log in user to _SESSION", 2);
|
$this->debug->append("Log in user to _SESSION", 2);
|
||||||
|
if (!empty($lastIP) && (!empty($lastLoginTime))) {
|
||||||
|
$_SESSION['last_ip_pop'] = array($lastIP, $lastLoginTime);
|
||||||
|
}
|
||||||
if ($this->config['strict'] && $this->config['memcache']['enabled']) {
|
if ($this->config['strict'] && $this->config['memcache']['enabled']) {
|
||||||
session_regenerate_id(true);
|
session_regenerate_id(true);
|
||||||
$_SESSION['AUTHENTICATED'] = '1';
|
$_SESSION['AUTHENTICATED'] = '1';
|
||||||
|
|||||||
@ -128,6 +128,20 @@ if ($config['memcache']['enabled'] && ($config['mc_antidos']['enabled'] || $conf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Got past rate limiter and session manager, show last logged in popup if it's still set
|
||||||
|
if (@$_GET['clp'] == 1 && @$_SESSION['last_ip_pop']) unset($_SESSION['last_ip_pop']);
|
||||||
|
if (count(@$_SESSION['last_ip_pop']) == 2) {
|
||||||
|
$data = $_SESSION['last_ip_pop'];
|
||||||
|
$ip = filter_var($data[0], FILTER_VALIDATE_IP);
|
||||||
|
$time = date("l, F jS \a\\t g:i a", $data[1]);
|
||||||
|
$closelink = "<a href='index.php?page=dashboard&clp=1' style='float:right;padding-right:14px;'>Close</a>";
|
||||||
|
if (@$_SESSION['AUTHENTICATED'] && $_SESSION['last_ip_pop'][0] !== $_SERVER['REMOTE_ADDR']) {
|
||||||
|
$_SESSION['POPUP'][] = array('CONTENT' => "You last logged in from <b>$ip</b> on $time $closelink", 'TYPE' => 'warning');
|
||||||
|
} else {
|
||||||
|
$_SESSION['POPUP'][] = array('CONTENT' => "You last logged in from <b>$ip</b> on $time $closelink", 'TYPE' => 'info');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Quick config check
|
// Quick config check
|
||||||
if (@$_SESSION['USERDATA']['is_admin'] && !@$config['skip_config_tests']) {
|
if (@$_SESSION['USERDATA']['is_admin'] && !@$config['skip_config_tests']) {
|
||||||
require_once(INCLUDE_DIR. '/admin_checks.php');
|
require_once(INCLUDE_DIR. '/admin_checks.php');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user