- added custom/editable ship jump logs, #709

- fixed DB setup error: "`system`.`description` can´t have a default value", closed #701
- upgraded "lazyload" js lib `v1.9.5` → `v1.9.7`
- upgraded multiple 3rd party NPM dependencies for Gulp build
This commit is contained in:
Mark Friedrich
2018-10-27 00:45:53 +02:00
parent 95222c309c
commit 07d5be71b2
95 changed files with 1766 additions and 560 deletions

View File

@@ -9,6 +9,7 @@
namespace Controller;
use Controller\Api as Api;
use Exception\PathfinderException;
use lib\Config;
use lib\Resource;
use lib\Monolog;
@@ -66,7 +67,6 @@ class Controller {
* @param \Base $f3
* @param $params
* @return bool
* @throws \Exception\PathfinderException
*/
function beforeroute(\Base $f3, $params): bool {
// initiate DB connection
@@ -103,10 +103,10 @@ class Controller {
header($resource->buildHeader(), false);
}
if($this->getTemplate()){
if($file = $this->getTemplate()){
// Ajax calls don´t need a page render..
// this happens on client side
echo \Template::instance()->render( $this->getTemplate() );
echo \Template::instance()->render($file);
}
}
@@ -131,7 +131,6 @@ class Controller {
* @param $session
* @param $sid
* @return bool
* @throws \Exception\PathfinderException
*/
$onSuspect = function($session, $sid){
self::getLogger('SESSION_SUSPECT')->write( sprintf(
@@ -160,7 +159,6 @@ class Controller {
/**
* init new Resource handler
* @param \Base $f3
* @throws \Exception\PathfinderException
*/
protected function initResource(\Base $f3){
$resource = Resource::instance();
@@ -228,7 +226,6 @@ class Controller {
* -> store validation data in DB
* @param Model\CharacterModel $character
* @throws \Exception
* @throws \Exception\PathfinderException
*/
protected function setLoginCookie(Model\CharacterModel $character){
if( $this->getCookieState() ){
@@ -286,7 +283,6 @@ class Controller {
* @param bool $checkAuthorization
* @return Model\CharacterModel[]
* @throws \Exception
* @throws \Exception\PathfinderException
*/
protected function getCookieCharacters($cookieData = [], $checkAuthorization = true){
$characters = [];
@@ -489,15 +485,16 @@ class Controller {
/**
* log out current character or all active characters (multiple browser tabs)
* -> send response data to client
* @param \Base $f3
* @param bool $all
* @param bool $deleteSession
* @param bool $deleteLog
* @param bool $deleteCookie
* @throws \Exception
* @throws \ZMQSocketException
*/
protected function logoutCharacter(bool $all = false, bool $deleteSession = true, bool $deleteLog = true, bool $deleteCookie = false){
$sessionCharacterData = (array)$this->getF3()->get(Api\User::SESSION_KEY_CHARACTERS);
protected function logoutCharacter(\Base $f3, bool $all = false, bool $deleteSession = true, bool $deleteLog = true, bool $deleteCookie = false){
$sessionCharacterData = (array)$f3->get(Api\User::SESSION_KEY_CHARACTERS);
if($sessionCharacterData){
$activeCharacterId = ($activeCharacter = $this->getCharacter()) ? $activeCharacter->_id : 0;
@@ -523,6 +520,20 @@ class Controller {
(new Socket( Config::getSocketUri() ))->sendData('characterLogout', $characterIds);
}
}
if($f3->get('AJAX')){
$status = 403;
$f3->status($status);
$return = (object) [];
$return->reroute = rtrim(self::getEnvironmentData('URL'), '/') . $f3->alias('login');
$return->error[] = $this->getErrorObject($status, Config::getMessageFromHTTPStatus($status));
echo json_encode($return);
}else{
// redirect to landing page
$f3->reroute(['login']);
}
}
/**
@@ -627,7 +638,6 @@ class Controller {
/**
* get a custom userAgent string for API calls
* @return string
* @throws \Exception\PathfinderException
*/
protected function getUserAgent(){
$userAgent = '';
@@ -663,18 +673,26 @@ class Controller {
* -> on HTTP request -> render error page
* @param \Base $f3
* @return bool
* @throws \Exception\PathfinderException
*/
public function showError(\Base $f3){
if(!headers_sent()){
// collect error info -------------------------------------------------------------------------------------
$error = $this->getErrorObject(
$f3->get('ERROR.code'),
$f3->get('ERROR.status'),
$f3->get('ERROR.text'),
$f3->get('DEBUG') === 3 ? $f3->get('ERROR.trace') : null
);
$errorData = $f3->get('ERROR');
$exception = $f3->get('EXCEPTION');
if($exception instanceof PathfinderException){
// ... handle Pathfinder exceptions (e.g. validation Exceptions,..)
$error = $exception->getError();
}else{
// ... handle error $f3->error() calls
$error = $this->getErrorObject(
$errorData['code'],
$errorData['status'],
$errorData['text'],
$f3->get('DEBUG') === 3 ? $errorData['trace'] : null
);
}
// check if error is a PDO Exception ----------------------------------------------------------------------
if(strpos(strtolower( $f3->get('ERROR.text') ), 'duplicate') !== false){
@@ -725,24 +743,6 @@ class Controller {
* @return bool
*/
public function unload(\Base $f3){
// track some 4xx Client side errors
// 5xx errors are handled in "ONERROR" callback
$status = http_response_code();
if(!headers_sent() && $status >= 300){
if($f3->get('AJAX')){
$params = (array)$f3->get('POST');
$return = (object) [];
if((bool)$params['reroute']){
$return->reroute = rtrim(self::getEnvironmentData('URL'), '/') . $f3->alias('login');
}else{
// no reroute -> errors can be shown
$return->error[] = $this->getErrorObject($status, Config::getMessageFromHTTPStatus($status));
}
echo json_encode($return);
}
}
// store all user activities that are buffered for logging in this request
// this should work even on non HTTP200 responses
$this->logActivities();
@@ -887,7 +887,6 @@ class Controller {
* get the current registration status
* 0=registration stop |1=new registration allowed
* @return int
* @throws \Exception\PathfinderException
*/
static function getRegistrationStatus(){
return (int)Config::getPathfinderData('registration.status');
@@ -898,7 +897,6 @@ class Controller {
* -> set in pathfinder.ini
* @param string $type
* @return \Log|null
* @throws \Exception\PathfinderException
*/
static function getLogger($type){
return LogController::getLogger($type);