release 1.3.10
This commit is contained in:
@@ -452,7 +452,7 @@ function run_bot() {
|
||||
|
||||
if($db_cache['job_check']['reload_trigger']['timestamp'] == 1) {
|
||||
unset($db_cache['addon_assign_groups'],$db_cache['admin_addtime']);
|
||||
if(($get_db_data = $mysqlcon->query("SELECT * FROM `$dbname`.`addon_assign_groups`; SELECT * FROM `$dbname`.`admin_addtime`;")) === false) {
|
||||
if(($get_db_data = $mysqlcon->query("SELECT * FROM `$dbname`.`addon_assign_groups`; SELECT * FROM `$dbname`.`admin_addtime`; SELECT * FROM `$dbname`.`groups`;")) === false) {
|
||||
shutdown($mysqlcon,$cfg,1,"Select on DB failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
@@ -467,6 +467,9 @@ function run_bot() {
|
||||
break;
|
||||
case 2:
|
||||
$db_cache['admin_addtime'] = $fetched_array;
|
||||
break;
|
||||
case 3:
|
||||
$db_cache['groups'] = $fetched_array;
|
||||
break 2;
|
||||
}
|
||||
$get_db_data->nextRowset();
|
||||
|
||||
@@ -328,7 +328,9 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$server_used_slots = $serverinfo['virtualserver_clientsonline'] - $serverinfo['virtualserver_queryclientsonline'];
|
||||
$server_free_slots = $serverinfo['virtualserver_maxclients'] - $server_used_slots;
|
||||
$server_name = $mysqlcon->quote($serverinfo['virtualserver_name'], ENT_QUOTES);
|
||||
|
||||
$serverinfo['virtualserver_total_ping'] = round((substr($serverinfo['virtualserver_total_ping'], 0, strpos($serverinfo['virtualserver_total_ping'], '.')).".".substr($serverinfo['virtualserver_total_ping'], (strpos($serverinfo['virtualserver_total_ping'], '.') + 1), 4)));
|
||||
if($serverinfo['virtualserver_total_ping'] > 32767) $serverinfo['virtualserver_total_ping'] = 32767;
|
||||
|
||||
// Write stats/index and Nations, Platforms & Versions
|
||||
$sqlexec .= "UPDATE `$dbname`.`stats_server` SET `total_user`=$total_user,`total_online_time`=$total_online_time,`total_active_time`=$total_active_time,`total_inactive_time`=$total_inactive_time,`country_nation_name_1`='$country_nation_name_1',`country_nation_name_2`='$country_nation_name_2',`country_nation_name_3`='$country_nation_name_3',`country_nation_name_4`='$country_nation_name_4',`country_nation_name_5`='$country_nation_name_5',`country_nation_1`=$country_nation_1,`country_nation_2`=$country_nation_2,`country_nation_3`=$country_nation_3,`country_nation_4`=$country_nation_4,`country_nation_5`=$country_nation_5,`country_nation_other`=$country_nation_other,`platform_1`=$platform_1,`platform_2`=$platform_2,`platform_3`=$platform_3,`platform_4`=$platform_4,`platform_5`=$platform_5,`platform_other`=$platform_other,`version_name_1`='$version_name_1',`version_name_2`='$version_name_2',`version_name_3`='$version_name_3',`version_name_4`='$version_name_4',`version_name_5`='$version_name_5',`version_1`=$version_1,`version_2`=$version_2,`version_3`=$version_3,`version_4`=$version_4,`version_5`=$version_5,`version_other`=$version_other,`server_status`=$server_status,`server_free_slots`=$server_free_slots,`server_used_slots`=$server_used_slots,`server_channel_amount`={$serverinfo['virtualserver_channelsonline']},`server_ping`={$serverinfo['virtualserver_total_ping']},`server_packet_loss`={$serverinfo['virtualserver_total_packetloss_total']},`server_bytes_down`={$serverinfo['connection_bytes_received_total']},`server_bytes_up`={$serverinfo['connection_bytes_sent_total']},`server_uptime`={$serverinfo['virtualserver_uptime']},`server_id`={$serverinfo['virtualserver_id']},`server_name`=$server_name,`server_pass`={$serverinfo['virtualserver_flag_password']},`server_creation_date`={$serverinfo['virtualserver_created']},`server_platform`='{$serverinfo['virtualserver_platform']}',`server_weblist`={$serverinfo['virtualserver_weblist_enabled']},`server_version`='{$serverinfo['virtualserver_version']}',`user_today`=$user_today,`user_week`=$user_week,`user_month`=$user_month,`user_quarter`=$user_quarter;\n";
|
||||
}
|
||||
|
||||
@@ -98,6 +98,9 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
$name = $mysqlcon->quote((mb_substr($client['client_nickname'],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';
|
||||
$client['client_platform'] = mb_substr($client['client_platform'],0,32);
|
||||
$client['client_version'] = mb_substr($client['client_version'],0,64);
|
||||
|
||||
if (!isset($multipleonline[$uid]) && $client['client_version'] != "ServerQuery" && $client['client_type']!="1") {
|
||||
$clientidle = floor($client['client_idle_time'] / 1000);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?PHP
|
||||
function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,&$db_cache) {
|
||||
$starttime = microtime(true);
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
$job_begin = $db_cache['job_check']['calc_user_limit']['timestamp'];
|
||||
@@ -64,10 +65,12 @@ function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,&$db_cache) {
|
||||
$idle_month = 0;
|
||||
$active_month = 0;
|
||||
}
|
||||
|
||||
$clientdesc = $mysqlcon->quote($clientinfo['client_description'], ENT_QUOTES);
|
||||
$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),";
|
||||
if($clientinfo['client_totalconnections'] > 16777215) $clientinfo['client_totalconnections'] = 16777215;
|
||||
$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,$nowtime),";
|
||||
} catch (Exception $e) {
|
||||
if($e->getCode() == 512) {
|
||||
if($e->getCode() == 512 || $e->getCode() == 1281) {
|
||||
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);
|
||||
@@ -101,7 +104,7 @@ function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,&$db_cache) {
|
||||
$db_cache['job_check']['calc_user_limit']['timestamp'] = $job_end;
|
||||
if ($allupdateuuid != '') {
|
||||
$allupdateuuid = substr($allupdateuuid, 0, -1);
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$job_end WHERE `job_name`='calc_user_limit';\nINSERT 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`);\n";
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$job_end WHERE `job_name`='calc_user_limit';\nINSERT 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`,`last_calculated`) 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`),`last_calculated`=VALUES(`last_calculated`);\n";
|
||||
unset($allupdateuuid);
|
||||
} else {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$job_end WHERE `job_name`='calc_user_limit';\n";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
function check_db($mysqlcon,$lang,$cfg,$dbname) {
|
||||
$cfg['version_latest_available'] = '1.3.9';
|
||||
$cfg['version_latest_available'] = '1.3.10';
|
||||
enter_logfile($cfg,5,"Check Ranksystem database for updates...");
|
||||
|
||||
function check_double_cldbid($mysqlcon,$cfg,$dbname) {
|
||||
@@ -330,11 +330,21 @@ function check_db($mysqlcon,$lang,$cfg,$dbname) {
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.9', '<')) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('get_avatars', '0'),('calc_donut_chars', '0'),('reload_trigger', '0');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.9] Added new job_check values.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.10', '<')) {
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`admin_addtime`;") === false) { }
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`addon_assign_groups`;") === false) { }
|
||||
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('get_avatars', '0'),('calc_donut_chars', '0'),('reload_trigger', '0');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.9] Added new job_check values.");
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_user` ADD COLUMN `last_calculated` int(10) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.10] Added new stats_user values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_user` MODIFY COLUMN `total_connections` MEDIUMINT(8) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.10] Adjusted table stats_user successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE INDEX `snapshot_id` ON `$dbname`.`user_snapshot` (`id`)") === false) { }
|
||||
|
||||
@@ -23,7 +23,9 @@ function get_avatars($ts3,$cfg,$dbname,&$db_cache) {
|
||||
unset($fsfilelist);
|
||||
|
||||
if (isset($tsfilelist)) {
|
||||
$downloadedavatars = 0;
|
||||
foreach($tsfilelist as $tsfile) {
|
||||
if($downloadedavatars > 9) break;
|
||||
$fullfilename = '/'.$tsfile['name'];
|
||||
$uuidasbase16 = substr($tsfile['name'],7);
|
||||
if (!isset($fsfilelistarray[$uuidasbase16.'.png']) || ($tsfile['datetime'] - $cfg['teamspeak_avatar_download_delay']) > $fsfilelistarray[$uuidasbase16.'.png']) {
|
||||
@@ -34,6 +36,7 @@ function get_avatars($ts3,$cfg,$dbname,&$db_cache) {
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . $avatar["host"] . ":" . $avatar["port"]);
|
||||
$tsfile = $transfer->download($avatar["ftkey"], $avatar["size"]);
|
||||
$avatarfilepath = substr(__DIR__,0,-4).'avatars/'.$uuidasbase16.'.png';
|
||||
$downloadedavatars++;
|
||||
enter_logfile($cfg,5,"Download avatar: ".$fullfilename);
|
||||
if(file_put_contents($avatarfilepath, $tsfile) === false) {
|
||||
enter_logfile($cfg,2,"Error while writing out the avatar. Please check the permission for the folder 'avatars'");
|
||||
|
||||
@@ -130,6 +130,10 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
if((strstr($event["msg"], '!reloadgroups') || strstr($event["msg"], '!reloadicons')) && $admin == 1) {
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`groups`") === false) {
|
||||
enter_logfile($cfg,4,"handle_messages 14:".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger';") === false) {
|
||||
enter_logfile($cfg,4,"handle_messages 15:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0011'] ." ". $lang['msg0010']);
|
||||
return;
|
||||
|
||||
@@ -18,7 +18,7 @@ function reset_rs($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
|
||||
krsort($cfg['rankup_definition']);
|
||||
|
||||
if (($all_clients = $mysqlcon->query("SELECT cldbid,uuid,name FROM `$dbname`.`user`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
if (($all_clients = $mysqlcon->query("SELECT `cldbid`,`uuid`,`name` FROM `$dbname`.`user`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
shutdown($mysqlcon,$cfg,1,"Select on DB failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
@@ -201,23 +201,27 @@ function reset_rs($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
} else {
|
||||
$db_cache['job_check']['reset_webspace_cache']['timestamp'] = 2;
|
||||
enter_logfile($cfg,4," Started job '".$lang['wihladm33']."'");
|
||||
if ($mysqlcon->exec("DELETE FROM `$dbname`.`groups`;") === false) {
|
||||
enter_logfile($cfg,4," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger';") === false) {
|
||||
enter_logfile($cfg,4," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$del_folder = array('avatars/','tsicons/');
|
||||
$err_cnt = 0;
|
||||
|
||||
|
||||
if (!function_exists('rm_file_reset')) {
|
||||
function rm_file_reset($folder,$cfg) {
|
||||
foreach(scandir($folder) as $file) {
|
||||
if ('.' === $file || '..' === $file || 'rs.png' === $file || is_dir($folder.$file)) {
|
||||
continue;
|
||||
if (in_array($file, array('.','..','check.png','placeholder.png','rs.png','servericon.png','100.png','200.png','300.png','500.png','600.png')) || is_dir($folder.$file)) continue;
|
||||
if(unlink($folder.$file)) {
|
||||
enter_logfile($cfg,4," File ".$folder.$file." successfully deleted.");
|
||||
} else {
|
||||
if(unlink($folder.$file)) {
|
||||
enter_logfile($cfg,4," File ".$folder.$file." successfully deleted.");
|
||||
} else {
|
||||
enter_logfile($cfg,2," File ".$folder.$file." couldn't be deleted. Please check the file permissions.");
|
||||
$err_cnt++;
|
||||
}
|
||||
enter_logfile($cfg,2," File ".$folder.$file." couldn't be deleted. Please check the file permissions.");
|
||||
$err_cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,8 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
$ts3groups = $ts3->serverGroupList();
|
||||
|
||||
// ServerIcon
|
||||
if ($serverinfo['virtualserver_icon_id'] < 0) {
|
||||
$sIconId = (pow(2, 32)) - ($serverinfo['virtualserver_icon_id'] * -1);
|
||||
} else {
|
||||
$sIconId = $serverinfo['virtualserver_icon_id'];
|
||||
}
|
||||
$sIconId = $serverinfo['virtualserver_icon_id'];
|
||||
$sIconId = ($sIconId < 0) ? (pow(2, 32)) - ($sIconId * -1) : $sIconId;
|
||||
$sIconFile = 0;
|
||||
$extension = '';
|
||||
if (!isset($db_cache['groups']['0']) || $db_cache['groups']['0']['iconid'] != $sIconId || (isset($iconarr["i".$sIconId]) && $iconarr["i".$sIconId] > $db_cache['groups']['0']['icondate'])) {
|
||||
@@ -82,7 +79,7 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
"icondate" => $sicondate,
|
||||
"sortid" => "0",
|
||||
"type" => "0",
|
||||
"ext" => $mysqlcon->quote($extension, ENT_QUOTES)
|
||||
"ext" => $extension
|
||||
);
|
||||
}
|
||||
unset($sIconFile,$sIconId);
|
||||
@@ -111,6 +108,8 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.sprintf($lang['upgrp0008'], $sgname, $sgid).$e->getMessage());
|
||||
}
|
||||
} else {
|
||||
$extension = $db_cache['groups'][$sgid]['ext'];
|
||||
}
|
||||
} elseif($iconid == 0) {
|
||||
foreach (glob(substr(dirname(__FILE__),0,-4) . "tsicons/" . $iconid . ".*") as $file) {
|
||||
@@ -141,7 +140,7 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
"icondate" => $iconarr["i".$iconid],
|
||||
"sortid" => $servergroup['sortid'],
|
||||
"type" => $servergroup['type'],
|
||||
"ext" => $mysqlcon->quote($extension, ENT_QUOTES)
|
||||
"ext" => $extension
|
||||
);
|
||||
}
|
||||
if($iconcount > 9 && $nobreak != 1) {
|
||||
@@ -153,7 +152,7 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
if (isset($updategroups)) {
|
||||
$sqlinsertvalues = '';
|
||||
foreach ($updategroups as $updatedata) {
|
||||
$sqlinsertvalues .= "({$updatedata['sgid']},{$updatedata['sgidname']},{$updatedata['iconid']},{$updatedata['icondate']},{$updatedata['sortid']},{$updatedata['type']},{$updatedata['ext']}),";
|
||||
$sqlinsertvalues .= "({$updatedata['sgid']},{$updatedata['sgidname']},{$updatedata['iconid']},{$updatedata['icondate']},{$updatedata['sortid']},{$updatedata['type']},{$mysqlcon->quote($updatedata['ext'], ENT_QUOTES)}),";
|
||||
$db_cache['groups'][$updatedata['sgid']]['sgidname'] = $updatedata['sgidname'];
|
||||
$db_cache['groups'][$updatedata['sgid']]['iconid'] = $updatedata['iconid'];
|
||||
$db_cache['groups'][$updatedata['sgid']]['icondate'] = $updatedata['icondate'];
|
||||
|
||||
Reference in New Issue
Block a user