- new map change log to Slack channel - new "rally point" logging to Slack channel - new "rally point" poke options (e.g. custom message), closed #295 - new log options for WebSocket installations - added ship "mass" logging (backend only), #313 - added map logging to Slack, #326 - added "ESI error rate" limit detection - added "Monolog" as new logging library (Composer dependency) - added "Swiftmailer" as new eMail library (Composer dependency) - added Support for Redis session hander (performance boost) - improved character select panels (visible "online" status) - improved "activity logging" (more DB columns added to check) - improved eMail logging (HTML template support) - improved "delete map" now become "inactive" for some days before delete - improved character logout handling - improved /setup page for DB bootstrap (new button for DB create if not exists) - fixed broken ship tracking (ship name re-added) - fixed broken ship tracking for multiple chars on different browser tabs - fixed broken cursor coordinates, closed #518 - fixed null pointer "charactermodel.php->isActive():925" closed #529 - fixed broken "scroll offset", closed #533 closed #534 - Updated "validation" library JS v0.10.1 -> v0.11.9 - Updated ORM Mapper _Cortex_ v1.5.0-dev -> v1.5.0 - and many more....
110 lines
2.6 KiB
PHP
110 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Exodus
|
|
* Date: 26.11.2016
|
|
* Time: 17:32
|
|
*/
|
|
|
|
namespace Lib;
|
|
|
|
class Util {
|
|
|
|
/**
|
|
* convert array keys to upper/lowercase -> recursive
|
|
* @param $arr
|
|
* @param int $case
|
|
* @return array
|
|
*/
|
|
static function arrayChangeKeyCaseRecursive($arr, $case = CASE_LOWER){
|
|
if(is_array($arr)){
|
|
$arr = array_map( function($item){
|
|
if( is_array($item) )
|
|
$item = self::arrayChangeKeyCaseRecursive($item);
|
|
return $item;
|
|
}, array_change_key_case((array)$arr, $case));
|
|
}
|
|
|
|
return $arr;
|
|
}
|
|
|
|
/**
|
|
* checks whether an array is associative or not (sequential)
|
|
* @param mixed $array
|
|
* @return bool
|
|
*/
|
|
static function is_assoc($array): bool {
|
|
$isAssoc = false;
|
|
if(
|
|
is_array($array) &&
|
|
array_keys($array) !== range(0, count($array) - 1)
|
|
){
|
|
$isAssoc = true;
|
|
}
|
|
|
|
return $isAssoc;
|
|
}
|
|
|
|
/**
|
|
* convert array keys by a custom callback
|
|
* @param $arr
|
|
* @param $callback
|
|
* @return array
|
|
*/
|
|
static function arrayChangeKeys($arr, $callback){
|
|
return array_combine(
|
|
array_map(function ($key) use ($callback){
|
|
return $callback($key);
|
|
}, array_keys($arr)), $arr
|
|
);
|
|
}
|
|
|
|
/**
|
|
* convert a string with multiple scopes into an array
|
|
* @param string $scopes
|
|
* @return array|null
|
|
*/
|
|
static function convertScopesString($scopes){
|
|
$scopes = array_filter(
|
|
array_map('strtolower',
|
|
(array)explode(' ', $scopes)
|
|
)
|
|
);
|
|
|
|
if($scopes){
|
|
sort($scopes);
|
|
}else{
|
|
$scopes = null;
|
|
}
|
|
|
|
return $scopes;
|
|
}
|
|
|
|
/**
|
|
* obsucre string e.g. password (hide last characters)
|
|
* @param string $string
|
|
* @param int $maxHideChars
|
|
* @return string
|
|
*/
|
|
static function obscureString(string $string, int $maxHideChars = 10): string {
|
|
$formatted = '';
|
|
$length = mb_strlen((string)$string);
|
|
if($length > 0){
|
|
$hideChars = ($length < $maxHideChars) ? $length : $maxHideChars;
|
|
$formatted = substr_replace($string, str_repeat('_', min(3, $length)), -$hideChars) .
|
|
' [' . $length . ']';
|
|
}
|
|
return $formatted;
|
|
}
|
|
|
|
/**
|
|
* get hash from an array of ESI scopes
|
|
* @param array $scopes
|
|
* @return string
|
|
*/
|
|
static function getHashFromScopes($scopes){
|
|
$scopes = (array)$scopes;
|
|
sort($scopes);
|
|
return md5(serialize($scopes));
|
|
}
|
|
} |