release 1.1.1

This commit is contained in:
Newcomer1989
2016-10-08 15:26:17 +02:00
parent e20f08f8b3
commit ab76128c42
80 changed files with 4085 additions and 3002 deletions

View File

@@ -1,9 +1,6 @@
<?PHP
function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$serverinfo,$substridle,$grouptime,$logpath) {
$starttime = microtime(true);
function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serverinfo,$substridle,$grouptime,$logpath) {
$nowtime = time();
$sqlmsg = '';
$sqlerr = 0;
$total_user = 0;
$total_online_time = 0;
@@ -15,8 +12,6 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
$server_channel_amount = 0;
if(($uuids = $mysqlcon->query("SELECT uuid,count,idle,platform,nation FROM $dbname.user")) === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 1:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
$uuids = $uuids->fetchAll();
foreach($uuids as $uuid) {
@@ -39,8 +34,6 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
// Duplicate users Table in snapshot Table
if(($max_entry_usersnap = $mysqlcon->query("SELECT MAX(DISTINCT(timestamp)) AS timestamp FROM $dbname.user_snapshot")) === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 2:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
$max_entry_usersnap = $max_entry_usersnap->fetch(PDO::FETCH_ASSOC);
$diff_max_usersnap = $nowtime - $max_entry_usersnap['timestamp'];
@@ -54,8 +47,6 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
if ($allinsertsnap != '') {
if($mysqlcon->exec("INSERT INTO $dbname.user_snapshot (timestamp, uuid, count, idle) VALUES $allinsertsnap") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 3:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
}
}
@@ -63,8 +54,6 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
$deletiontime = $nowtime - 2678400;
if($mysqlcon->exec("DELETE FROM $dbname.user_snapshot WHERE timestamp=$deletiontime") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 4:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
}
@@ -81,16 +70,12 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
// Calc Values for server stats
if(($entry_snapshot_count = $mysqlcon->query("SELECT count(DISTINCT(timestamp)) AS timestamp FROM $dbname.user_snapshot")) === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 5:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
$entry_snapshot_count = $entry_snapshot_count->fetch(PDO::FETCH_ASSOC);
if ($entry_snapshot_count['timestamp'] > 27) {
// Calc total_online_week
if(($snapshot_count_week = $mysqlcon->query("SELECT (SELECT SUM(count) FROM $dbname.user_snapshot WHERE timestamp=(SELECT MAX(s2.timestamp) AS value1 FROM (SELECT DISTINCT(timestamp) FROM $dbname.user_snapshot ORDER BY timestamp DESC LIMIT 28) AS s2, $dbname.user_snapshot AS s1 WHERE s1.timestamp=s2.timestamp)) - (SELECT SUM(count) FROM $dbname.user_snapshot WHERE timestamp=(SELECT MIN(s2.timestamp) AS value2 FROM (SELECT DISTINCT(timestamp) FROM $dbname.user_snapshot ORDER BY timestamp DESC LIMIT 28) AS s2, $dbname.user_snapshot AS s1 WHERE s1.timestamp=s2.timestamp) AND uuid IN (SELECT uuid FROM $dbname.user)) AS count")) === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 6:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
$snapshot_count_week = $snapshot_count_week->fetch(PDO::FETCH_ASSOC);
$total_online_week = $snapshot_count_week['count'];
@@ -101,8 +86,6 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
// Calc total_online_month
if(($snapshot_count_month = $mysqlcon->query("SELECT (SELECT SUM(count) FROM $dbname.user_snapshot WHERE timestamp=(SELECT MAX(s2.timestamp) AS value1 FROM (SELECT DISTINCT(timestamp) FROM $dbname.user_snapshot ORDER BY timestamp DESC LIMIT 120) AS s2, $dbname.user_snapshot AS s1 WHERE s1.timestamp=s2.timestamp)) - (SELECT SUM(count) FROM $dbname.user_snapshot WHERE timestamp=(SELECT MIN(s2.timestamp) AS value2 FROM (SELECT DISTINCT(timestamp) FROM $dbname.user_snapshot ORDER BY timestamp DESC LIMIT 120) AS s2, $dbname.user_snapshot AS s1 WHERE s1.timestamp=s2.timestamp) AND uuid IN (SELECT uuid FROM $dbname.user)) AS count")) === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 7:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
$snapshot_count_month = $snapshot_count_month->fetch(PDO::FETCH_ASSOC);
$total_online_month = $snapshot_count_month['count'];
@@ -221,8 +204,6 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
if($mysqlcon->exec("UPDATE $dbname.stats_server SET total_user='$total_user', total_online_time='$total_online_time', total_online_month='$total_online_month', total_online_week='$total_online_week', 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', version_name_1='$version_name_1', server_status='$server_status', server_free_slots='$server_free_slots', server_used_slots='$server_used_slots', server_channel_amount='$server_channel_amount', server_ping='$server_ping', server_packet_loss='$server_packet_loss', server_bytes_down='$server_bytes_down', server_bytes_up='$server_bytes_up', server_uptime='$server_uptime', server_id='$server_id', server_name=$server_name, server_pass='$server_pass', server_creation_date='$server_creation_date', server_platform='$server_platform', server_weblist='$server_weblist', server_version='$server_version'") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 8:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
// Stats for Server Usage
@@ -235,8 +216,6 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
if ($max_entry_serverusage['timestamp'] == 0 || $diff_max_serverusage > 898) { // every 15 mins
if($mysqlcon->exec("INSERT INTO $dbname.server_usage (timestamp, clients, channel) VALUES ($nowtime,$server_used_slots,$server_channel_amount)") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 10:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
}
@@ -244,8 +223,6 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
$upnextuptime = $nowtime - 86400;
if(($uuidsoff = $mysqlcon->query("SELECT uuid,idle,count FROM $dbname.user WHERE online<>1 AND lastseen>$upnextuptime")) === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 11:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
if ($uuidsoff->rowCount() != 0) {
$uuidsoff = $uuidsoff->fetchAll(PDO::FETCH_ASSOC);
@@ -285,41 +262,20 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
$allupdateuuid = substr($allupdateuuid, 0, -1);
if ($mysqlcon->exec("UPDATE $dbname.user set nextup = CASE uuid $allupdatenextup END WHERE uuid IN ($allupdateuuid)") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 12:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
}
//Calc Rank
if($mysqlcon->exec("SET @a:=0") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 13:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
if ($substridle == 1) {
if($mysqlcon->exec("UPDATE $dbname.user u INNER JOIN (SELECT @a:=@a+1 nr,uuid FROM $dbname.user WHERE except!=1 ORDER BY (count - idle) DESC) s USING (uuid) SET u.rank=s.nr") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 14:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
} else {
if($mysqlcon->exec("UPDATE $dbname.user u INNER JOIN (SELECT @a:=@a+1 nr,uuid FROM $dbname.user WHERE except!=1 ORDER BY count DESC) s USING (uuid) SET u.rank=s.nr") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 14:".print_r($mysqlcon->errorInfo()));
$sqlmsg .= print_r($mysqlcon->errorInfo());
$sqlerr++;
}
}
$buildtime = microtime(true) - $starttime;
if ($buildtime < 0) { $buildtime = 0; }
if ($sqlerr == 0) {
if($mysqlcon->exec("UPDATE $dbname.job_log SET status='0', runtime='$buildtime' WHERE id='$jobid'") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 15:".print_r($mysqlcon->errorInfo()));
}
} else {
if($mysqlcon->exec("UPDATE $dbname.job_log SET status='1', err_msg='$sqlmsg', runtime='$buildtime' WHERE id='$jobid'") === false) {
enter_logfile($logpath,$timezone,2,"calc_serverstats 16:".print_r($mysqlcon->errorInfo()));
}
}
}