- New "admin dashboard" /admin page + login, #494

- New ESI scope for admin access
- New admin.log file for admin actions (kick, ban,..)
- New login status for characters
- improved cronJob exec time for systemData import (jump/kill data)
- Added PHP 64-bit check to /setup
This commit is contained in:
Exodus4D
2017-05-27 14:09:12 +02:00
parent cc4de64673
commit 5be1d3547a
44 changed files with 1428 additions and 437 deletions

View File

@@ -17,13 +17,14 @@ class AccessController extends Controller {
/**
* event handler
* @param \Base $f3
* @param array $params
*/
function beforeroute(\Base $f3) {
parent::beforeroute($f3);
function beforeroute(\Base $f3, $params) {
parent::beforeroute($f3, $params);
// Any route/endpoint of a child class of this one,
// requires a valid logged in user!
$loginCheck = $this->checkLogTimer($f3);
$loginCheck = $this->isLoggedIn($f3);
if( !$loginCheck ){
// no user found or login timer expired
@@ -34,7 +35,7 @@ class AccessController extends Controller {
$f3->status(403);
}else{
// redirect to landing page
$f3->reroute('@login');
$f3->reroute(['login']);
}
// die() triggers unload() function
@@ -42,6 +43,55 @@ class AccessController extends Controller {
}
}
/**
* get current character and check if it is a valid character
* @param \Base $f3
* @return bool
*/
protected function isLoggedIn(\Base $f3){
$loginCheck = false;
if( $character = $this->getCharacter() ){
if($this->checkLogTimer($f3, $character)){
if($character->isAuthorized() === 'OK'){
$loginCheck = true;
}
}
}
return $loginCheck;
}
/**
* checks whether a user/character is currently logged in
* @param \Base $f3
* @param Model\CharacterModel $character
* @return bool
*/
private function checkLogTimer(\Base $f3, Model\CharacterModel $character){
$loginCheck = false;
if(
!$character->dry() &&
$character->lastLogin
){
// check logIn time
$logInTime = new \DateTime($character->lastLogin);
$now = new \DateTime();
$timeDiff = $now->diff($logInTime);
$minutes = $timeDiff->days * 60 * 24 * 60;
$minutes += $timeDiff->h * 60;
$minutes += $timeDiff->i;
if($minutes <= $f3->get('PATHFINDER.TIMER.LOGGED')){
$loginCheck = true;
}
}
return $loginCheck;
}
/**
* broadcast map data to clients
* -> send over TCP Socket