release 1.3.22
This commit is contained in:
@@ -4,7 +4,7 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
if($db_cache['job_check']['calc_donut_chars']['timestamp'] < ($nowtime - 8) || $db_cache['job_check']['get_version']['timestamp'] < ($nowtime - 43199)) {
|
||||
if(intval($db_cache['job_check']['calc_donut_chars']['timestamp']) < ($nowtime - 8) || intval($db_cache['job_check']['get_version']['timestamp']) < ($nowtime - 43199)) {
|
||||
$db_cache['job_check']['calc_donut_chars']['timestamp'] = $nowtime;
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`={$nowtime} WHERE `job_name`='calc_donut_chars';\n";
|
||||
|
||||
@@ -44,8 +44,8 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$count_version_user[$version] = 1;
|
||||
}
|
||||
|
||||
$total_online_time = $total_online_time + $uuid['count'];
|
||||
$total_inactive_time = $total_inactive_time + $uuid['idle'];
|
||||
if($uuid['count']>0) $total_online_time += $uuid['count'];
|
||||
if($uuid['idle']>0) $total_inactive_time += $uuid['idle'];
|
||||
}
|
||||
|
||||
arsort($country_array);
|
||||
@@ -342,20 +342,21 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
|
||||
|
||||
// Calc Values for server stats
|
||||
if($db_cache['job_check']['calc_server_stats']['timestamp'] < ($nowtime - 899)) {
|
||||
if(intval($db_cache['job_check']['calc_server_stats']['timestamp']) < ($nowtime - 899)) {
|
||||
$db_cache['job_check']['calc_server_stats']['timestamp'] = $nowtime;
|
||||
$weekago = $db_cache['job_check']['last_snapshot_id']['timestamp'] - 28;
|
||||
$monthago = $db_cache['job_check']['last_snapshot_id']['timestamp'] - 120;
|
||||
$weekago = intval($db_cache['job_check']['last_snapshot_id']['timestamp']) - 28;
|
||||
$monthago = intval($db_cache['job_check']['last_snapshot_id']['timestamp']) - 120;
|
||||
if ($weekago < 1) $weekago = $weekago + 121;
|
||||
if ($monthago < 1) $monthago = $monthago + 121;
|
||||
|
||||
if(($entry_snapshot_count = $mysqlcon->query("SELECT count(DISTINCT(`id`)) AS `id` FROM `$dbname`.`user_snapshot`")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,2,"calc_serverstats 19:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"calc_serverstats 19:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if ($entry_snapshot_count['id'] > 28) {
|
||||
// Calc total_online_week
|
||||
if(($snapshot_count_week = $mysqlcon->query("SELECT (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$db_cache['job_check']['last_snapshot_id']['timestamp']}) - (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$weekago}) AS `count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,2,"calc_serverstats 20:".print_r($mysqlcon->errorInfo(), true));
|
||||
#if(($snapshot_count_week = $mysqlcon->query("SELECT (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$db_cache['job_check']['last_snapshot_id']['timestamp']}) - (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$weekago}) AS `count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
if(($snapshot_count_week = $mysqlcon->query("SELECT SUM(`a`.`count` - `b`.`count`) AS `count` FROM `$dbname`.`user_snapshot` `a`, `$dbname`.`user_snapshot` `b` WHERE `b`.`cldbid` = `a`.`cldbid` AND `a`.`id`={$db_cache['job_check']['last_snapshot_id']['timestamp']} AND `b`.`id`={$weekago} AND `a`.`count`>`b`.`count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile(2,"calc_serverstats 20:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if($snapshot_count_week['count'] == NULL) {
|
||||
$total_online_week = 0;
|
||||
@@ -367,8 +368,9 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
}
|
||||
if ($entry_snapshot_count['id'] > 120) {
|
||||
// Calc total_online_month
|
||||
if(($snapshot_count_month = $mysqlcon->query("SELECT (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$db_cache['job_check']['last_snapshot_id']['timestamp']}) - (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$monthago}) AS `count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,2,"calc_serverstats 21:".print_r($mysqlcon->errorInfo(), true));
|
||||
#if(($snapshot_count_month = $mysqlcon->query("SELECT (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$db_cache['job_check']['last_snapshot_id']['timestamp']}) - (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$monthago}) AS `count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
if(($snapshot_count_month = $mysqlcon->query("SELECT SUM(`a`.`count` - `b`.`count`) AS `count` FROM `$dbname`.`user_snapshot` `a`, `$dbname`.`user_snapshot` `b` WHERE `b`.`cldbid` = `a`.`cldbid` AND `a`.`id`={$db_cache['job_check']['last_snapshot_id']['timestamp']} AND `b`.`id`={$monthago} AND `a`.`count`>`b`.`count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile(2,"calc_serverstats 21:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if($snapshot_count_month['count'] == NULL) {
|
||||
$total_online_month = 0;
|
||||
@@ -380,9 +382,9 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
}
|
||||
$sqlexec .= "UPDATE `$dbname`.`stats_server` SET `total_online_month`={$total_online_month},`total_online_week`={$total_online_week};\nUPDATE `$dbname`.`job_check` SET `timestamp`={$nowtime} WHERE `job_name`='calc_server_stats';\n";
|
||||
|
||||
if ($db_cache['job_check']['get_version']['timestamp'] < ($nowtime - 43199)) {
|
||||
if (intval($db_cache['job_check']['get_version']['timestamp']) < ($nowtime - 43199)) {
|
||||
$db_cache['job_check']['get_version']['timestamp'] = $nowtime;
|
||||
enter_logfile($cfg,6,"Get the latest Ranksystem Version.");
|
||||
enter_logfile(6,"Get the latest Ranksystem Version.");
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://ts-n.net/ranksystem/'.$cfg['version_update_channel']);
|
||||
curl_setopt($ch, CURLOPT_REFERER, 'TSN Ranksystem');
|
||||
@@ -412,22 +414,58 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
$cfg['version_latest_available'] = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
curl_close($ch); unset($ch);
|
||||
|
||||
if(!isset($cfg['stats_news_html']) || $cfg['stats_news_html'] != '') {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='0' WHERE `job_name`='news_html';\nUPDATE `$dbname`.`cfg_params` SET `value`='' WHERE `param`='stats_news_html';\n";
|
||||
}
|
||||
$newh = curl_init();
|
||||
curl_setopt($newh, CURLOPT_URL, 'https://ts-n.net/ranksystem/news_html');
|
||||
curl_setopt($newh, CURLOPT_REFERER, 'TSN Ranksystem - News HTML');
|
||||
curl_setopt($newh, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($newh, CURLOPT_MAXREDIRS, 10);
|
||||
curl_setopt($newh, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($newh, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
$cfg['stats_news_html'] = curl_exec($newh);
|
||||
curl_close($newh); unset($newh);
|
||||
if($cfg['stats_news_html'] != '') {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$nowtime WHERE `job_name`='news_html';\nUPDATE `$dbname`.`cfg_params` SET `value`='{$cfg['stats_news_html']}' WHERE `param`='stats_news_html';\n";
|
||||
}
|
||||
|
||||
if(!isset($cfg['teamspeak_news_bb']) || $cfg['teamspeak_news_bb'] != '') {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='0' WHERE `job_name`='news_bb';\nUPDATE `$dbname`.`cfg_params` SET `value`='' WHERE `param`='teamspeak_news_bb';\n";
|
||||
}
|
||||
$newb = curl_init();
|
||||
curl_setopt($newb, CURLOPT_URL, 'https://ts-n.net/ranksystem/news_bb');
|
||||
curl_setopt($newb, CURLOPT_REFERER, 'TSN Ranksystem - News BB');
|
||||
curl_setopt($newb, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($newb, CURLOPT_MAXREDIRS, 10);
|
||||
curl_setopt($newb, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($newb, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
$cfg['teamspeak_news_bb'] = curl_exec($newb);
|
||||
curl_close($newb); unset($newb);
|
||||
if($cfg['teamspeak_news_bb'] != '') {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$nowtime WHERE `job_name`='news_bb';\nUPDATE `$dbname`.`cfg_params` SET `value`='{$cfg['teamspeak_news_bb']}' WHERE `param`='teamspeak_news_bb';\n";
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_latest_available'], $cfg['version_current_using'], '>') && $cfg['version_latest_available'] != NULL) {
|
||||
enter_logfile($cfg,4,$lang['upinf']);
|
||||
enter_logfile(4,$lang['upinf']);
|
||||
if(isset($cfg['webinterface_admin_client_unique_id_list']) && $cfg['webinterface_admin_client_unique_id_list'] != NULL) {
|
||||
foreach(array_flip($cfg['webinterface_admin_client_unique_id_list']) as $clientid) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upmsg'], $cfg['version_current_using'], $cfg['version_latest_available'], 'https://ts-ranksystem.com/#changelog'));
|
||||
enter_logfile($cfg,4," ".sprintf($lang['upusrinf'], $clientid));
|
||||
if(isset($cfg['teamspeak_news_bb']) && $cfg['teamspeak_news_bb'] != '') {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upmsg'], $cfg['version_current_using'], $cfg['version_latest_available'], 'https://ts-ranksystem.com/#changelog')."\n\n[U]Latest News:[/U]\n".$cfg['teamspeak_news_bb']);
|
||||
} else {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upmsg'], $cfg['version_current_using'], $cfg['version_latest_available'], 'https://ts-ranksystem.com/#changelog'));
|
||||
}
|
||||
enter_logfile(4," ".sprintf($lang['upusrinf'], $clientid));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
enter_logfile(6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
}
|
||||
}
|
||||
}
|
||||
$sqlexec .= update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand);
|
||||
$sqlexec .= update_rs($mysqlcon,$lang,$cfg,$dbname);
|
||||
}
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$nowtime WHERE `job_name`='get_version';\nUPDATE `$dbname`.`cfg_params` SET `value`='{$cfg['version_latest_available']}' WHERE `param`='version_latest_available';\n";
|
||||
}
|
||||
@@ -436,13 +474,13 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$dbversion = $mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
preg_match("/^[0-9\.-]+/", $dbversion, $version_number);
|
||||
if ($cfg['rankup_time_assess_mode'] == 1) {
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '5.5.5-10.6', '>=')) {
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '8', '>=') && version_compare($version_number[0], '10', '<') || version_compare($version_number[0], '5.5.5-10.6', '>=') && version_compare($version_number[0], '5.5.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 {
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '5.5.5-10.6', '>=')) {
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '8', '>=') && version_compare($version_number[0], '10', '<') || version_compare($version_number[0], '5.5.5-10.6', '>=') && version_compare($version_number[0], '5.5.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";
|
||||
@@ -450,7 +488,7 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
}
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"calc_serverstats needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"calc_serverstats needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user