- #84, #138 improved "character selection" on login page (expired cookies are deleted, character panel layout improvements)
- added new "Server info panel" to the login page - added new cronjob to delete expired cookie authentication data
This commit is contained in:
@@ -17,8 +17,11 @@ importSystemData = Cron\CcpSystemsUpdate->importSystemData, @hourly
|
||||
; disable outdated maps
|
||||
deactivateMapData = Cron\MapUpdate->deactivateMapData, @hourly
|
||||
|
||||
; delete character log data
|
||||
deleteLogData = Cron\CharacterUpdate->deleteLogData, @hourly
|
||||
|
||||
; delete disabled maps
|
||||
deleteMapData = Cron\MapUpdate->deleteMapData, @downtime
|
||||
|
||||
; delete character log data
|
||||
deleteLogData = Cron\CharacterUpdate->deleteLogData, @hourly
|
||||
; delete expired character cookie authentication data
|
||||
deleteAuthenticationData = Cron\CharacterUpdate->deleteAuthenticationData, @downtime
|
||||
@@ -48,7 +48,7 @@ class AppController extends Controller {
|
||||
// characters from cookies
|
||||
$f3->set('cookieCharacters', $this->getCookieByName(self::COOKIE_PREFIX_CHARACTER, true));
|
||||
$f3->set('getCharacterGrid', function($characters){
|
||||
return ( ((12 / count($characters)) <= 4) ? 4 : (12 / count($characters)) );
|
||||
return ( ((12 / count($characters)) <= 3) ? 3 : (12 / count($characters)) );
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ class Sso extends Api\User{
|
||||
* @param array $additionalOptions
|
||||
* @return mixed|null
|
||||
*/
|
||||
protected function getEndpoints($accessToken, $additionalOptions = []){
|
||||
protected function getEndpoints($accessToken = '', $additionalOptions = []){
|
||||
$crestUrl = self::getCrestEndpoint();
|
||||
$additionalOptions['contentType'] = 'application/vnd.ccp.eve.Api-v3+json';
|
||||
$endpoint = $this->getEndpoint($accessToken, $crestUrl, $additionalOptions);
|
||||
@@ -645,6 +645,44 @@ class Sso extends Api\User{
|
||||
return $characterModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* get CREST server status (online/offline)
|
||||
* @return \stdClass object
|
||||
*/
|
||||
public function getCrestServerStatus(){
|
||||
$endpoints = $this->getEndpoints();
|
||||
|
||||
// set default status e.g. Endpoints don´t work
|
||||
$data = (object) [];
|
||||
$data->crestOffline = true;
|
||||
$data->serverName = 'EVE ONLINE';
|
||||
$data->serviceStatus = [
|
||||
'eve' => 'offline',
|
||||
'server' => 'offline',
|
||||
];
|
||||
$data->userCounts = [
|
||||
'eve' => 0
|
||||
];
|
||||
|
||||
$endpoint = $this->walkEndpoint('', $endpoints, ['serverName']);
|
||||
if( !empty($endpoint) ){
|
||||
$data->crestOffline = false;
|
||||
$data->serverName = (string) $endpoint;
|
||||
}
|
||||
$endpoint = $this->walkEndpoint('', $endpoints, ['serviceStatus']);
|
||||
if( !empty($endpoint) ){
|
||||
$data->crestOffline = false;
|
||||
$data->serviceStatus = (new Mapper\CrestServiceStatus($endpoint))->getData();
|
||||
}
|
||||
|
||||
$endpoint = $this->walkEndpoint('', $endpoints, ['userCounts']);
|
||||
if( !empty($endpoint) ){
|
||||
$data->crestOffline = false;
|
||||
$data->userCounts = (new Mapper\CrestUserCounts($endpoint))->getData();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* check response "Header" data for errors
|
||||
* @param $headers
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
namespace Controller;
|
||||
use Controller\Api as Api;
|
||||
use Controller\Ccp\Sso;
|
||||
use Model;
|
||||
use DB;
|
||||
|
||||
@@ -242,29 +243,34 @@ class Controller {
|
||||
|
||||
// validate expire data
|
||||
// validate token
|
||||
if(
|
||||
!$characterAuth->dry() &&
|
||||
strtotime($characterAuth->expires) >= $currentTime->getTimestamp() &&
|
||||
hash_equals($characterAuth->token, hash('sha256', $data[1]))
|
||||
){
|
||||
// cookie information is valid
|
||||
// -> try to update character information from CREST
|
||||
// e.g. Corp has changed, this also ensures valid "access_token"
|
||||
/**
|
||||
* @var $character Model\CharacterModel
|
||||
*/
|
||||
$character = $characterAuth->characterId;
|
||||
$updateStatus = $character->updateFromCrest();
|
||||
|
||||
// check if character still has user (is not the case of "ownerHash" changed
|
||||
// check if character is still authorized to log in (e.g. corp/ally or config has changed
|
||||
// -> do NOT remove cookie on failure. This can be a temporary problem (e.g. CREST is down,..)
|
||||
if( !$characterAuth->dry() ){
|
||||
if(
|
||||
empty($updateStatus) &&
|
||||
$character->hasUserCharacter() &&
|
||||
$character->isAuthorized()
|
||||
strtotime($characterAuth->expires) >= $currentTime->getTimestamp() &&
|
||||
hash_equals($characterAuth->token, hash('sha256', $data[1]))
|
||||
){
|
||||
$characters[$name] = $character;
|
||||
// cookie information is valid
|
||||
// -> try to update character information from CREST
|
||||
// e.g. Corp has changed, this also ensures valid "access_token"
|
||||
/**
|
||||
* @var $character Model\CharacterModel
|
||||
*/
|
||||
$character = $characterAuth->characterId;
|
||||
$updateStatus = $character->updateFromCrest();
|
||||
|
||||
// check if character still has user (is not the case of "ownerHash" changed
|
||||
// check if character is still authorized to log in (e.g. corp/ally or config has changed
|
||||
// -> do NOT remove cookie on failure. This can be a temporary problem (e.g. CREST is down,..)
|
||||
if(
|
||||
empty($updateStatus) &&
|
||||
$character->hasUserCharacter() &&
|
||||
$character->isAuthorized()
|
||||
){
|
||||
$characters[$name] = $character;
|
||||
}
|
||||
}else{
|
||||
// clear existing authentication data from DB
|
||||
$characterAuth->erase();
|
||||
$invalidCookie = true;
|
||||
}
|
||||
}else{
|
||||
$invalidCookie = true;
|
||||
@@ -371,6 +377,31 @@ class Controller {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get EVE server status from CREST
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function getEveServerStatus(\Base $f3){
|
||||
$return = (object) [];
|
||||
$return->error = [];
|
||||
|
||||
// server status can be cached for some seconds
|
||||
$cacheKey = 'eve_server_status';
|
||||
if( !$f3->exists($cacheKey) ){
|
||||
$sso = new Sso();
|
||||
$return->status = $sso->getCrestServerStatus();
|
||||
|
||||
if( !$return->status->crestOffline ){
|
||||
$f3->set($cacheKey, $return, 60);
|
||||
}
|
||||
}else{
|
||||
// get from cache
|
||||
$return = $f3->get($cacheKey);
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* check weather the page is IGB trusted or not
|
||||
* @return boolean
|
||||
|
||||
@@ -17,15 +17,17 @@ class CharacterUpdate {
|
||||
/**
|
||||
* delete all character log data
|
||||
* >> php index.php "/cron/deleteLogData"
|
||||
* @param $f3
|
||||
* @param \Base $f3
|
||||
*/
|
||||
function deleteLogData($f3){
|
||||
|
||||
DB\Database::instance()->getDB('PF');
|
||||
|
||||
/**
|
||||
* @var $characterLogModel Model\CharacterLogModel
|
||||
*/
|
||||
$characterLogModel = Model\BasicModel::getNew('CharacterLogModel', 0);
|
||||
|
||||
// find "old" character logs
|
||||
// find expired character logs
|
||||
$characterLogs = $characterLogModel->find([
|
||||
'TIMESTAMPDIFF(SECOND, updated, NOW() ) > :lifetime',
|
||||
':lifetime' => (int)$f3->get('PATHFINDER.CACHE.CHARACTER_LOG')
|
||||
@@ -33,10 +35,35 @@ class CharacterUpdate {
|
||||
|
||||
if(is_object($characterLogs)){
|
||||
foreach($characterLogs as $characterLog){
|
||||
// delete log and all cached values
|
||||
$characterLog->erase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete expired character authentication data
|
||||
* authentication data is used for cookie based login
|
||||
* >> php index.php "/cron/deleteAuthenticationData"
|
||||
* @param $f3
|
||||
*/
|
||||
function deleteAuthenticationData($f3){
|
||||
DB\Database::instance()->getDB('PF');
|
||||
|
||||
/**
|
||||
* @var $authenticationModel Model\CharacterAuthenticationModel
|
||||
*/
|
||||
$authenticationModel = Model\BasicModel::getNew('CharacterAuthenticationModel', 0);
|
||||
|
||||
// find expired authentication data
|
||||
$authentications = $authenticationModel->find([
|
||||
'(expires - NOW()) <= 0'
|
||||
]);
|
||||
|
||||
if(is_object($authentications)){
|
||||
foreach($authentications as $authentication){
|
||||
$authentication->erase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
19
app/main/data/mapper/crestservicestatus.php
Normal file
19
app/main/data/mapper/crestservicestatus.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exodus
|
||||
* Date: 01.05.2016
|
||||
* Time: 19:17
|
||||
*/
|
||||
|
||||
namespace Data\Mapper;
|
||||
|
||||
|
||||
class CrestServiceStatus extends AbstractIterator {
|
||||
|
||||
protected static $map = [
|
||||
'dust' => 'dust',
|
||||
'eve' => 'eve',
|
||||
'server' => 'server'
|
||||
];
|
||||
}
|
||||
18
app/main/data/mapper/crestusercounts.php
Normal file
18
app/main/data/mapper/crestusercounts.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exodus
|
||||
* Date: 01.05.2016
|
||||
* Time: 19:42
|
||||
*/
|
||||
|
||||
namespace Data\Mapper;
|
||||
|
||||
|
||||
class CrestUserCounts extends AbstractIterator {
|
||||
|
||||
protected static $map = [
|
||||
'dust' => 'dust',
|
||||
'eve' => 'eve'
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user