release 1.3.1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?PHP
|
||||
function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,$select_arr) {
|
||||
$starttime = microtime(true);
|
||||
$sqlexec = '';
|
||||
$max_timestamp = key($select_arr['max_timestamp_user_snapshot']);
|
||||
$min_timestamp_week = key($select_arr['usersnap_min_week']);
|
||||
@@ -20,6 +21,7 @@ function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,$select_arr) {
|
||||
foreach ($sqlhis as $uuid => $userstats) {
|
||||
$uuids .= "'".$uuid."',";
|
||||
}
|
||||
unset($userstats,$uuid);
|
||||
$uuids = substr($uuids, 0, -1);
|
||||
|
||||
if(isset($sqlhis) && $max_timestamp != NULL && $min_timestamp_week != NULL && $min_timestamp_month != NULL) {
|
||||
@@ -34,6 +36,7 @@ function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,$select_arr) {
|
||||
enter_logfile($cfg,2,"calc_userstats 7:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
unset($uuids,$job_begin,$max_timestamp,$min_timestamp_week,$min_timestamp_month);
|
||||
$allupdateuuid = '';
|
||||
|
||||
foreach ($sqlhis as $uuid => $userstats) {
|
||||
@@ -60,21 +63,48 @@ function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,$select_arr) {
|
||||
$active_month = 0;
|
||||
}
|
||||
$clientdesc = $mysqlcon->quote($clientinfo['client_description'], ENT_QUOTES);;
|
||||
$allupdateuuid .= "('" . $uuid . "','" .$userstats['rank'] . "','" . $count_week . "','" . $count_month . "','" . $idle_week . "','" . $idle_month . "','" . $active_week . "','" . $active_month . "','" . $clientinfo['client_totalconnections'] . "','" . $clientinfo['client_base64HashClientUID'] . "','" . $clientinfo['client_total_bytes_uploaded'] . "','" . $clientinfo['client_total_bytes_downloaded'] . "'," . $clientdesc . "),";
|
||||
$allupdateuuid .= "('$uuid',$count_week,$count_month,$idle_week,$idle_month,$active_week,$active_month,{$clientinfo['client_totalconnections']},'{$clientinfo['client_base64HashClientUID']}',{$clientinfo['client_total_bytes_uploaded']},{$clientinfo['client_total_bytes_downloaded']},$clientdesc),";
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,6,$e->getCode() . ': ' . $e->getMessage()."; Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") was missing in TS database, perhaps its already deleted. Run !clean to correct this.");
|
||||
if($e->getCode() == 512) {
|
||||
enter_logfile($cfg,6,"Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") known by Ranksystem is missing in TS database, perhaps its already deleted or cldbid changed. Try to search for client by uuid.");
|
||||
try {
|
||||
$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].".");
|
||||
if($cfg['rankup_client_database_id_change_switch'] == 1) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` SET `count`=0,`idle`=0 WHERE `uuid`='$uuid'; UPDATE `$dbname`.`stats_user` SET `count_week`=0,`count_month`=0,`idle_week`=0,`idle_month`=0,`achiev_time`=0,`achiev_time_perc`=0,`active_week`=0,`active_month`=0 WHERE `uuid`='$uuid'; DELETE FROM `$dbname`.`user_snapshot` WHERE `uuid`='$uuid'; ";
|
||||
enter_logfile($cfg,4," ".sprintf($lang['changedbid'], $userstats['name'], $uuid, $userstats['cldbid'], $getcldbid[0]));
|
||||
} else {
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` SET `cldbid`={$getcldbid[0]} WHERE `uuid`='$uuid'; ";
|
||||
enter_logfile($cfg,4," Store new cldbid ".$getcldbid[0]." for client (uuid: ".$uuid." old cldbid: ".$userstats['cldbid'].")");
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,3," Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") is missing in TS database, but TeamSpeak answers on question with the same cldbid (".$getcldbid[0].").. It's weird!");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
if($e->getCode() == 2568) {
|
||||
enter_logfile($cfg,4,$e->getCode() . ': ' . $e->getMessage()."; Error due command clientdbfind (permission: b_virtualserver_client_dbsearch needed).");
|
||||
} else {
|
||||
enter_logfile($cfg,6,$e->getCode() . ': ' . $e->getMessage()."; Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") is missing in TS database, it seems to be deleted. Run !clean to correct this.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.$e->getMessage()."; Error due command clientdbinfo (permission: b_virtualserver_client_dbinfo needed).");
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($sqlhis, $userdataweekbegin, $userdataend, $userdatamonthbegin);
|
||||
unset($sqlhis,$userdataweekbegin,$userdataend,$userdatamonthbegin,$clientinfo,$count_week,$idle_week,$active_week,$count_month,$idle_month,$active_month,$clientdesc);
|
||||
|
||||
if ($allupdateuuid != '') {
|
||||
$allupdateuuid = substr($allupdateuuid, 0, -1);
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$job_end WHERE `job_name`='calc_user_limit'; INSERT INTO `$dbname`.`stats_user` (`uuid`,`rank`,`count_week`,`count_month`,`idle_week`,`idle_month`,`active_week`,`active_month`,`total_connections`,`base64hash`,`client_total_up`,`client_total_down`,`client_description`) VALUES $allupdateuuid ON DUPLICATE KEY UPDATE `rank`=VALUES(`rank`),`count_week`=VALUES(`count_week`),`count_month`=VALUES(`count_month`),`idle_week`=VALUES(`idle_week`),`idle_month`=VALUES(`idle_month`),`active_week`=VALUES(`active_week`),`active_month`=VALUES(`active_month`),`total_connections`=VALUES(`total_connections`),`base64hash`=VALUES(`base64hash`),`client_total_up`=VALUES(`client_total_up`),`client_total_down`=VALUES(`client_total_down`),`client_description`=VALUES(`client_description`); ";
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$job_end WHERE `job_name`='calc_user_limit'; INSERT INTO `$dbname`.`stats_user` (`uuid`,`count_week`,`count_month`,`idle_week`,`idle_month`,`active_week`,`active_month`,`total_connections`,`base64hash`,`client_total_up`,`client_total_down`,`client_description`) VALUES $allupdateuuid ON DUPLICATE KEY UPDATE `count_week`=VALUES(`count_week`),`count_month`=VALUES(`count_month`),`idle_week`=VALUES(`idle_week`),`idle_month`=VALUES(`idle_month`),`active_week`=VALUES(`active_week`),`active_month`=VALUES(`active_month`),`total_connections`=VALUES(`total_connections`),`base64hash`=VALUES(`base64hash`),`client_total_up`=VALUES(`client_total_up`),`client_total_down`=VALUES(`client_total_down`),`client_description`=VALUES(`client_description`); ";
|
||||
unset($allupdateuuid);
|
||||
} else {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$job_end WHERE `job_name`='calc_user_limit'; ";
|
||||
}
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"calc_userstats needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user