v1.1.1 (#233)
* fixed #194 PHP 5.6 error * - closed #102 added "set waypoint/destination" context menu to route finder module - update "Select2" 4.0.0 -> 4.0.3 - update "Font Awesome" 4.6.1 -> 4.6.3 * - added *.js files for develop branch * - closed #195 fixed "BASE" dir for subDir installations - fixed "Home" menu link * - #195 improved js load path * - added "clear cache" function for manually cache clearing to /setup #200 #105 #158 - added cache size information to /setup - added current pathfinder "VERSION" to /setup - updated "requireJs" 2.1.20 ->2.2.0 - removed unnecessary page cache timings from static templates (page cache) * - added "document_root", "port", "protocol" and "PHP framework version" to /setup page - added new "shattered" wormhole types to "signature table", closed #182, #179 * - added new "delete old signatures" option to "signature reader" dialog, closed #95 * - added new housekeeping cronjob für cached files, closed #200 - added new cache size information to /setup page * - fixed signature groupId/typeId "overwriting" for already known signatures. closed #207 - improved system search dialog. Added trim(); before "api/signatures-> search" request * updated README.me * fixed PHP error "default object from empty value", closed #209 * reduced image file size * - added local storage (IndexedDB) - added local storage for map scroll position. closed #69 * - added "notice" panel for upcoming release information - improved layout for "release dialog" (GitHub API) - improved pagespeed (removed render blocking javascripts) - improved map scrollbar configuration - improved Chrome browser custom scrollbar layout - removed "sign up" buttons from "map panels", closed #214 * - fixed some session and cookie bugs * - added new requirement check for `max_input_vars` to /setup URL, closed #224 * - fixed isWormhole(); bug * -v1.1.1 added js build files
This commit is contained in:
@@ -40,7 +40,7 @@ class GitHub extends Controller\Controller {
|
||||
public function releases($f3){
|
||||
$cacheKey = 'CACHE_GITHUB_RELEASES';
|
||||
$ttl = 60 * 30; // 30min
|
||||
$releaseCount = 3;
|
||||
$releaseCount = 4;
|
||||
|
||||
if( !$f3->exists($cacheKey) ){
|
||||
$apiPath = $this->getF3()->get('PATHFINDER.API.GIT_HUB') . '/repos/exodus4d/pathfinder/releases';
|
||||
|
||||
@@ -780,150 +780,155 @@ class Map extends Controller\AccessController {
|
||||
$sourceSystemId = (int)$this->getF3()->get(User::SESSION_KEY_CHARACTER_PREV_SYSTEM_ID);
|
||||
$targetSystemId = (int)$log->systemId;
|
||||
|
||||
$sourceSystem = null;
|
||||
$targetSystem = null;
|
||||
if($sourceSystemId){
|
||||
$sourceSystem = null;
|
||||
$targetSystem = null;
|
||||
|
||||
// check if source and target systems are equal
|
||||
// -> NO target system available
|
||||
if($sourceSystemId === $targetSystemId){
|
||||
// check if previous (solo) system is already on the map
|
||||
$sourceSystem = $map->getSystemByCCPId($sourceSystemId);
|
||||
$sameSystem = true;
|
||||
}else{
|
||||
// check if previous (source) system is already on the map
|
||||
$sourceSystem = $map->getSystemByCCPId($sourceSystemId);
|
||||
// check if source and target systems are equal
|
||||
// -> NO target system available
|
||||
if($sourceSystemId === $targetSystemId){
|
||||
// check if previous (solo) system is already on the map
|
||||
$sourceSystem = $map->getSystemByCCPId($sourceSystemId);
|
||||
$sameSystem = true;
|
||||
}else{
|
||||
// check if previous (source) system is already on the map
|
||||
$sourceSystem = $map->getSystemByCCPId($sourceSystemId);
|
||||
|
||||
// -> check if system is already on this map
|
||||
$targetSystem = $map->getSystemByCCPId( $targetSystemId );
|
||||
}
|
||||
// -> check if system is already on this map
|
||||
$targetSystem = $map->getSystemByCCPId( $targetSystemId );
|
||||
}
|
||||
|
||||
// if systems don´t already exists on map -> get "blank" systems
|
||||
// -> required for system type check (e.g. wormhole, k-space)
|
||||
if( !$sourceSystem ){
|
||||
$sourceExists = false;
|
||||
$sourceSystem = $map->getNewSystem($sourceSystemId);
|
||||
}else{
|
||||
// system exists -> add target to the "right"
|
||||
$systemPosX = $sourceSystem->posX + $systemOffsetX;
|
||||
$systemPosY = $sourceSystem->posY + $systemOffsetY;
|
||||
}
|
||||
// if systems don´t already exists on map -> get "blank" systems
|
||||
// -> required for system type check (e.g. wormhole, k-space)
|
||||
if(
|
||||
!$sourceSystem &&
|
||||
$sourceSystemId
|
||||
){
|
||||
$sourceExists = false;
|
||||
$sourceSystem = $map->getNewSystem($sourceSystemId);
|
||||
}else{
|
||||
// system exists -> add target to the "right"
|
||||
$systemPosX = $sourceSystem->posX + $systemOffsetX;
|
||||
$systemPosY = $sourceSystem->posY + $systemOffsetY;
|
||||
}
|
||||
|
||||
if(
|
||||
!$sameSystem &&
|
||||
!$targetSystem
|
||||
){
|
||||
$targetExists = false;
|
||||
$targetSystem = $map->getNewSystem( $targetSystemId );
|
||||
}
|
||||
if(
|
||||
!$sameSystem &&
|
||||
!$targetSystem
|
||||
){
|
||||
$targetExists = false;
|
||||
$targetSystem = $map->getNewSystem( $targetSystemId );
|
||||
}
|
||||
|
||||
$addSourceSystem = false;
|
||||
$addTargetSystem = false;
|
||||
$addConnection = false;
|
||||
$addSourceSystem = false;
|
||||
$addTargetSystem = false;
|
||||
$addConnection = false;
|
||||
|
||||
switch($mapScope->name){
|
||||
case 'all':
|
||||
if($sameSystem){
|
||||
$addSourceSystem = true;
|
||||
}else{
|
||||
$addSourceSystem = true;
|
||||
$addTargetSystem = true;
|
||||
$addConnection = true;
|
||||
}
|
||||
break;
|
||||
case 'k-space':
|
||||
if($sameSystem){
|
||||
if( !$sourceSystem->isWormhole() ){
|
||||
switch($mapScope->name){
|
||||
case 'all':
|
||||
if($sameSystem){
|
||||
$addSourceSystem = true;
|
||||
}
|
||||
}elseif(
|
||||
!$sourceSystem->isWormhole() ||
|
||||
!$targetSystem->isWormhole()
|
||||
){
|
||||
$addSourceSystem = true;
|
||||
$addTargetSystem = true;
|
||||
$addConnection = true;
|
||||
}
|
||||
break;
|
||||
case 'wh':
|
||||
default:
|
||||
if($sameSystem){
|
||||
if( $sourceSystem->isWormhole() ){
|
||||
$addSourceSystem = true;
|
||||
}
|
||||
}elseif(
|
||||
$sourceSystem->isWormhole() ||
|
||||
$targetSystem->isWormhole()
|
||||
){
|
||||
$addSourceSystem = true;
|
||||
$addTargetSystem = true;
|
||||
$addConnection = true;
|
||||
}elseif(
|
||||
!$sourceSystem->isWormhole() &&
|
||||
!$targetSystem->isWormhole()
|
||||
){
|
||||
// check distance between systems (in jumps)
|
||||
// -> if > 1 it is !very likely! a wormhole
|
||||
$routeController = new Route();
|
||||
$routeController->initJumpData();
|
||||
$route = $routeController->findRoute($sourceSystem->name, $targetSystem->name, 1);
|
||||
|
||||
if( !$route['routePossible'] ){
|
||||
}else{
|
||||
$addSourceSystem = true;
|
||||
$addTargetSystem = true;
|
||||
$addConnection = true;
|
||||
}
|
||||
break;
|
||||
case 'k-space':
|
||||
if($sameSystem){
|
||||
if( !$sourceSystem->isWormhole() ){
|
||||
$addSourceSystem = true;
|
||||
}
|
||||
}elseif(
|
||||
!$sourceSystem->isWormhole() ||
|
||||
!$targetSystem->isWormhole()
|
||||
){
|
||||
$addSourceSystem = true;
|
||||
$addTargetSystem = true;
|
||||
$addConnection = true;
|
||||
}
|
||||
break;
|
||||
case 'wh':
|
||||
default:
|
||||
if($sameSystem){
|
||||
if( $sourceSystem->isWormhole() ){
|
||||
$addSourceSystem = true;
|
||||
}
|
||||
}elseif(
|
||||
$sourceSystem->isWormhole() ||
|
||||
$targetSystem->isWormhole()
|
||||
){
|
||||
$addSourceSystem = true;
|
||||
$addTargetSystem = true;
|
||||
$addConnection = true;
|
||||
}elseif(
|
||||
!$sourceSystem->isWormhole() &&
|
||||
!$targetSystem->isWormhole()
|
||||
){
|
||||
// check distance between systems (in jumps)
|
||||
// -> if > 1 it is !very likely! a wormhole
|
||||
$routeController = new Route();
|
||||
$routeController->initJumpData();
|
||||
$route = $routeController->findRoute($sourceSystem->name, $targetSystem->name, 1);
|
||||
|
||||
if( !$route['routePossible'] ){
|
||||
$addSourceSystem = true;
|
||||
$addTargetSystem = true;
|
||||
$addConnection = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// save source system -------------------------------------------------------------------------------------
|
||||
if(
|
||||
$addSourceSystem &&
|
||||
$sourceSystem &&
|
||||
!$sourceExists
|
||||
){
|
||||
$sourceSystem = $map->saveSystem($sourceSystem, $systemPosX, $systemPosY, $character);
|
||||
// get updated maps object
|
||||
if($sourceSystem){
|
||||
$map = $sourceSystem->mapId;
|
||||
$sourceExists = true;
|
||||
$clearMapDataCache = true;
|
||||
// increase system position (prevent overlapping)
|
||||
$systemPosX = $sourceSystem->posX + $systemOffsetX;
|
||||
$systemPosY = $sourceSystem->posY + $systemOffsetY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// save source system -------------------------------------------------------------------------------------
|
||||
if(
|
||||
$addSourceSystem &&
|
||||
$sourceSystem &&
|
||||
!$sourceExists
|
||||
){
|
||||
$sourceSystem = $map->saveSystem($sourceSystem, $systemPosX, $systemPosY, $character);
|
||||
// get updated maps object
|
||||
if($sourceSystem){
|
||||
$map = $sourceSystem->mapId;
|
||||
$sourceExists = true;
|
||||
$clearMapDataCache = true;
|
||||
// increase system position (prevent overlapping)
|
||||
$systemPosX = $sourceSystem->posX + $systemOffsetX;
|
||||
$systemPosY = $sourceSystem->posY + $systemOffsetY;
|
||||
}
|
||||
}
|
||||
|
||||
// save target system -------------------------------------------------------------------------------------
|
||||
if(
|
||||
$addTargetSystem &&
|
||||
$targetSystem &&
|
||||
!$targetExists
|
||||
){
|
||||
$targetSystem = $map->saveSystem($targetSystem, $systemPosX, $systemPosY, $character);
|
||||
// get updated maps object
|
||||
if($targetSystem){
|
||||
$map = $targetSystem->mapId;
|
||||
$clearMapDataCache = true;
|
||||
$targetExists = true;
|
||||
// save target system -------------------------------------------------------------------------------------
|
||||
if(
|
||||
$addTargetSystem &&
|
||||
$targetSystem &&
|
||||
!$targetExists
|
||||
){
|
||||
$targetSystem = $map->saveSystem($targetSystem, $systemPosX, $systemPosY, $character);
|
||||
// get updated maps object
|
||||
if($targetSystem){
|
||||
$map = $targetSystem->mapId;
|
||||
$clearMapDataCache = true;
|
||||
$targetExists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// save connection ----------------------------------------------------------------------------------------
|
||||
if(
|
||||
$addConnection &&
|
||||
$sourceExists &&
|
||||
$targetExists &&
|
||||
$sourceSystem &&
|
||||
$targetSystem &&
|
||||
!$map->searchConnection( $sourceSystem, $targetSystem )
|
||||
){
|
||||
$connection = $map->getNewConnection($sourceSystem, $targetSystem);
|
||||
$connection = $map->saveConnection($connection);
|
||||
// get updated maps object
|
||||
if($connection){
|
||||
$map = $connection->mapId;
|
||||
$clearMapDataCache = true;
|
||||
// save connection ----------------------------------------------------------------------------------------
|
||||
if(
|
||||
$addConnection &&
|
||||
$sourceExists &&
|
||||
$targetExists &&
|
||||
$sourceSystem &&
|
||||
$targetSystem &&
|
||||
!$map->searchConnection( $sourceSystem, $targetSystem )
|
||||
){
|
||||
$connection = $map->getNewConnection($sourceSystem, $targetSystem);
|
||||
$connection = $map->saveConnection($connection);
|
||||
// get updated maps object
|
||||
if($connection){
|
||||
$map = $connection->mapId;
|
||||
$clearMapDataCache = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,8 +589,8 @@ class Route extends \Controller\AccessController {
|
||||
];
|
||||
|
||||
$returnRoutData = [
|
||||
'systemFrom' => $routeData['systemFrom'],
|
||||
'systemTo' => $routeData['systemTo'],
|
||||
'systemFromData' => $routeData['systemFromData'],
|
||||
'systemToData' => $routeData['systemToData'],
|
||||
'maps' => $mapData,
|
||||
'mapIds' => $mapIds
|
||||
];
|
||||
@@ -599,10 +599,14 @@ class Route extends \Controller\AccessController {
|
||||
$returnRoutData += $filterData;
|
||||
|
||||
if(count($mapIds) > 0){
|
||||
$systemFrom = $routeData['systemFromData']['name'];
|
||||
$systemTo = $routeData['systemToData']['name'];
|
||||
|
||||
|
||||
$cacheKey = $this->getRouteCacheKey(
|
||||
$mapIds,
|
||||
$routeData['systemFrom'],
|
||||
$routeData['systemTo'],
|
||||
$systemFrom,
|
||||
$systemTo,
|
||||
$filterData
|
||||
);
|
||||
|
||||
@@ -614,7 +618,7 @@ class Route extends \Controller\AccessController {
|
||||
$this->initJumpData($mapIds, $filterData);
|
||||
|
||||
// no cached route data found
|
||||
$foundRoutData = $this->findRoute($routeData['systemFrom'], $routeData['systemTo']);
|
||||
$foundRoutData = $this->findRoute($systemFrom, $systemTo);
|
||||
$returnRoutData = array_merge($returnRoutData, $foundRoutData);
|
||||
|
||||
// cache if route was found
|
||||
|
||||
@@ -28,7 +28,7 @@ class Signature extends Controller\AccessController{
|
||||
* -> return value of this is limited to a "SINGLE" system
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function getAll($f3){
|
||||
public function getAll(\Base $f3){
|
||||
$signatureData = [];
|
||||
$systemIds = (array)$f3->get('POST.systemIds');
|
||||
|
||||
@@ -60,12 +60,16 @@ class Signature extends Controller\AccessController{
|
||||
/**
|
||||
* save or update a full signature data set
|
||||
* or save/update just single or multiple signature data
|
||||
* @param $f3
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function save($f3){
|
||||
public function save(\Base $f3){
|
||||
$requestData = $f3->get('POST');
|
||||
|
||||
$signatureData = null;
|
||||
$systemId = (int)$requestData['systemId'];
|
||||
// delete all signatures that are not available in this request
|
||||
$deleteOldSignatures = (bool)$requestData['deleteOld'];
|
||||
|
||||
|
||||
$return = (object) [];
|
||||
$return->error = [];
|
||||
@@ -83,6 +87,8 @@ class Signature extends Controller\AccessController{
|
||||
$activeCharacter = $this->getCharacter();
|
||||
|
||||
if($activeCharacter){
|
||||
// signature ids that were updated/created
|
||||
$updatedSignatureIds = [];
|
||||
|
||||
/**
|
||||
* @var Model\SystemModel $system
|
||||
@@ -96,7 +102,7 @@ class Signature extends Controller\AccessController{
|
||||
|
||||
$system->getById( (int)$data['systemId']);
|
||||
|
||||
if(!$system->dry()){
|
||||
if( !$system->dry() ){
|
||||
// update/save signature
|
||||
|
||||
/**
|
||||
@@ -156,6 +162,14 @@ class Signature extends Controller\AccessController{
|
||||
unset( $data['typeId'] );
|
||||
}
|
||||
|
||||
// "sig reader" should not overwrite signature group information
|
||||
if(
|
||||
$data['groupId'] == 0 &&
|
||||
$signature->groupId > 0
|
||||
){
|
||||
unset($data['groupId']);
|
||||
}
|
||||
|
||||
$newData = $data;
|
||||
}
|
||||
|
||||
@@ -167,6 +181,7 @@ class Signature extends Controller\AccessController{
|
||||
}
|
||||
|
||||
$signature->save();
|
||||
$updatedSignatureIds[] = $signature->id;
|
||||
|
||||
// get a fresh signature object with the new data. This is a bad work around!
|
||||
// but i could not figure out what the problem was when using the signature model, saved above :(
|
||||
@@ -184,6 +199,28 @@ class Signature extends Controller\AccessController{
|
||||
|
||||
$system->reset();
|
||||
}
|
||||
|
||||
// delete "old" signatures ------------------------------------------------------------------
|
||||
if(
|
||||
$deleteOldSignatures &&
|
||||
$systemId
|
||||
){
|
||||
$system->getById($systemId);
|
||||
if(
|
||||
!$system->dry() &&
|
||||
$system->hasAccess($activeCharacter)
|
||||
){
|
||||
$allSignatures = $system->getSignatures();
|
||||
foreach($allSignatures as $tempSignature){
|
||||
if( !in_array($tempSignature->id, $updatedSignatureIds)){
|
||||
$tempSignature->delete( $activeCharacter );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +231,7 @@ class Signature extends Controller\AccessController{
|
||||
* delete signatures
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function delete($f3){
|
||||
public function delete(\Base $f3){
|
||||
$signatureIds = $f3->get('POST.signatureIds');
|
||||
$activeCharacter = $this->getCharacter();
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
namespace Controller;
|
||||
|
||||
use data\filesystem\Search;
|
||||
use DB;
|
||||
use DB\SQL;
|
||||
use DB\SQL\MySQL as MySQL;
|
||||
@@ -137,6 +138,7 @@ class Setup extends Controller {
|
||||
/**
|
||||
* main setup route handler
|
||||
* works as dispatcher for setup functions
|
||||
* -> for security reasons all /setup "routes" are dispatched by GET params
|
||||
* @param \Base $f3
|
||||
*/
|
||||
public function init(\Base $f3){
|
||||
@@ -146,21 +148,17 @@ class Setup extends Controller {
|
||||
$fixColumns = false;
|
||||
|
||||
// bootstrap database from model class definition
|
||||
if(
|
||||
isset($params['db']) &&
|
||||
!empty($params['db'])
|
||||
){
|
||||
if( !empty($params['db']) ){
|
||||
$this->bootstrapDB($params['db']);
|
||||
|
||||
// reload page
|
||||
// -> remove GET param
|
||||
$f3->reroute('@setup');
|
||||
return;
|
||||
}elseif(
|
||||
isset($params['fixCols']) &&
|
||||
!empty($params['fixCols'])
|
||||
){
|
||||
}elseif( !empty($params['fixCols']) ){
|
||||
$fixColumns = true;
|
||||
}elseif( !empty($params['clearCache']) ){
|
||||
$this->clearCache($f3);
|
||||
}
|
||||
|
||||
// set template data ----------------------------------------------------------------
|
||||
@@ -175,6 +173,9 @@ class Setup extends Controller {
|
||||
|
||||
// set database connection information
|
||||
$f3->set('checkDatabase', $this->checkDatabase($f3, $fixColumns));
|
||||
|
||||
// set cache size
|
||||
$f3->set('cacheSize', $this->getCacheData($f3));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +230,7 @@ class Setup extends Controller {
|
||||
$serverInfo = [
|
||||
'time' => [
|
||||
'label' => 'Time',
|
||||
'value' => date('Y/m/d H:i:s') . ' - (' . date_default_timezone_get() . ')'
|
||||
'value' => date('Y/m/d H:i:s') . ' - (' . $f3->get('TZ') . ')'
|
||||
],
|
||||
'os' => [
|
||||
'label' => 'OS',
|
||||
@@ -250,6 +251,18 @@ class Setup extends Controller {
|
||||
'machine' => [
|
||||
'label' => 'Machine type',
|
||||
'value' => php_uname('m')
|
||||
],
|
||||
'root' => [
|
||||
'label' => 'Document root',
|
||||
'value' => $f3->get('ROOT')
|
||||
],
|
||||
'port' => [
|
||||
'label' => 'Port',
|
||||
'value' => $f3->get('PORT')
|
||||
],
|
||||
'protocol' => [
|
||||
'label' => 'Protocol',
|
||||
'value' => $f3->get('SCHEME')
|
||||
]
|
||||
];
|
||||
|
||||
@@ -309,6 +322,20 @@ class Setup extends Controller {
|
||||
'required' => 'installed',
|
||||
'version' => (extension_loaded('curl') && function_exists('curl_version')) ? 'installed' : 'not installed',
|
||||
'check' => (extension_loaded('curl') && function_exists('curl_version'))
|
||||
],
|
||||
'maxInputVars' => [
|
||||
'label' => 'max_input_vars',
|
||||
'required' => $f3->get('REQUIREMENTS.PHP.MAX_INPUT_VARS'),
|
||||
'version' => ini_get('max_input_vars'),
|
||||
'check' => ini_get('max_input_vars') >= $f3->get('REQUIREMENTS.PHP.MAX_INPUT_VARS'),
|
||||
'tooltip' => 'PHP default = 1000. Increase it in order to import larger maps.'
|
||||
],
|
||||
'maxExecutionTime' => [
|
||||
'label' => 'max_execution_time',
|
||||
'required' => $f3->get('REQUIREMENTS.PHP.MAX_EXECUTION_TIME'),
|
||||
'version' => ini_get('max_execution_time'),
|
||||
'check' => ini_get('max_execution_time') >= $f3->get('REQUIREMENTS.PHP.MAX_EXECUTION_TIME'),
|
||||
'tooltip' => 'PHP default = 30. Max execution time for PHP scripts.'
|
||||
]
|
||||
];
|
||||
|
||||
@@ -730,4 +757,56 @@ class Setup extends Controller {
|
||||
}
|
||||
return $checkTables;
|
||||
}
|
||||
|
||||
/**
|
||||
* get cache folder size as string
|
||||
* @param \Base $f3
|
||||
* @return array
|
||||
*/
|
||||
protected function getCacheData(\Base $f3){
|
||||
|
||||
// get all cache -----------------------------------------------------------------------------------------
|
||||
$cacheFilesAll = Search::getFilesByMTime( $f3->get('TEMP') );
|
||||
$bytesAll = 0;
|
||||
foreach($cacheFilesAll as $filename => $file) {
|
||||
$bytesAll += $file->getSize();
|
||||
}
|
||||
|
||||
// get data cache -----------------------------------------------------------------------------------------
|
||||
$cacheFilesData = Search::getFilesByMTime( $f3->get('TEMP') . 'cache/' );
|
||||
$bytesData = 0;
|
||||
foreach($cacheFilesData as $filename => $file) {
|
||||
$bytesData += $file->getSize();
|
||||
}
|
||||
|
||||
return [
|
||||
'all' => $this->convertBytes($bytesAll),
|
||||
'data' => $this->convertBytes($bytesData),
|
||||
'template' => $this->convertBytes($bytesAll - $bytesData)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all cached files
|
||||
* @param \Base $f3
|
||||
*/
|
||||
protected function clearCache(\Base $f3){
|
||||
$f3->clear('CACHE');
|
||||
}
|
||||
|
||||
/**
|
||||
* convert Bytes to string + suffix
|
||||
* @param int $bytes
|
||||
* @param int $precision
|
||||
* @return string
|
||||
*/
|
||||
protected function convertBytes($bytes, $precision = 2){
|
||||
$result = '0';
|
||||
if($bytes){
|
||||
$base = log($bytes, 1024);
|
||||
$suffixes = array('', 'KB', 'MB', 'GB', 'TB');
|
||||
$result = round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user