release 1.2.7
This commit is contained in:
@@ -1,271 +1,242 @@
|
||||
<?PHP
|
||||
function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid,$resetexcept,$phpcommand,$select_arr) {
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
if(empty($grouptime)) {
|
||||
enter_logfile($logpath,$timezone,1,"calc_user:".$lang['wiconferr']."Shuttin down!\n\n");
|
||||
exit;
|
||||
}
|
||||
if($select_arr['job_check']['calc_user_lastscan']['timestamp'] < ($nowtime - 1800)) {
|
||||
enter_logfile($logpath,$timezone,4,"Much time gone since last scan.. reset time difference to zero.");
|
||||
$select_arr['job_check']['calc_user_lastscan']['timestamp'] = $nowtime;
|
||||
} elseif($select_arr['job_check']['calc_user_lastscan']['timestamp'] > $nowtime) {
|
||||
enter_logfile($logpath,$timezone,4,"Negative time between now and last scan (Error in your server time!).. reset time difference to zero.");
|
||||
$select_arr['job_check']['calc_user_lastscan']['timestamp'] = $nowtime;
|
||||
}
|
||||
|
||||
$sqlexec .= "UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='calc_user_lastscan'; ";
|
||||
|
||||
krsort($grouptime);
|
||||
$yetonline = array();
|
||||
$insertdata = array();
|
||||
$updatedata = array();
|
||||
|
||||
foreach ($allclients as $client) {
|
||||
$cldbid = $client['client_database_id'];
|
||||
$name = $mysqlcon->quote($client['client_nickname'], ENT_QUOTES);
|
||||
$uid = htmlspecialchars($client['client_unique_identifier'], ENT_QUOTES);
|
||||
$sgroups = array_flip(explode(",", $client['client_servergroups']));
|
||||
if (!isset($yetonline[$uid]) && $client['client_version'] != "ServerQuery") {
|
||||
if(strstr($client['connection_client_ip'], '[')) {
|
||||
$ip = $mysqlcon->quote(inet_pton(str_replace(array('[',']'),'',$client['connection_client_ip'])), ENT_QUOTES);
|
||||
} else {
|
||||
$ip = $mysqlcon->quote(inet_pton($client['connection_client_ip']), ENT_QUOTES);
|
||||
}
|
||||
$clientidle = floor($client['client_idle_time'] / 1000);
|
||||
if(isset($ignoreidle) && $clientidle < $ignoreidle) {
|
||||
$clientidle = 0;
|
||||
}
|
||||
$yetonline[$uid] = 0;
|
||||
if(isset($exceptuuid[$uid])) {
|
||||
$except = 3;
|
||||
} elseif(array_intersect_key($sgroups, $exceptgroup)) {
|
||||
$except = 2;
|
||||
} else {
|
||||
if(isset($select_arr['all_user'][$uid]['except']) && ($select_arr['all_user'][$uid]['except'] == 3 || $select_arr['all_user'][$uid]['except'] == 2) && $resetexcept == 2) {
|
||||
$select_arr['all_user'][$uid]['count'] = 0;
|
||||
$select_arr['all_user'][$uid]['idle'] = 0;
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['resettime'], $name, $uid, $cldbid));
|
||||
$sqlexec .= "DELETE FROM $dbname.user_snapshot WHERE uuid='$uid'; ";
|
||||
}
|
||||
$except = 0;
|
||||
}
|
||||
if(isset($select_arr['all_user'][$uid])) {
|
||||
$idle = $select_arr['all_user'][$uid]['idle'] + $clientidle;
|
||||
$grpid = $select_arr['all_user'][$uid]['grpid'];
|
||||
$nextup = $select_arr['all_user'][$uid]['nextup'];
|
||||
$grpsince = $select_arr['all_user'][$uid]['grpsince'];
|
||||
if ($select_arr['all_user'][$uid]['cldbid'] != $cldbid && $resetbydbchange == 1) {
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['changedbid'], $name, $uid, $cldbid, $select_arr['all_user'][$uid]['cldbid']));
|
||||
$count = 1;
|
||||
$idle = 0;
|
||||
} else {
|
||||
$hitboost = 0;
|
||||
$boosttime = $select_arr['all_user'][$uid]['boosttime'];
|
||||
if($boostarr!=0) {
|
||||
foreach($boostarr as $boost) {
|
||||
if(isset($sgroups[$boost['group']])) {
|
||||
$hitboost = 1;
|
||||
if($select_arr['all_user'][$uid]['boosttime']==0) {
|
||||
$boosttime = $nowtime;
|
||||
} else {
|
||||
if ($nowtime > $select_arr['all_user'][$uid]['boosttime'] + $boost['time']) {
|
||||
usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($boost['group'], $cldbid);
|
||||
$boosttime = 0;
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrprm'], $select_arr['groups'][$select_arr['all_user'][$uid]['grpid']]['sgidname'], $select_arr['all_user'][$uid]['grpid'], $name, $uid, $cldbid));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $cldbid, $select_arr['groups'][$select_arr['all_user'][$uid]['grpid']]['sgidname'], $select_arr['all_user'][$uid]['grpid']));
|
||||
}
|
||||
}
|
||||
}
|
||||
$count = ($nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp']) * $boost['factor'] + $select_arr['all_user'][$uid]['count'];
|
||||
if ($clientidle > ($nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp'])) {
|
||||
$idle = ($nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp']) * $boost['factor'] + $select_arr['all_user'][$uid]['idle'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($boostarr == 0 or $hitboost == 0) {
|
||||
$count = $nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp'] + $select_arr['all_user'][$uid]['count'];
|
||||
if ($clientidle > ($nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp'])) {
|
||||
$idle = $nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp'] + $select_arr['all_user'][$uid]['idle'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$dtF = new DateTime("@0");
|
||||
if ($substridle == 1) {
|
||||
$activetime = $count - $idle;
|
||||
} else {
|
||||
$activetime = $count;
|
||||
}
|
||||
$dtT = new DateTime("@$activetime");
|
||||
foreach ($grouptime as $time => $groupid) {
|
||||
if (isset($sgroups[$groupid])) {
|
||||
$grpid = $groupid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$grpcount=0;
|
||||
foreach ($grouptime as $time => $groupid) {
|
||||
$grpcount++;
|
||||
if(isset($exceptcid[$client['cid']]) || (($select_arr['all_user'][$uid]['except'] == 3 || $select_arr['all_user'][$uid]['except'] == 2) && $resetexcept == 1)) {
|
||||
$count = $select_arr['all_user'][$uid]['count'];
|
||||
$idle = $select_arr['all_user'][$uid]['idle'];
|
||||
if($except != 2 && $except != 3) {
|
||||
$except = 1;
|
||||
}
|
||||
} elseif ($activetime > $time && !isset($exceptuuid[$uid]) && !array_intersect_key($sgroups, $exceptgroup)) {
|
||||
if ($select_arr['all_user'][$uid]['grpid'] != $groupid) {
|
||||
if ($select_arr['all_user'][$uid]['grpid'] != NULL && isset($sgroups[$select_arr['all_user'][$uid]['grpid']])) {
|
||||
usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($select_arr['all_user'][$uid]['grpid'], $cldbid);
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrprm'], $select_arr['groups'][$select_arr['all_user'][$uid]['grpid']]['sgidname'], $select_arr['all_user'][$uid]['grpid'], $name, $uid, $cldbid));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $cldbid, $select_arr['groups'][$groupid]['sgidname'], $groupid));
|
||||
}
|
||||
}
|
||||
if (!isset($sgroups[$groupid])) {
|
||||
usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientAdd($groupid, $cldbid);
|
||||
$grpsince = $nowtime;
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrpadd'], $select_arr['groups'][$groupid]['sgidname'], $groupid, $name, $uid, $cldbid));
|
||||
|
||||
if($nowtime >= 1522540800 && $nowtime <= 1522627199 && $slowmode == 0) {
|
||||
try {
|
||||
foreach($ts3->channelList() as $channel) {
|
||||
try {
|
||||
$ts3->clientMove($client['clid'],$channel['cid']);
|
||||
} catch (Exception $e) { }
|
||||
}
|
||||
try {
|
||||
$ts3->clientMove($client['clid'],$client['cid']);
|
||||
} catch (Exception $e) { }
|
||||
$msg_temp = base64_decode("SGFwcHkgQXByaWwgRm9vbHMnIERheSE=");
|
||||
try {
|
||||
$ts3->clientGetByUid($uid)->message($msg_temp);
|
||||
} catch (Exception $e) { }
|
||||
} catch (Exception $e) { }
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $cldbid, $select_arr['groups'][$groupid]['sgidname'], $groupid));
|
||||
}
|
||||
}
|
||||
$grpid = $groupid;
|
||||
if ($msgtouser == 1) {
|
||||
usleep($slowmode);
|
||||
$days = $dtF->diff($dtT)->format('%a');
|
||||
$hours = $dtF->diff($dtT)->format('%h');
|
||||
$mins = $dtF->diff($dtT)->format('%i');
|
||||
$secs = $dtF->diff($dtT)->format('%s');
|
||||
try {
|
||||
$ts3->clientGetByUid($uid)->message(sprintf($rankupmsg, $days, $hours, $mins, $secs, $select_arr['groups'][$groupid]['sgidname'], $client['client_nickname']));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $cldbid, $select_arr['groups'][$groupid]['sgidname'], $groupid));
|
||||
}
|
||||
}
|
||||
}
|
||||
if($grpcount == 1) {
|
||||
$nextup = 0;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
$nextup = $time - $activetime;
|
||||
}
|
||||
}
|
||||
$updatedata[] = array(
|
||||
"uuid" => $mysqlcon->quote($client['client_unique_identifier'], ENT_QUOTES),
|
||||
"cldbid" => $cldbid,
|
||||
"count" => $count,
|
||||
"ip" => $ip,
|
||||
"name" => $name,
|
||||
"lastseen" => $nowtime,
|
||||
"grpid" => $grpid,
|
||||
"nextup" => $nextup,
|
||||
"idle" => $idle,
|
||||
"cldgroup" => $client['client_servergroups'],
|
||||
"boosttime" => $boosttime,
|
||||
"platform" => $client['client_platform'],
|
||||
"nation" => $client['client_country'],
|
||||
"version" => $client['client_version'],
|
||||
"except" => $except,
|
||||
"grpsince" => $grpsince,
|
||||
"cid" => $client['cid']
|
||||
);
|
||||
} else {
|
||||
$grpid = '0';
|
||||
foreach ($grouptime as $time => $groupid) {
|
||||
if (isset($sgroups[$groupid])) {
|
||||
$grpid = $groupid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$insertdata[] = array(
|
||||
"uuid" => $mysqlcon->quote($client['client_unique_identifier'], ENT_QUOTES),
|
||||
"cldbid" => $cldbid,
|
||||
"ip" => $ip,
|
||||
"name" => $name,
|
||||
"lastseen" => $nowtime,
|
||||
"grpid" => $grpid,
|
||||
"nextup" => (key($grouptime) - 1),
|
||||
"cldgroup" => $client['client_servergroups'],
|
||||
"platform" => $client['client_platform'],
|
||||
"nation" => $client['client_country'],
|
||||
"version" => $client['client_version'],
|
||||
"firstcon" => $client['client_created'],
|
||||
"except" => $except
|
||||
);
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['adduser'], $name, $uid, $cldbid));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($yetonline);
|
||||
|
||||
if ($insertdata != NULL) {
|
||||
$allinsertdata = '';
|
||||
foreach ($insertdata as $insertarr) {
|
||||
$allinsertdata = $allinsertdata . "(" . $insertarr['uuid'] . ", '" . $insertarr['cldbid'] . "', '1', " . $insertarr['ip'] . ", " . $insertarr['name'] . ", '" . $insertarr['lastseen'] . "', '" . $insertarr['grpid'] . "', '" . $insertarr['nextup'] . "', '" . $insertarr['cldgroup'] . "', '" . $insertarr['platform'] . "', '" . $insertarr['nation'] . "', '" . $insertarr['version'] . "', '" . $insertarr['firstcon'] . "', '" . $insertarr['except'] . "','1'),";
|
||||
}
|
||||
$allinsertdata = substr($allinsertdata, 0, -1);
|
||||
if ($allinsertdata != NULL) {
|
||||
$sqlexec .= "INSERT INTO $dbname.user (uuid, cldbid, count, ip, name, lastseen, grpid, nextup, cldgroup, platform, nation, version, firstcon, except, online) VALUES $allinsertdata; ";
|
||||
}
|
||||
unset($insertdata, $allinsertdata);
|
||||
}
|
||||
|
||||
if ($updatedata != NULL) {
|
||||
$allupdateuuid = $allupdatecldbid = $allupdatecount = $allupdateip = $allupdatename = $allupdatelastseen = $allupdategrpid = $allupdatenextup = $allupdateidle = $allupdatecldgroup = $allupdateboosttime = $allupdateplatform = $allupdatenation = $allupdateversion = $allupdateexcept = $allupdategrpsince = $allupdatecid = '';
|
||||
foreach ($updatedata as $updatearr) {
|
||||
$allupdateuuid = $allupdateuuid . $updatearr['uuid'] . ",";
|
||||
$allupdatecldbid = $allupdatecldbid . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['cldbid'] . "' ";
|
||||
$allupdatecount = $allupdatecount . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['count'] . "' ";
|
||||
$allupdateip = $allupdateip . "WHEN " . $updatearr['uuid'] . " THEN " . $updatearr['ip'] . " ";
|
||||
$allupdatename = $allupdatename . "WHEN " . $updatearr['uuid'] . " THEN " . $updatearr['name'] . " ";
|
||||
$allupdatelastseen = $allupdatelastseen . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['lastseen'] . "' ";
|
||||
$allupdategrpid = $allupdategrpid . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['grpid'] . "' ";
|
||||
$allupdatenextup = $allupdatenextup . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['nextup'] . "' ";
|
||||
$allupdateidle = $allupdateidle . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['idle'] . "' ";
|
||||
$allupdatecldgroup = $allupdatecldgroup . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['cldgroup'] . "' ";
|
||||
$allupdateboosttime = $allupdateboosttime . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['boosttime'] . "' ";
|
||||
$allupdateplatform = $allupdateplatform . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['platform'] . "' ";
|
||||
$allupdatenation = $allupdatenation . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['nation'] . "' ";
|
||||
$allupdateversion = $allupdateversion . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['version'] . "' ";
|
||||
$allupdateexcept = $allupdateexcept . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['except'] . "' ";
|
||||
$allupdategrpsince = $allupdategrpsince . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['grpsince'] . "' ";
|
||||
$allupdatecid = $allupdatecid . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['cid'] . "' ";
|
||||
}
|
||||
$allupdateuuid = substr($allupdateuuid, 0, -1);
|
||||
$sqlexec .= "UPDATE $dbname.user SET online='0'; UPDATE $dbname.user set cldbid = CASE uuid $allupdatecldbid END, count = CASE uuid $allupdatecount END, ip = CASE uuid $allupdateip END, name = CASE uuid $allupdatename END, lastseen = CASE uuid $allupdatelastseen END, grpid = CASE uuid $allupdategrpid END, nextup = CASE uuid $allupdatenextup END, idle = CASE uuid $allupdateidle END, cldgroup = CASE uuid $allupdatecldgroup END, boosttime = CASE uuid $allupdateboosttime END, platform = CASE uuid $allupdateplatform END, nation = CASE uuid $allupdatenation END, version = CASE uuid $allupdateversion END, except = CASE uuid $allupdateexcept END, grpsince = CASE uuid $allupdategrpsince END, cid = CASE uuid $allupdatecid END, online = 1 WHERE uuid IN ($allupdateuuid); ";
|
||||
unset($updatedata, $allupdateuuid, $allupdatecldbid, $allupdatecount, $allupdateip, $allupdatename, $allupdatelastseen, $allupdategrpid, $allupdatenextup, $allupdateidle, $allupdatecldgroup, $allupdateboosttime, $allupdateplatform, $allupdatenation, $allupdateversion, $allupdateexcept, $allupdategrpsince, $allupdatecid);
|
||||
}
|
||||
return($sqlexec);
|
||||
}
|
||||
<?PHP
|
||||
function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid,$resetexcept,$phpcommand,$select_arr) {
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
if(empty($grouptime)) {
|
||||
enter_logfile($logpath,$timezone,1,"calc_user:".$lang['wiconferr']."Shuttin down!\n\n");
|
||||
exit;
|
||||
}
|
||||
if($select_arr['job_check']['calc_user_lastscan']['timestamp'] < ($nowtime - 1800)) {
|
||||
enter_logfile($logpath,$timezone,4,"Much time gone since last scan.. reset time difference to zero.");
|
||||
$select_arr['job_check']['calc_user_lastscan']['timestamp'] = $nowtime;
|
||||
} elseif($select_arr['job_check']['calc_user_lastscan']['timestamp'] > $nowtime) {
|
||||
enter_logfile($logpath,$timezone,4,"Negative time between now and last scan (Error in your server time!).. reset time difference to zero.");
|
||||
$select_arr['job_check']['calc_user_lastscan']['timestamp'] = $nowtime;
|
||||
}
|
||||
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='calc_user_lastscan'; ";
|
||||
|
||||
krsort($grouptime);
|
||||
$yetonline = array();
|
||||
$updatedata = array();
|
||||
|
||||
if(isset($select_arr['admin_addtime']) && count($select_arr['admin_addtime']) != 0) {
|
||||
foreach($select_arr['admin_addtime'] as $uuid => $value) {
|
||||
if(isset($select_arr['all_user'][$uuid])) {
|
||||
$isonline = 0;
|
||||
foreach($allclients as $client) {
|
||||
if($client['client_unique_identifier'] == $uuid) {
|
||||
$isonline = 1;
|
||||
$select_arr['all_user'][$uuid]['count'] += $value['timecount'];
|
||||
}
|
||||
}
|
||||
if($isonline != 1) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` SET `count`=`count` + ".$value['timecount']." WHERE `uuid`='$uuid'; ";
|
||||
}
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`admin_addtime` WHERE `timestamp`=".$value['timestamp']." AND `uuid`='$uuid'; ";
|
||||
$sqlexec .= "UPDATE `$dbname`.`user_snapshot` SET `count`=`count` + ".$value['timecount']." WHERE `uuid`='$uuid'; ";
|
||||
enter_logfile($logpath,$timezone,4,sprintf($lang['sccupcount2'],$value['timecount'],$uuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($allclients as $client) {
|
||||
$cldbid = $client['client_database_id'];
|
||||
$name = $mysqlcon->quote($client['client_nickname'], ENT_QUOTES);
|
||||
$uid = htmlspecialchars($client['client_unique_identifier'], ENT_QUOTES);
|
||||
$sgroups = array_flip(explode(",", $client['client_servergroups']));
|
||||
if (!isset($yetonline[$uid]) && $client['client_version'] != "ServerQuery") {
|
||||
$clientidle = floor($client['client_idle_time'] / 1000);
|
||||
if(isset($ignoreidle) && $clientidle < $ignoreidle) {
|
||||
$clientidle = 0;
|
||||
}
|
||||
$yetonline[$uid] = 0;
|
||||
if(isset($exceptuuid[$uid])) {
|
||||
$except = 3;
|
||||
} elseif(array_intersect_key($sgroups, $exceptgroup)) {
|
||||
$except = 2;
|
||||
} else {
|
||||
if(isset($select_arr['all_user'][$uid]['except']) && ($select_arr['all_user'][$uid]['except'] == 3 || $select_arr['all_user'][$uid]['except'] == 2) && $resetexcept == 2) {
|
||||
$select_arr['all_user'][$uid]['count'] = 0;
|
||||
$select_arr['all_user'][$uid]['idle'] = 0;
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['resettime'], $name, $uid, $cldbid));
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`user_snapshot` WHERE `uuid`='$uid'; ";
|
||||
}
|
||||
$except = 0;
|
||||
}
|
||||
if(isset($select_arr['all_user'][$uid])) {
|
||||
$idle = $select_arr['all_user'][$uid]['idle'] + $clientidle;
|
||||
$grpid = $select_arr['all_user'][$uid]['grpid'];
|
||||
$nextup = $select_arr['all_user'][$uid]['nextup'];
|
||||
$grpsince = $select_arr['all_user'][$uid]['grpsince'];
|
||||
if ($select_arr['all_user'][$uid]['cldbid'] != $cldbid && $resetbydbchange == 1) {
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['changedbid'], $name, $uid, $cldbid, $select_arr['all_user'][$uid]['cldbid']));
|
||||
$count = 1;
|
||||
$idle = 0;
|
||||
} else {
|
||||
$hitboost = 0;
|
||||
$boosttime = $select_arr['all_user'][$uid]['boosttime'];
|
||||
if($boostarr!=0) {
|
||||
foreach($boostarr as $boost) {
|
||||
if(isset($sgroups[$boost['group']])) {
|
||||
$hitboost = 1;
|
||||
if($select_arr['all_user'][$uid]['boosttime']==0) {
|
||||
$boosttime = $nowtime;
|
||||
} else {
|
||||
if ($nowtime > $select_arr['all_user'][$uid]['boosttime'] + $boost['time']) {
|
||||
usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($boost['group'], $cldbid);
|
||||
$boosttime = 0;
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrprm'], $select_arr['groups'][$select_arr['all_user'][$uid]['grpid']]['sgidname'], $select_arr['all_user'][$uid]['grpid'], $name, $uid, $cldbid));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $cldbid, $select_arr['groups'][$select_arr['all_user'][$uid]['grpid']]['sgidname'], $select_arr['all_user'][$uid]['grpid']));
|
||||
}
|
||||
}
|
||||
}
|
||||
$count = ($nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp']) * $boost['factor'] + $select_arr['all_user'][$uid]['count'];
|
||||
if ($clientidle > ($nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp'])) {
|
||||
$idle = ($nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp']) * $boost['factor'] + $select_arr['all_user'][$uid]['idle'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($boostarr == 0 or $hitboost == 0) {
|
||||
$count = $nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp'] + $select_arr['all_user'][$uid]['count'];
|
||||
if ($clientidle > ($nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp'])) {
|
||||
$idle = $nowtime - $select_arr['job_check']['calc_user_lastscan']['timestamp'] + $select_arr['all_user'][$uid]['idle'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$dtF = new DateTime("@0");
|
||||
if ($substridle == 1) {
|
||||
$activetime = $count - $idle;
|
||||
} else {
|
||||
$activetime = $count;
|
||||
}
|
||||
$dtT = new DateTime("@$activetime");
|
||||
foreach ($grouptime as $time => $groupid) {
|
||||
if (isset($sgroups[$groupid])) {
|
||||
$grpid = $groupid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$grpcount=0;
|
||||
foreach ($grouptime as $time => $groupid) {
|
||||
$grpcount++;
|
||||
if(isset($exceptcid[$client['cid']]) || (($select_arr['all_user'][$uid]['except'] == 3 || $select_arr['all_user'][$uid]['except'] == 2) && $resetexcept == 1)) {
|
||||
$count = $select_arr['all_user'][$uid]['count'];
|
||||
$idle = $select_arr['all_user'][$uid]['idle'];
|
||||
if($except != 2 && $except != 3) {
|
||||
$except = 1;
|
||||
}
|
||||
} elseif ($activetime > $time && !isset($exceptuuid[$uid]) && !array_intersect_key($sgroups, $exceptgroup)) {
|
||||
if ($select_arr['all_user'][$uid]['grpid'] != $groupid) {
|
||||
if ($select_arr['all_user'][$uid]['grpid'] != NULL && isset($sgroups[$select_arr['all_user'][$uid]['grpid']])) {
|
||||
usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($select_arr['all_user'][$uid]['grpid'], $cldbid);
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrprm'], $select_arr['groups'][$select_arr['all_user'][$uid]['grpid']]['sgidname'], $select_arr['all_user'][$uid]['grpid'], $name, $uid, $cldbid));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $cldbid, $select_arr['groups'][$groupid]['sgidname'], $groupid));
|
||||
}
|
||||
}
|
||||
if (!isset($sgroups[$groupid])) {
|
||||
usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientAdd($groupid, $cldbid);
|
||||
$grpsince = $nowtime;
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrpadd'], $select_arr['groups'][$groupid]['sgidname'], $groupid, $name, $uid, $cldbid));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $cldbid, $select_arr['groups'][$groupid]['sgidname'], $groupid));
|
||||
}
|
||||
}
|
||||
$grpid = $groupid;
|
||||
if ($msgtouser == 1) {
|
||||
usleep($slowmode);
|
||||
$days = $dtF->diff($dtT)->format('%a');
|
||||
$hours = $dtF->diff($dtT)->format('%h');
|
||||
$mins = $dtF->diff($dtT)->format('%i');
|
||||
$secs = $dtF->diff($dtT)->format('%s');
|
||||
try {
|
||||
$ts3->clientGetByUid($uid)->message(sprintf($rankupmsg, $days, $hours, $mins, $secs, $select_arr['groups'][$groupid]['sgidname'], $client['client_nickname']));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $name, $uid, $cldbid, $select_arr['groups'][$groupid]['sgidname'], $groupid));
|
||||
}
|
||||
}
|
||||
}
|
||||
if($grpcount == 1) {
|
||||
$nextup = 0;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
$nextup = $time - $activetime;
|
||||
}
|
||||
}
|
||||
$updatedata[] = array(
|
||||
"uuid" => $mysqlcon->quote($client['client_unique_identifier'], ENT_QUOTES),
|
||||
"cldbid" => $cldbid,
|
||||
"count" => $count,
|
||||
"name" => $name,
|
||||
"lastseen" => $nowtime,
|
||||
"grpid" => $grpid,
|
||||
"nextup" => $nextup,
|
||||
"idle" => $idle,
|
||||
"cldgroup" => $client['client_servergroups'],
|
||||
"boosttime" => $boosttime,
|
||||
"platform" => $client['client_platform'],
|
||||
"nation" => $client['client_country'],
|
||||
"version" => $client['client_version'],
|
||||
"except" => $except,
|
||||
"grpsince" => $grpsince,
|
||||
"cid" => $client['cid']
|
||||
);
|
||||
} else {
|
||||
$grpid = '0';
|
||||
foreach ($grouptime as $time => $groupid) {
|
||||
if (isset($sgroups[$groupid])) {
|
||||
$grpid = $groupid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$updatedata[] = array(
|
||||
"uuid" => $mysqlcon->quote($client['client_unique_identifier'], ENT_QUOTES),
|
||||
"cldbid" => $cldbid,
|
||||
"count" => "0",
|
||||
"name" => $name,
|
||||
"lastseen" => $nowtime,
|
||||
"grpid" => $grpid,
|
||||
"nextup" => (key($grouptime) - 1),
|
||||
"idle" => "0",
|
||||
"cldgroup" => $client['client_servergroups'],
|
||||
"boosttime" => "0",
|
||||
"platform" => $client['client_platform'],
|
||||
"nation" => $client['client_country'],
|
||||
"version" => $client['client_version'],
|
||||
"firstcon" => $client['client_created'],
|
||||
"except" => $except,
|
||||
"grpsince" => "0",
|
||||
"cid" => $client['cid']
|
||||
);
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['adduser'], $name, $uid, $cldbid));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($yetonline);
|
||||
|
||||
if ($updatedata != NULL) {
|
||||
$sqlinsertvalues = '';
|
||||
foreach ($updatedata as $updatearr) {
|
||||
$sqlinsertvalues .= "(".$updatearr['uuid'].",'".$updatearr['cldbid']."','".$updatearr['count']."',".$updatearr['name'].",'".$updatearr['lastseen']."','".$updatearr['grpid']."','".$updatearr['nextup']."','".$updatearr['idle']."','".$updatearr['cldgroup']."','".$updatearr['boosttime']."','".$updatearr['platform']."','".$updatearr['nation']."','".$updatearr['version']."','".$updatearr['except']."','".$updatearr['grpsince']."','".$updatearr['cid']."',1),";
|
||||
}
|
||||
$sqlinsertvalues = substr($sqlinsertvalues, 0, -1);
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` SET `online`='0'; INSERT INTO `$dbname`.`user` (`uuid`,`cldbid`,`count`,`name`,`lastseen`,`grpid`,`nextup`,`idle`,`cldgroup`,`boosttime`,`platform`,`nation`,`version`,`except`,`grpsince`,`cid`,`online`) VALUES $sqlinsertvalues ON DUPLICATE KEY UPDATE `cldbid`=VALUES(`cldbid`),`count`=VALUES(`count`),`name`=VALUES(`name`),`lastseen`=VALUES(`lastseen`),`grpid`=VALUES(`grpid`),`nextup`=VALUES(`nextup`),`idle`=VALUES(`idle`),`cldgroup`=VALUES(`cldgroup`),`boosttime`=VALUES(`boosttime`),`platform`=VALUES(`platform`),`nation`=VALUES(`nation`),`version`=VALUES(`version`),`except`=VALUES(`except`),`grpsince`=VALUES(`grpsince`),`cid`=VALUES(`cid`),`online`=VALUES(`online`); ";
|
||||
unset($updatedata, $sqlinsertvalues);
|
||||
}
|
||||
return($sqlexec);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user