release 1.2.12

This commit is contained in:
Newcomer1989
2019-02-24 02:49:55 +01:00
parent ce3c88d833
commit 357a38dbf8
57 changed files with 2054 additions and 1134 deletions

View File

@@ -1,30 +1,30 @@
<?PHP
function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$cleanperiod,$logpath,$select_arr) {
function clean($ts3,$mysqlcon,$lang,$cfg,$dbname,$select_arr) {
$nowtime = time();
$sqlexec = '';
// clean old clients out of the database
if($select_arr['job_check']['clean_clients']['timestamp'] < ($nowtime - $cleanperiod)) {
if ($cleanclients == 1) {
enter_logfile($logpath,$timezone,4,$lang['clean']);
if($select_arr['job_check']['clean_clients']['timestamp'] < ($nowtime - $cfg['rankup_clean_clients_period'])) {
if ($cfg['rankup_clean_clients_switch'] == 1) {
enter_logfile($cfg,4,$lang['clean']);
$start = $countdel = $countts = 0;
$break=200;
$count_tsuser['count'] = 0;
$clientdblist=array();
enter_logfile($logpath,$timezone,5," Get TS3 Clientlist...");
enter_logfile($cfg,5," Get TS3 Clientlist...");
while($getclientdblist=$ts3->clientListDb($start, $break)) {
check_shutdown($timezone,$logpath);
check_shutdown($cfg);
$dummy = $mysqlcon->query("SELECT * FROM `$dbname`.`job_check`"); //TeamSpeak became very slow on sending dblist with 3.3.0.. needs to hold the connection
$clientdblist=array_merge($clientdblist, $getclientdblist);
$start=$start+$break;
$count_tsuser=array_shift($getclientdblist);
enter_logfile($logpath,$timezone,6," Got TS3 Clientlist ".count($clientdblist)." of ".$count_tsuser['count']." Clients.");
enter_logfile($cfg,6," Got TS3 Clientlist ".count($clientdblist)." of ".$count_tsuser['count']." Clients.");
if($count_tsuser['count'] <= $start) {
break;
}
usleep($slowmode);
usleep($cfg['teamspeak_query_command_delay']);
}
enter_logfile($logpath,$timezone,5," Get TS3 Clientlist [DONE]");
enter_logfile($cfg,5," Get TS3 Clientlist [DONE]");
foreach($clientdblist as $uuidts) {
$single_uuid = $uuidts['client_unique_identifier']->toString();
$uidarrts[$single_uuid]= 1;
@@ -40,8 +40,8 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$c
}
}
unset($uidarrts);
enter_logfile($logpath,$timezone,4," ".sprintf($lang['cleants'], $countts, $count_tsuser['count']));
enter_logfile($logpath,$timezone,4," ".sprintf($lang['cleanrs'], count($select_arr['all_user'])));
enter_logfile($cfg,4," ".sprintf($lang['cleants'], $countts, $count_tsuser['count']));
enter_logfile($cfg,4," ".sprintf($lang['cleanrs'], count($select_arr['all_user'])));
if(isset($deleteuuids)) {
$alldeldata = '';
@@ -64,9 +64,9 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$c
}
if (isset($fsfilelistarray[$uuidasbase16.'.png'])) {
if(unlink($avatarfilepath.$uuidasbase16.'.png') === false) {
enter_logfile($logpath,$timezone,2," ".sprintf($lang['clean0002'], $uuidasbase16, $uuid).' '.sprintf($lang['errperm'], 'avatars'));
enter_logfile($cfg,2," ".sprintf($lang['clean0002'], $uuidasbase16, $uuid).' '.sprintf($lang['errperm'], 'avatars'));
} else {
enter_logfile($logpath,$timezone,4," ".sprintf($lang['clean0001'], $uuidasbase16, $uuid));
enter_logfile($cfg,4," ".sprintf($lang['clean0001'], $uuidasbase16, $uuid));
}
}
}
@@ -75,15 +75,15 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$c
$alldeldata = "(".$alldeldata.")";
if ($alldeldata != '') {
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='clean_clients'; UPDATE `$dbname`.`stats_user` AS `t` LEFT JOIN `$dbname`.`user` AS `u` ON `t`.`uuid`=`u`.`uuid` SET `t`.`removed`='1' WHERE `u`.`uuid` IS NULL; DELETE FROM `$dbname`.`user` WHERE `uuid` IN $alldeldata; ";
enter_logfile($logpath,$timezone,4," ".sprintf($lang['cleandel'], $countdel));
enter_logfile($cfg,4," ".sprintf($lang['cleandel'], $countdel));
unset($$alldeldata);
}
} else {
enter_logfile($logpath,$timezone,4," ".$lang['cleanno']);
enter_logfile($cfg,4," ".$lang['cleanno']);
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='clean_clients'; ";
}
} else {
enter_logfile($logpath,$timezone,4,$lang['clean0004']);
enter_logfile($cfg,4,$lang['clean0004']);
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='clean_clients'; ";
}
}
@@ -91,7 +91,7 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$c
// clean usersnaps older then 1 month + clean old server usage - older then a year
if ($select_arr['job_check']['clean_db']['timestamp'] < ($nowtime - 86400)) {
$sqlexec .= "DELETE `a` FROM `$dbname`.`user_snapshot` AS `a` CROSS JOIN(SELECT DISTINCT(`timestamp`) FROM `$dbname`.`user_snapshot` ORDER BY `timestamp` DESC LIMIT 1000 OFFSET 121) AS `b` WHERE `a`.`timestamp`=`b`.`timestamp`; DELETE FROM `$dbname`.`server_usage` WHERE `timestamp` < (UNIX_TIMESTAMP() - 31536000); DELETE `b` FROM `$dbname`.`user` AS `a` RIGHT JOIN `$dbname`.`stats_user` AS `b` ON `a`.`uuid`=`b`.`uuid` WHERE `a`.`uuid` IS NULL; UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='clean_db'; DELETE FROM `$dbname`.`csrf_token` WHERE `timestamp` < (UNIX_TIMESTAMP() - 3600); ";
enter_logfile($logpath,$timezone,4,$lang['clean0003']);
enter_logfile($cfg,4,$lang['clean0003']);
}
// delete IP address of offline user