- 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....
194 lines
6.1 KiB
PHP
194 lines
6.1 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: exodus4d
|
|
* Date: 30.07.2015
|
|
* Time: 17:54
|
|
*/
|
|
|
|
namespace cron;
|
|
use DB;
|
|
use lib\Config;
|
|
use Model;
|
|
|
|
class MapUpdate {
|
|
|
|
const LOG_TEXT_MAPS = '%s (%d maps)';
|
|
|
|
// disabled maps will be fully deleted after (x) days
|
|
const DAYS_UNTIL_MAP_DELETION = 30;
|
|
|
|
/**
|
|
* deactivate all "private" maps whose lifetime is over
|
|
* >> php index.php "/cron/deactivateMapData"
|
|
* @param \Base $f3
|
|
*/
|
|
function deactivateMapData(\Base $f3){
|
|
$privateMapLifetime = (int)Config::getMapsDefaultConfig('private.lifetime');
|
|
|
|
if($privateMapLifetime > 0){
|
|
$pfDB = DB\Database::instance()->getDB('PF');
|
|
if($pfDB){
|
|
$sqlDeactivateExpiredMaps = "UPDATE map SET
|
|
active = 0
|
|
WHERE
|
|
map.active = 1 AND
|
|
map.typeId = 2 AND
|
|
TIMESTAMPDIFF(DAY, map.updated, NOW() ) > :lifetime";
|
|
|
|
$pfDB->exec($sqlDeactivateExpiredMaps, ['lifetime' => $privateMapLifetime]);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* delete all deactivated maps
|
|
* >> php index.php "/cron/deleteMapData"
|
|
* @param \Base $f3
|
|
*/
|
|
function deleteMapData(\Base $f3){
|
|
$pfDB = DB\Database::instance()->getDB('PF');
|
|
$deletedMapsCount = 0;
|
|
|
|
if($pfDB){
|
|
$sqlDeleteDisabledMaps = "SELECT
|
|
id
|
|
FROM
|
|
map
|
|
WHERE
|
|
map.active = 0 AND
|
|
TIMESTAMPDIFF(DAY, map.updated, NOW() ) > :deletion_time";
|
|
|
|
$disabledMaps = $pfDB->exec($sqlDeleteDisabledMaps, ['deletion_time' => self::DAYS_UNTIL_MAP_DELETION]);
|
|
|
|
if($deletedMapsCount = $pfDB->count()){
|
|
$mapModel = Model\BasicModel::getNew('MapModel');
|
|
foreach($disabledMaps as $data){
|
|
$mapModel->getById( (int)$data['id'], 3, false );
|
|
if( !$mapModel->dry() ){
|
|
$mapModel->erase();
|
|
}
|
|
$mapModel->reset();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Log ------------------------
|
|
$log = new \Log('cron_' . __FUNCTION__ . '.log');
|
|
$log->write( sprintf(self::LOG_TEXT_MAPS, __FUNCTION__, $deletedMapsCount) );
|
|
}
|
|
|
|
/**
|
|
* delete expired EOL connections
|
|
* >> php index.php "/cron/deleteEolConnections"
|
|
* @param \Base $f3
|
|
*/
|
|
function deleteEolConnections(\Base $f3){
|
|
$eolExpire = (int)$f3->get('PATHFINDER.CACHE.EXPIRE_CONNECTIONS_EOL');
|
|
|
|
if($eolExpire > 0){
|
|
$pfDB = DB\Database::instance()->getDB('PF');
|
|
if($pfDB){
|
|
$sql = "SELECT
|
|
`con`.`id`
|
|
FROM
|
|
`connection` `con` INNER JOIN
|
|
`map` ON
|
|
`map`.`id` = `con`.`mapId`
|
|
WHERE
|
|
`map`.`deleteEolConnections` = :deleteEolConnections AND
|
|
TIMESTAMPDIFF(SECOND, `con`.`eolUpdated`, NOW() ) > :expire_time
|
|
";
|
|
|
|
$connectionsData = $pfDB->exec($sql, [
|
|
'deleteEolConnections' => 1,
|
|
'expire_time' => $eolExpire
|
|
]);
|
|
|
|
if($connectionsData){
|
|
/**
|
|
* @var $connection Model\ConnectionModel
|
|
*/
|
|
$connection = Model\BasicModel::getNew('ConnectionModel');
|
|
foreach($connectionsData as $data){
|
|
$connection->getById( (int)$data['id'] );
|
|
if( !$connection->dry() ){
|
|
$connection->erase();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* delete expired WH connections after max lifetime for wormholes is reached
|
|
* >> php index.php "/cron/deleteExpiredConnections"
|
|
* @param \Base $f3
|
|
*/
|
|
function deleteExpiredConnections(\Base $f3){
|
|
$whExpire = (int)$f3->get('PATHFINDER.CACHE.EXPIRE_CONNECTIONS_WH');
|
|
|
|
if($whExpire > 0){
|
|
$pfDB = DB\Database::instance()->getDB('PF');
|
|
if($pfDB){
|
|
$sql = "SELECT
|
|
`con`.`id`
|
|
FROM
|
|
`connection` `con` INNER JOIN
|
|
`map` ON
|
|
`map`.`id` = `con`.`mapId`
|
|
WHERE
|
|
`map`.`deleteExpiredConnections` = :deleteExpiredConnections AND
|
|
`con`.`scope` = :scope AND
|
|
TIMESTAMPDIFF(SECOND, `con`.`created`, NOW() ) > :expire_time
|
|
";
|
|
|
|
$connectionsData = $pfDB->exec($sql, [
|
|
'deleteExpiredConnections' => 1,
|
|
'scope' => 'wh',
|
|
'expire_time' => $whExpire
|
|
]);
|
|
|
|
if($connectionsData){
|
|
/**
|
|
* @var $connection Model\ConnectionModel
|
|
*/
|
|
$connection = Model\BasicModel::getNew('ConnectionModel');
|
|
foreach($connectionsData as $data){
|
|
$connection->getById( (int)$data['id'] );
|
|
if( !$connection->dry() ){
|
|
$connection->erase();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* delete all expired signatures on "inactive" systems
|
|
* >> php index.php "/cron/deleteSignatures"
|
|
* @param \Base $f3
|
|
*/
|
|
function deleteSignatures(\Base $f3){
|
|
$signatureExpire = (int)$f3->get('PATHFINDER.CACHE.EXPIRE_SIGNATURES');
|
|
|
|
if($signatureExpire > 0){
|
|
$pfDB = DB\Database::instance()->getDB('PF');
|
|
if($pfDB){
|
|
$sqlDeleteExpiredSignatures = "DELETE `sigs` FROM
|
|
`system_signature` `sigs` INNER JOIN
|
|
`system` ON
|
|
`system`.`id` = `sigs`.`systemId`
|
|
WHERE
|
|
`system`.`active` = 0 AND
|
|
TIMESTAMPDIFF(SECOND, `sigs`.`updated`, NOW() ) > :lifetime
|
|
";
|
|
|
|
$pfDB->exec($sqlDeleteExpiredSignatures, ['lifetime' => $signatureExpire]);
|
|
}
|
|
}
|
|
}
|
|
|
|
} |