- Improved HTTP Header parser (PHP)
- Improved log info in `logs/cron_truncateFiles.log`, added truncated *.log file names - Fixed wrong return type for `UserModel::getSessionCharacterData()`, must be `array` not `null` (edge case)
This commit is contained in:
@@ -870,7 +870,8 @@ class Controller {
|
||||
*/
|
||||
static function getRequestHeaders() : array {
|
||||
$headers = [];
|
||||
|
||||
$headerPrefix = 'http_';
|
||||
$prefixLength = mb_strlen($headerPrefix);
|
||||
$serverData = self::getServerData();
|
||||
|
||||
if(
|
||||
@@ -885,8 +886,9 @@ class Controller {
|
||||
// Therefore we can´t use this for all servers
|
||||
// https://github.com/exodus4d/pathfinder/issues/58
|
||||
foreach($_SERVER as $name => $value){
|
||||
if(substr($name, 0, 5) == 'HTTP_'){
|
||||
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
|
||||
$name = mb_strtolower($name);
|
||||
if(mb_substr($name, 0, $prefixLength) == $headerPrefix){
|
||||
$headers[mb_convert_case(str_replace('_', '-', mb_substr($name, $prefixLength)), MB_CASE_TITLE)] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ use data\filesystem\Search;
|
||||
|
||||
class MapHistory extends AbstractCron {
|
||||
|
||||
const LOG_TEXT = '%s [%4s] log files, [%4s] not writable, [%4s] read error, [%4s] write error, [%4s] rename error, [%4s] delete error, exec (%.3Fs)';
|
||||
/**
|
||||
* log msg for truncateFiles() cronjob
|
||||
*/
|
||||
const LOG_TEXT = '%s [%4s] log files, [%s] truncated, [%4s] not writable, [%4s] read error, [%4s] write error, [%4s] rename error, [%4s] delete error, exec (%.3Fs)';
|
||||
|
||||
/**
|
||||
* default log file size limit before truncate, bytes (1MB)
|
||||
@@ -65,6 +68,7 @@ class MapHistory extends AbstractCron {
|
||||
$writeErrors = 0;
|
||||
$renameErrors = 0;
|
||||
$deleteErrors = 0;
|
||||
$truncatedFileNames = [];
|
||||
|
||||
if($f3->exists('PATHFINDER.HISTORY.LOG', $dir)){
|
||||
$fileHandler = FileHandler::instance();
|
||||
@@ -98,7 +102,8 @@ class MapHistory extends AbstractCron {
|
||||
// move temp file from PHP temp dir into Pathfinders history log dir...
|
||||
// ... overwrite old log file with new file
|
||||
if(rename($temp, $file->getRealPath())){
|
||||
// map history logs should be writable non cronjob user too
|
||||
$truncatedFileNames[] = $file->getFilename();
|
||||
// map history logs should be writable for non cronjob user too
|
||||
@chmod($file->getRealPath(), 0666);
|
||||
}else{
|
||||
$renameErrors++;
|
||||
@@ -120,6 +125,6 @@ class MapHistory extends AbstractCron {
|
||||
|
||||
// Log ------------------------
|
||||
$log = new \Log('cron_' . __FUNCTION__ . '.log');
|
||||
$log->write(sprintf(self::LOG_TEXT, __FUNCTION__, $largeFiles, $notWritableFiles, $readErrors, $writeErrors, $renameErrors, $deleteErrors, $execTime));
|
||||
$log->write(sprintf(self::LOG_TEXT, __FUNCTION__, $largeFiles, implode(', ', $truncatedFileNames), $notWritableFiles, $readErrors, $writeErrors, $renameErrors, $deleteErrors, $execTime));
|
||||
}
|
||||
}
|
||||
@@ -218,9 +218,12 @@ class UserModel extends AbstractPathfinderModel {
|
||||
// user matches session data
|
||||
if($characterId > 0){
|
||||
$data = $this->findSessionCharacterData($characterId);
|
||||
}elseif( !empty($sessionCharacters = (array)$this->getF3()->get(User::SESSION_KEY_CHARACTERS)) ){
|
||||
}elseif(
|
||||
is_array($sessionCharacters = $this->getF3()->get(User::SESSION_KEY_CHARACTERS)) && // check for null
|
||||
!empty($sessionCharacters)
|
||||
){
|
||||
// no character was requested ($requestedCharacterId = 0) AND session characters were found
|
||||
// -> get first matched character (e.g. user open browser tab)
|
||||
// -> get first matched character (e.g. user open /login browser tab)
|
||||
$data = $sessionCharacters[0];
|
||||
}
|
||||
}
|
||||
@@ -235,7 +238,7 @@ class UserModel extends AbstractPathfinderModel {
|
||||
* @var $character CharacterModel
|
||||
*/
|
||||
$character = AbstractPathfinderModel::getNew('CharacterModel');
|
||||
$character->getById( (int)$data['ID']);
|
||||
$character->getById((int)$data['ID']);
|
||||
|
||||
if(
|
||||
$character->dry() ||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div id="{{id}}" class="alert alert-warning">
|
||||
<div class="ui-pnotify-icon"><span class="fas fa-exclamation fa-fw fa-lg"></span></div>
|
||||
<h4 class="ui-pnotify-title">Scheduled maintenance: Update v1.5.0 <i class="fas fa-long-arrow-alt-right"></i> v1.5.1; Shutdown: ~15:00 (UTC). ETA ~15:45 (UTC)</h4>
|
||||
<h4 class="ui-pnotify-title">Scheduled maintenance: Update v1.5.1 <i class="fas fa-long-arrow-alt-right"></i> v1.5.2; Shutdown: ~21:30 (UTC). ETA ~22:00 (UTC)</h4>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user