release 1.3.21
This commit is contained in:
@@ -92,12 +92,12 @@ function addon_channelinfo_toplist(&$addons_config,$ts3,$mysqlcon,$cfg,$dbname,$
|
||||
$smarty->assign('CLIENT_NEXT_RANKUP_TIME_'.($nr + 1),$userdata[$nr]['nextup']);
|
||||
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_ID_'.($nr + 1),$userdata[$nr]['grpid']);
|
||||
if(isset($db_cache['groups'][$userdata[$nr]['grpid']]['sgidname'])) {
|
||||
if(isset($db_cache['groups'][$userdata[$nr]['grpid']]['sgidname']) && $userdata[$nr]['grpid'] != 0) {
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_NAME_'.($nr + 1),substr($db_cache['groups'][$userdata[$nr]['grpid']]['sgidname'],1,-1));
|
||||
} else {
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_NAME_'.($nr + 1),'unknown_group');
|
||||
}
|
||||
if(isset($db_cache['groups'][$userdata[$nr]['grpid']]['iconid']) && isset($db_cache['groups'][$userdata[$nr]['grpid']]['ext'])) {
|
||||
if(isset($db_cache['groups'][$userdata[$nr]['grpid']]['iconid']) && isset($db_cache['groups'][$userdata[$nr]['grpid']]['ext']) && $userdata[$nr]['grpid'] != 0) {
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_ICON_URL_'.($nr + 1),'tsicons/'.$db_cache['groups'][$userdata[$nr]['grpid']]['iconid'].'.'.$db_cache['groups'][$userdata[$nr]['grpid']]['ext']);
|
||||
} else {
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_ICON_URL_'.($nr + 1),'file_not_found');
|
||||
|
||||
@@ -145,7 +145,7 @@ function run_bot(&$cfg) {
|
||||
|
||||
enter_logfile($cfg,9," Select virtual server...");
|
||||
try {
|
||||
if(version_compare($ts3version['version'],'3.4.0','>=')) {
|
||||
if(version_compare($ts3version['version'],'3.4.0','>=') || version_compare($ts3version['version'],'3.0.0','<=')) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$ts3server = $ts3host->serverGetByPort($cfg['teamspeak_voice_port'], $cfg['teamspeak_query_nickname']);
|
||||
} else {
|
||||
|
||||
@@ -408,8 +408,6 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$cfg['temp_db_version']
|
||||
);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
|
||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
@@ -435,14 +433,20 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
}
|
||||
|
||||
//Calc Rank
|
||||
$dbversion = $mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
preg_match("/^[0-9\.-]+/", $dbversion, $version_number);
|
||||
if ($cfg['rankup_time_assess_mode'] == 1) {
|
||||
$sqlexec .= "SET @a:=0;\nUPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT @a:=@a+1 `nr`,`uuid` FROM `$dbname`.`user` WHERE `except`<2 ORDER BY (`count` - `idle`) DESC) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`nr`;\n";
|
||||
//MySQL 8 or above
|
||||
//UPDATE `user` AS `u` INNER JOIN (SELECT RANK() OVER (ORDER BY (`count` - `idle`) DESC) AS `rank`, `uuid` FROM `$dbname`.`user` WHERE `except`<2) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`rank`;
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '5.5.5-10.6', '>=')) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT RANK() OVER (ORDER BY (`count` - `idle`) DESC) AS `rank`, `uuid` FROM `$dbname`.`user` WHERE `except`<2) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`rank`;\n";
|
||||
} else {
|
||||
$sqlexec .= "SET @a:=0;\nUPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT @a:=@a+1 `nr`,`uuid` FROM `$dbname`.`user` WHERE `except`<2 ORDER BY (`count` - `idle`) DESC) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`nr`;\n";
|
||||
}
|
||||
} else {
|
||||
$sqlexec .= "SET @a:=0;\nUPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT @a:=@a+1 `nr`,`uuid` FROM `$dbname`.`user` WHERE `except`<2 ORDER BY `count` DESC) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`nr`;\n";
|
||||
//MySQL 8 or above
|
||||
//UPDATE `user` AS `u` INNER JOIN (SELECT RANK() OVER (ORDER BY `count` DESC) AS `rank`, `uuid` FROM `$dbname`.`user` WHERE `except`<2) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`rank`;
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '5.5.5-10.6', '>=')) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT RANK() OVER (ORDER BY `count` DESC) AS `rank`, `uuid` FROM `$dbname`.`user` WHERE `except`<2) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`rank`;\n";
|
||||
} else {
|
||||
$sqlexec .= "SET @a:=0;\nUPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT @a:=@a+1 `nr`,`uuid` FROM `$dbname`.`user` WHERE `except`<2 ORDER BY `count` DESC) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`nr`;\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
$name = $mysqlcon->quote((mb_substr(mb_convert_encoding($client['client_nickname'],'UTF-8','auto'),0,30)), ENT_QUOTES);
|
||||
$uid = htmlspecialchars($client['client_unique_identifier'], ENT_QUOTES);
|
||||
$sgroups = array_flip(explode(",", $client['client_servergroups']));
|
||||
if(strlen($client['client_country']) > 2 || $client['client_country'] == '') $client['client_country'] = 'XX';
|
||||
if($client['client_country'] !== NULL && strlen($client['client_country']) > 2 || $client['client_country'] === NULL) $client['client_country'] = 'XX';
|
||||
$client['client_platform'] = mb_substr($client['client_platform'],0,32);
|
||||
$client['client_version'] = mb_substr($client['client_version'],0,64);
|
||||
|
||||
@@ -108,17 +108,18 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
if(isset($db_cache['all_user'][$uid]['except']) && ($db_cache['all_user'][$uid]['except'] == 3 || $db_cache['all_user'][$uid]['except'] == 2) && $cfg['rankup_excepted_mode'] == 2) {
|
||||
$db_cache['all_user'][$uid]['count'] = 0;
|
||||
$db_cache['all_user'][$uid]['idle'] = 0;
|
||||
enter_logfile($cfg,5,sprintf($lang['resettime'], $name, $uid, $client['client_database_id']));
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`user_snapshot` WHERE `uuid`='$uid';\n";
|
||||
enter_logfile($cfg,5,sprintf($lang['resettime'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`user_snapshot` WHERE `cldbid`='{$client['client_database_id']}';\n";
|
||||
}
|
||||
$except = 0;
|
||||
}
|
||||
if(isset($db_cache['all_user'][$uid])) {
|
||||
$idle = $db_cache['all_user'][$uid]['idle'] + $clientidle;
|
||||
if ($db_cache['all_user'][$uid]['cldbid'] != $client['client_database_id'] && $cfg['rankup_client_database_id_change_switch'] == 1) {
|
||||
enter_logfile($cfg,5,sprintf($lang['changedbid'], $name, $uid, $client['client_database_id'], $db_cache['all_user'][$uid]['cldbid']));
|
||||
enter_logfile($cfg,5,sprintf($lang['changedbid'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['all_user'][$uid]['cldbid']));
|
||||
$count = 1;
|
||||
$idle = 0;
|
||||
$boosttime = 0;
|
||||
} else {
|
||||
$hitboost = 0;
|
||||
$boosttime = $db_cache['all_user'][$uid]['boosttime'];
|
||||
@@ -129,14 +130,15 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
if($db_cache['all_user'][$uid]['boosttime']==0) {
|
||||
$boosttime = $nowtime;
|
||||
} else {
|
||||
if ($nowtime > $db_cache['all_user'][$uid]['boosttime'] + $boost['time']) {
|
||||
if ($nowtime > $db_cache['all_user'][$uid]['boosttime'] + $boost['time'] && (!isset($db_cache['all_user'][$uid]['grouperror']) || $db_cache['all_user'][$uid]['grouperror'] < ($nowtime - 300))) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($boost['group'], $client['client_database_id']);
|
||||
$boosttime = 0;
|
||||
enter_logfile($cfg,5,sprintf($lang['sgrprm'], $db_cache['groups'][$boost['group']]['sgidname'], $boost['group'], $name, $uid, $client['client_database_id']).' [Boost-Group]');
|
||||
enter_logfile($cfg,5,sprintf($lang['sgrprm'], $db_cache['groups'][$boost['group']]['sgidname'], $boost['group'], $client['client_nickname'], $uid, $client['client_database_id']).' [Boost-Group]');
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $client['client_database_id'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid']));
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid']));
|
||||
$db_cache['all_user'][$uid]['grouperror'] = $nowtime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,31 +191,35 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
$donotremove = 1; break;
|
||||
}
|
||||
}
|
||||
if($donotremove == 0) {
|
||||
if($donotremove == 0 && (!isset($db_cache['all_user'][$uid]['grouperror']) || $db_cache['all_user'][$uid]['grouperror'] < ($nowtime - 300))) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($db_cache['all_user'][$uid]['grpid'], $client['client_database_id']);
|
||||
enter_logfile($cfg,5,sprintf($lang['sgrprm'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid'], $name, $uid, $client['client_database_id']));
|
||||
enter_logfile($cfg,5,sprintf($lang['sgrprm'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
if(isset($client_groups_rankup[$db_cache['all_user'][$uid]['grpid']])) unset($client_groups_rankup[$db_cache['all_user'][$uid]['grpid']]);
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $client['client_database_id'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid']));
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid']));
|
||||
$db_cache['all_user'][$uid]['grouperror'] = $nowtime;
|
||||
}
|
||||
}
|
||||
}
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->serverGroupClientAdd($rank['group'], $client['client_database_id']);
|
||||
$db_cache['all_user'][$uid]['grpsince'] = $nowtime;
|
||||
enter_logfile($cfg,5,sprintf($lang['sgrpadd'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group'], $name, $uid, $client['client_database_id']));
|
||||
if ($cfg['rankup_message_to_user_switch'] == 1) {
|
||||
$days = $dtF->diff($dtT)->format('%a');
|
||||
$hours = $dtF->diff($dtT)->format('%h');
|
||||
$mins = $dtF->diff($dtT)->format('%i');
|
||||
$secs = $dtF->diff($dtT)->format('%s');
|
||||
sendmessage($ts3, $cfg, $uid, sprintf($cfg['rankup_message_to_user'],$days,$hours,$mins,$secs,$db_cache['groups'][$rank['group']]['sgidname'],$client['client_nickname']), 1, NULL, sprintf($lang['sgrprerr'], $name, $uid, $client['client_database_id'], $db_cache['groups'][$rank['group']]['sgidname'],$rank['group']), 2);
|
||||
if(!isset($db_cache['all_user'][$uid]['grouperror']) || $db_cache['all_user'][$uid]['grouperror'] < ($nowtime - 300)) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->serverGroupClientAdd($rank['group'], $client['client_database_id']);
|
||||
$db_cache['all_user'][$uid]['grpsince'] = $nowtime;
|
||||
enter_logfile($cfg,5,sprintf($lang['sgrpadd'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
if ($cfg['rankup_message_to_user_switch'] == 1) {
|
||||
$days = $dtF->diff($dtT)->format('%a');
|
||||
$hours = $dtF->diff($dtT)->format('%h');
|
||||
$mins = $dtF->diff($dtT)->format('%i');
|
||||
$secs = $dtF->diff($dtT)->format('%s');
|
||||
sendmessage($ts3, $cfg, $uid, sprintf($cfg['rankup_message_to_user'],$days,$hours,$mins,$secs,$db_cache['groups'][$rank['group']]['sgidname'],$client['client_nickname']), 1, NULL, sprintf($lang['sgrprerr'], $name, $uid, $client['client_database_id'], $db_cache['groups'][$rank['group']]['sgidname'],$rank['group']), 2);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group']));
|
||||
$db_cache['all_user'][$uid]['grouperror'] = $nowtime;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $client['client_database_id'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group']));
|
||||
}
|
||||
}
|
||||
if($grpcount == 1) {
|
||||
@@ -227,13 +233,14 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
}
|
||||
|
||||
foreach($client_groups_rankup as $removegroup => $dummy) {
|
||||
if($removegroup != NULL && $removegroup != 0 && $removegroup != $db_cache['all_user'][$uid]['grpid']){
|
||||
if($removegroup != NULL && $removegroup != 0 && $removegroup != $db_cache['all_user'][$uid]['grpid'] && (!isset($db_cache['all_user'][$uid]['grouperror']) || $db_cache['all_user'][$uid]['grouperror'] < ($nowtime - 300))){
|
||||
try {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$ts3->serverGroupClientDel($removegroup, $client['client_database_id']);
|
||||
enter_logfile($cfg,5,sprintf("Removed WRONG servergroup %s (ID: %s) from user %s (unique Client-ID: %s; Client-database-ID %s).", $db_cache['groups'][$removegroup]['sgidname'], $removegroup, $name, $uid, $client['client_database_id']));
|
||||
enter_logfile($cfg,5,sprintf("Removed WRONG servergroup %s (ID: %s) from user %s (unique Client-ID: %s; Client-database-ID %s).", $db_cache['groups'][$removegroup]['sgidname'], $removegroup, $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $client['client_database_id'], $db_cache['groups'][$removegroup]['sgidname'], $removegroup));
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$removegroup]['sgidname'], $removegroup));
|
||||
$db_cache['all_user'][$uid]['grouperror'] = $nowtime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -295,7 +302,7 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
$db_cache['all_user'][$uid]['boosttime'] = 0;
|
||||
$db_cache['all_user'][$uid]['grpsince'] = 0;
|
||||
$db_cache['all_user'][$uid]['except'] = $except;
|
||||
enter_logfile($cfg,5,sprintf($lang['adduser'], $name, $uid, $client['client_database_id']));
|
||||
enter_logfile($cfg,5,sprintf($lang['adduser'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
}
|
||||
$db_cache['all_user'][$uid]['name'] = $client['client_nickname'];
|
||||
$db_cache['all_user'][$uid]['lastseen'] = $nowtime;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?PHP
|
||||
function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,&$db_cache) {
|
||||
function calc_userstats($ts3,$mysqlcon,&$cfg,$dbname,&$db_cache) {
|
||||
$starttime = microtime(true);
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
@@ -72,7 +72,11 @@ function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,&$db_cache) {
|
||||
|
||||
try {
|
||||
$clientinfo = $ts3->clientInfoDb($userstats['cldbid']);
|
||||
$clientdesc = $mysqlcon->quote($clientinfo['client_description'], ENT_QUOTES);
|
||||
if($clientinfo['client_description'] !== NULL) {
|
||||
$clientdesc = $mysqlcon->quote($clientinfo['client_description'], ENT_QUOTES);
|
||||
} else {
|
||||
$clientdesc = "NULL";
|
||||
}
|
||||
if($clientinfo['client_totalconnections'] > 16777215) $clientinfo['client_totalconnections'] = 16777215;
|
||||
} catch (Exception $e) {
|
||||
if($e->getCode() == 512 || $e->getCode() == 1281) {
|
||||
@@ -81,8 +85,8 @@ function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,&$db_cache) {
|
||||
$getcldbid = $ts3->clientFindDb($uuid, TRUE);
|
||||
if($getcldbid[0] != $userstats['cldbid']) {
|
||||
enter_logfile($cfg,4," Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") known by the Ranksystem changed its cldbid. New cldbid is ".$getcldbid[0].".");
|
||||
$db_cache['all_user'][$uuid]['cldbid'] = $getcldbid[0];
|
||||
if($cfg['rankup_client_database_id_change_switch'] == 1) {
|
||||
$db_cache['all_user'][$uuid]['cldbid'] = $getcldbid[0];
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` SET `count`=0,`idle`=0 WHERE `uuid`='$uuid';\nUPDATE `$dbname`.`stats_user` SET `count_week`=0,`count_month`=0,`idle_week`=0,`idle_month`=0,`active_week`=0,`active_month`=0 WHERE `uuid`='$uuid';\nDELETE FROM `$dbname`.`user_snapshot` WHERE `cldbid`='{$userstats['cldbid']}';\n";
|
||||
enter_logfile($cfg,4," ".sprintf($lang['changedbid'], $userstats['name'], $uuid, $userstats['cldbid'], $getcldbid[0]));
|
||||
} else {
|
||||
@@ -116,7 +120,7 @@ function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,&$db_cache) {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.$e->getMessage()."; Error due command clientdbinfo for client-database-ID {$userstats['cldbid']} (permission: b_virtualserver_client_dbinfo needed).");
|
||||
}
|
||||
|
||||
$clientdesc = $clientinfo['client_base64HashClientUID'] = $mysqlcon->quote('', ENT_QUOTES);
|
||||
$clientdesc = $clientinfo['client_base64HashClientUID'] = "NULL";
|
||||
$clientinfo['client_totalconnections'] = $clientinfo['client_total_bytes_uploaded'] = $clientinfo['client_total_bytes_downloaded'] = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
$cfg['version_latest_available'] = '1.3.19';
|
||||
$cfg['version_latest_available'] = '1.3.21';
|
||||
enter_logfile($cfg,5,"Check Ranksystem database for updates...");
|
||||
|
||||
function check_double_cldbid($mysqlcon,$cfg,$dbname) {
|
||||
@@ -492,24 +492,27 @@ last seen {$CLIENT_LAST_SEEN_10|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`admin_addtime`;") === false) { }
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`addon_assign_groups`;") === false) { }
|
||||
|
||||
try {
|
||||
if($mysqlcon->exec("CREATE INDEX `serverusage_timestamp` ON `$dbname`.`server_usage` (`timestamp`)") === false) { }
|
||||
if($mysqlcon->exec("CREATE INDEX `user_version` ON `$dbname`.`user` (`version`)") === false) { }
|
||||
if($mysqlcon->exec("CREATE INDEX `user_cldbid` ON `$dbname`.`user` (`cldbid` ASC,`uuid`,`rank`)") === false) { }
|
||||
if($mysqlcon->exec("CREATE INDEX `user_online` ON `$dbname`.`user` (`online`,`lastseen`)") === false) { }
|
||||
} catch (Exception $e) { }
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.19', '<')) {
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`addons_config` MODIFY COLUMN `value` varchar(16000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.19] Adjusted table addons_config successfully.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.20', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('clean_user_iphash', '0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`);") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.20] Added new job_check values.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.21', '<')) {
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`admin_addtime`;") === false) { }
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`addon_assign_groups`;") === false) { }
|
||||
|
||||
try {
|
||||
if($mysqlcon->exec("CREATE INDEX `snapshot_id` ON `$dbname`.`user_snapshot` (`id`)") === false) { }
|
||||
if($mysqlcon->exec("CREATE INDEX `snapshot_cldbid` ON `$dbname`.`user_snapshot` (`cldbid`)") === false) { }
|
||||
if($mysqlcon->exec("CREATE INDEX `serverusage_timestamp` ON `$dbname`.`server_usage` (`timestamp`)") === false) { }
|
||||
if($mysqlcon->exec("CREATE INDEX `user_version` ON `$dbname`.`user` (`version`)") === false) { }
|
||||
if($mysqlcon->exec("CREATE INDEX `user_cldbid` ON `$dbname`.`user` (`cldbid` ASC,`uuid`,`rank`)") === false) { }
|
||||
|
||||
@@ -94,6 +94,25 @@ function clean($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`server_usage` WHERE `timestamp` < (UNIX_TIMESTAMP() - 31536000);\nDELETE `b` FROM `$dbname`.`user` AS `a` RIGHT JOIN `$dbname`.`stats_user` AS `b` ON `a`.`uuid`=`b`.`uuid` WHERE `a`.`uuid` IS NULL;\nUPDATE `$dbname`.`job_check` SET `timestamp`='{$nowtime}' WHERE `job_name`='clean_db';\nDELETE FROM `$dbname`.`csrf_token` WHERE `timestamp` < (UNIX_TIMESTAMP() - 3600);\nDELETE `h` FROM `$dbname`.`user_iphash` AS `h` LEFT JOIN `$dbname`.`user` AS `u` ON `u`.`uuid` = `h`.`uuid` WHERE (`u`.`uuid` IS NULL OR `u`.`online`!=1);\n";
|
||||
enter_logfile($cfg,4,$lang['clean0003']);
|
||||
}
|
||||
|
||||
// clean user_iphash
|
||||
if ($db_cache['job_check']['clean_user_iphash']['timestamp'] < ($nowtime - 3500)) {
|
||||
if(($sqlhashs = $mysqlcon->query("SELECT * FROM `$dbname`.`user_iphash`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
enter_logfile($cfg,2,"clean user_iphash:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$rem_uuids = '';
|
||||
foreach($sqlhashs as $uuid => $values) {
|
||||
if(isset($db_cache['all_user'][$uuid]) && $db_cache['all_user'][$uuid]['lastseen'] < ($nowtime - 100)) {
|
||||
$rem_uuids .= "'".$uuid."',";
|
||||
}
|
||||
}
|
||||
if($rem_uuids != '') {
|
||||
$rem_uuids = substr($rem_uuids, 0, -1);
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`user_iphash` WHERE `uuid` IN ({$rem_uuids});\n";
|
||||
}
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='clean_user_iphash';\n";
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"clean needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?PHP
|
||||
function db_ex_imp($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
$starttime = microtime(true);
|
||||
#enter_logfile($cfg,5," started DB Export");
|
||||
|
||||
if (in_array($db_cache['job_check']['database_export']['timestamp'], ["1","2"], true)) {
|
||||
if (in_array($db_cache['job_check']['database_export']['timestamp'], ["1","2"])) {
|
||||
|
||||
enter_logfile($cfg,4,"DB Export job(s) started");
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
$iconid = ($iconid < 0) ? (pow(2, 32)) - ($iconid * -1) : $iconid;
|
||||
$iconfile = 0;
|
||||
if($iconid > 600) {
|
||||
if (!isset($db_cache['groups'][$sgid]) || $db_cache['groups'][$sgid]['iconid'] != $iconid || $iconarr["i".$iconid] > $db_cache['groups'][$sgid]['icondate']) {
|
||||
if (!isset($db_cache['groups'][$sgid]) || $db_cache['groups'][$sgid]['iconid'] != $iconid || isset($iconarr["i".$iconid]) && $iconarr["i".$iconid] > $db_cache['groups'][$sgid]['icondate']) {
|
||||
try {
|
||||
check_shutdown($cfg); usleep($cfg['teamspeak_query_command_delay']);
|
||||
enter_logfile($cfg,5,sprintf($lang['upgrp0011'], $sgname, $sgid));
|
||||
|
||||
Reference in New Issue
Block a user