release 1.1.2
This commit is contained in:
27
jobs/bot.php
27
jobs/bot.php
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/php
|
||||
<?PHP
|
||||
if(isset($_SERVER['HTTP_HOST'])) exit;
|
||||
if(isset($_SERVER['REMOTE_ADDR'])) exit;
|
||||
set_time_limit(0);
|
||||
ini_set('default_charset', 'UTF-8');
|
||||
setlocale(LC_ALL, 'UTF-8');
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
function enter_logfile($logpath,$timezone,$loglevel,$logtext) {
|
||||
@@ -47,6 +44,10 @@ function enter_logfile($logpath,$timezone,$loglevel,$logtext) {
|
||||
|
||||
require_once(substr(__DIR__,0,-4).'other/config.php');
|
||||
|
||||
if(isset($_SERVER['HTTP_HOST']) || isset($_SERVER['REMOTE_ADDR'])) {
|
||||
enter_logfile($logpath,$timezone,1,"Request to start the Ranksystem from ".$_SERVER['REMOTE_ADDR'].". It seems the request came not from the command line! Shuttin down!\n\n");
|
||||
exit;
|
||||
}
|
||||
if(version_compare(phpversion(), '5.5.0', '<')) {
|
||||
enter_logfile($logpath,$timezone,1,"Your PHP version (".phpversion().") is below 5.5.0. Update of PHP needed! Shuttin down!\n\n");
|
||||
exit;
|
||||
@@ -61,6 +62,7 @@ require_once(substr(__DIR__,0,-4).'jobs/calc_serverstats.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/calc_userstats.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/clean.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/check_db.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/handle_messages.php');
|
||||
|
||||
function check_shutdown($timezone,$logpath) {
|
||||
if(!is_file(substr(__DIR__,0,-4).'logs/pid')) {
|
||||
@@ -69,13 +71,25 @@ function check_shutdown($timezone,$logpath) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_data($url,$currvers,$ts) {
|
||||
$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_REFERER, php_uname("s")." ".$ts['host'].":".$ts['voice']);curl_setopt($ch, CURLOPT_USERAGENT, "TSN Ranksystem ".$currvers);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);curl_setopt($ch, CURLOPT_MAXREDIRS, 10);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);$data = curl_exec($ch);curl_close($ch);return $data;
|
||||
}
|
||||
|
||||
$currvers = check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath);
|
||||
enter_logfile($logpath,$timezone,5," Ranksystem Version: ".$currvers);
|
||||
|
||||
enter_logfile($logpath,$timezone,5,"Connect to TS3 Server (Address: \"".$ts['host']."\" Voice-Port: \"".$ts['voice']."\" Query-Port: \"".$ts['query']."\").");
|
||||
try {
|
||||
$ts3 = TeamSpeak3::factory("serverquery://" . $ts['user'] . ":" . $ts['pass'] . "@" . $ts['host'] . ":" . $ts['query'] . "/?server_port=" . $ts['voice'] . "&blocking=0");
|
||||
$ts3 = TeamSpeak3::factory("serverquery://".$ts['user'].":".$ts['pass']."@".$ts['host'].":".$ts['query']."/?server_port=".$ts['voice']."&blocking=0");
|
||||
enter_logfile($logpath,$timezone,5," Connection to TS3 Server established.");
|
||||
try {
|
||||
usleep($slowmode);
|
||||
$ts3->notifyRegister("textprivate");
|
||||
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", "handle_messages");
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2," Error due register notifyTextmessage ".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
usleep($slowmode);
|
||||
@@ -128,7 +142,7 @@ try {
|
||||
if($defchid != 0) {
|
||||
try { usleep($slowmode); $ts3->clientMove($whoami['client_id'],$defchid); } catch (Exception $e) {}
|
||||
}
|
||||
calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid);
|
||||
calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid,$ts);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
@@ -140,6 +154,7 @@ try {
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$cleanperiod,$logpath);
|
||||
$looptime = microtime(true) - $starttime;
|
||||
try { $ts3->getAdapter(); } catch (Exception $e) {}
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
@@ -147,7 +162,7 @@ catch (Exception $e) {
|
||||
$offline_status = array(110,257,258,1024,1026,1031,1032,1033,1034,1280,1793);
|
||||
if(in_array($e->getCode(), $offline_status)) {
|
||||
if($mysqlcon->exec("UPDATE $dbname.stats_server SET server_status='0'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,$lang['error'].print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,$lang['error'].print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serv
|
||||
$server_used_slots = 0;
|
||||
$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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 1:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$uuids = $uuids->fetchAll();
|
||||
foreach($uuids as $uuid) {
|
||||
@@ -33,7 +33,7 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serv
|
||||
// Event Handling each 6 hours
|
||||
// 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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 2:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$max_entry_usersnap = $max_entry_usersnap->fetch(PDO::FETCH_ASSOC);
|
||||
$diff_max_usersnap = $nowtime - $max_entry_usersnap['timestamp'];
|
||||
@@ -46,14 +46,14 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serv
|
||||
$allinsertsnap = substr($allinsertsnap, 0, -1);
|
||||
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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 3:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Delete old Entries in user_snapshot
|
||||
$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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 4:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serv
|
||||
|
||||
// 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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 5:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 6:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$snapshot_count_week = $snapshot_count_week->fetch(PDO::FETCH_ASSOC);
|
||||
$total_online_week = $snapshot_count_week['count'];
|
||||
@@ -85,7 +85,7 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serv
|
||||
if ($entry_snapshot_count['timestamp'] > 119) {
|
||||
// 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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 7:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$snapshot_count_month = $snapshot_count_month->fetch(PDO::FETCH_ASSOC);
|
||||
$total_online_month = $snapshot_count_month['count'];
|
||||
@@ -183,7 +183,7 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serv
|
||||
$version_name_5 = $version['version'];
|
||||
}
|
||||
}
|
||||
$version_other = $version_other[0]['count'] - $version_1 + $version_2 + $version_3 + $version_4 + $version_5;
|
||||
$version_other = $version_other[0]['count'] - $version_1 - $version_2 - $version_3 - $version_4 - $version_5;
|
||||
|
||||
$total_user = count($sqlhis);
|
||||
$server_used_slots = $serverinfo['virtualserver_clientsonline'] - $serverinfo['virtualserver_queryclientsonline'];
|
||||
@@ -203,26 +203,26 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serv
|
||||
$server_version = $serverinfo['virtualserver_version'];
|
||||
|
||||
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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 8:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
// Stats for Server Usage
|
||||
if(($max_entry_serverusage = $mysqlcon->query("SELECT MAX(timestamp) AS timestamp FROM $dbname.server_usage")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 9:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 9:".print_r($mysqlcon->errorInfo(), true));
|
||||
$sqlerr++;
|
||||
}
|
||||
$max_entry_serverusage = $max_entry_serverusage->fetch(PDO::FETCH_ASSOC);
|
||||
$diff_max_serverusage = $nowtime - $max_entry_serverusage['timestamp'];
|
||||
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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 10:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
//Calc time next rankup
|
||||
$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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 11:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if ($uuidsoff->rowCount() != 0) {
|
||||
$uuidsoff = $uuidsoff->fetchAll(PDO::FETCH_ASSOC);
|
||||
@@ -261,21 +261,21 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serv
|
||||
}
|
||||
$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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 12:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
//Calc Rank
|
||||
if($mysqlcon->exec("SET @a:=0") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 13:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 14:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
} 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()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 14:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
<?PHP
|
||||
function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid) {
|
||||
function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid,$ts) {
|
||||
$nowtime = time();
|
||||
|
||||
if(($getversion = $mysqlcon->query("SELECT * FROM $dbname.job_check WHERE job_name='get_version'")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user -3:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user -3:".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$getversion = $getversion->fetchAll();
|
||||
$updatetime = $nowtime - 43200;
|
||||
if ($getversion[0]['timestamp'] < $updatetime) {
|
||||
set_error_handler(function() { });
|
||||
$newversion = file_get_contents('http://ts-n.net/ranksystem/version');
|
||||
restore_error_handler();
|
||||
$newversion=get_data('http://ts-n.net/ranksystem/version',$currvers,$ts);
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='get_version'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user -2:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user -2:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE $dbname.config SET newversion='$newversion'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user -1:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user -1:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,12 +21,12 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
if ($update == 1) {
|
||||
$updatetime = $nowtime - $updateinfotime;
|
||||
if(($lastupdate = $mysqlcon->query("SELECT * FROM $dbname.job_check WHERE job_name='check_update'")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 0:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 0:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$lastupdate = $lastupdate->fetchAll();
|
||||
if ($lastupdate[0]['timestamp'] < $updatetime) {
|
||||
if(($getversion = $mysqlcon->query("SELECT newversion FROM $dbname.config")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 1:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 1:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$getversion = $getversion->fetch(PDO::FETCH_ASSOC);
|
||||
$newversion = $getversion['newversion'];
|
||||
@@ -46,13 +44,13 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp=$nowtime WHERE job_name='check_update'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 3:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 3:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(($dbdata = $mysqlcon->query("SELECT * FROM $dbname.job_check WHERE job_name='calc_user_lastscan'")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 4:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 4:".print_r($mysqlcon->errorInfo(), true));
|
||||
exit;
|
||||
}
|
||||
$lastscanarr = $dbdata->fetchAll();
|
||||
@@ -66,10 +64,10 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
}
|
||||
if ($dbdata->rowCount() != 0) {
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='calc_user_lastscan'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 5:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 5:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if(($dbuserdata = $mysqlcon->query("SELECT uuid,cldbid,count,grpid,nextup,idle,boosttime FROM $dbname.user")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 6:".print_r($mysqlcon->errorInfo()));
|
||||
if(($dbuserdata = $mysqlcon->query("SELECT uuid,cldbid,count,grpid,nextup,idle,boosttime,grpsince FROM $dbname.user")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 6:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$uuids = $dbuserdata->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach($uuids as $uuid) {
|
||||
@@ -80,7 +78,8 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
"grpid" => $uuid['grpid'],
|
||||
"nextup" => $uuid['nextup'],
|
||||
"idle" => $uuid['idle'],
|
||||
"boosttime" => $uuid['boosttime']
|
||||
"boosttime" => $uuid['boosttime'],
|
||||
"grpsince" => $uuid['grpsince']
|
||||
);
|
||||
$uidarr[] = $uuid['uuid'];
|
||||
}
|
||||
@@ -130,6 +129,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
$idle = $sqlhis[$uid]['idle'] + $clientidle;
|
||||
$grpid = $sqlhis[$uid]['grpid'];
|
||||
$nextup = $sqlhis[$uid]['nextup'];
|
||||
$grpsince = $sqlhis[$uid]['grpsince'];
|
||||
if ($sqlhis[$uid]['cldbid'] != $cldbid && $resetbydbchange == 1) {
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['changedbid'], $name, $uid, $cldbid, $sqlhis[$uid]['cldbid']));
|
||||
$count = 1;
|
||||
@@ -206,6 +206,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientAdd($groupid, $cldbid);
|
||||
$grpsince = $nowtime;
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrpadd'], $groupid, $name, $uid, $cldbid));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
@@ -214,7 +215,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
}
|
||||
$grpid = $groupid;
|
||||
if ($msgtouser == 1) {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$days = $dtF->diff($dtT)->format('%a');
|
||||
$hours = $dtF->diff($dtT)->format('%h');
|
||||
$mins = $dtF->diff($dtT)->format('%i');
|
||||
@@ -249,7 +250,8 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
"platform" => $platform,
|
||||
"nation" => $nation,
|
||||
"version" => $version,
|
||||
"except" => $except
|
||||
"except" => $except,
|
||||
"grpsince" => $grpsince
|
||||
);
|
||||
} else {
|
||||
$grpid = '0';
|
||||
@@ -281,7 +283,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("UPDATE $dbname.user SET online='0'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 13:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
if ($insertdata != '') {
|
||||
@@ -292,7 +294,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
$allinsertdata = substr($allinsertdata, 0, -1);
|
||||
if ($allinsertdata != '') {
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.user (uuid, cldbid, count, ip, name, lastseen, grpid, nextup, cldgroup, platform, nation, version, firstcon, except, online) VALUES $allinsertdata") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 14:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 14:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,6 +317,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
$allupdatenation = '';
|
||||
$allupdateversion = '';
|
||||
$allupdateexcept = '';
|
||||
$allupdategrpsince = '';
|
||||
foreach ($updatedata as $updatearr) {
|
||||
$allupdateuuid = $allupdateuuid . $updatearr['uuid'] . ",";
|
||||
$allupdatecldbid = $allupdatecldbid . "WHEN " . $updatearr['uuid'] . " THEN '" . $updatearr['cldbid'] . "' ";
|
||||
@@ -331,10 +334,11 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
$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'] . "' ";
|
||||
}
|
||||
$allupdateuuid = substr($allupdateuuid, 0, -1);
|
||||
if($mysqlcon->exec("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, online = 1 WHERE uuid IN ($allupdateuuid)") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 15:".print_r($mysqlcon->errorInfo()));
|
||||
if($mysqlcon->exec("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, online = 1 WHERE uuid IN ($allupdateuuid)") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 15:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath) {
|
||||
|
||||
if(($count_user = $mysqlcon->query("SELECT count(*) as count FROM ((SELECT u.uuid FROM $dbname.user AS u INNER JOIN $dbname.stats_user As s On u.uuid=s.uuid) UNION (SELECT u.uuid FROM $dbname.user AS u LEFT JOIN $dbname.stats_user As s On u.uuid=s.uuid WHERE s.uuid IS NULL)) x")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 1:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 1:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$count_user = $count_user->fetchAll(PDO::FETCH_ASSOC);
|
||||
$total_user = $count_user[0]['count'];
|
||||
|
||||
if(($job_begin = $mysqlcon->query("SELECT timestamp FROM $dbname.job_check WHERE job_name='calc_user_limit'")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 2:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 2:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$job_begin = $job_begin->fetchAll();
|
||||
$job_begin = $job_begin[0]['timestamp'];
|
||||
@@ -21,7 +21,7 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpat
|
||||
}
|
||||
|
||||
if(($uuids = $mysqlcon->query("(SELECT u.uuid,u.rank,u.cldbid FROM $dbname.user AS u INNER JOIN $dbname.stats_user As s On u.uuid=s.uuid) UNION (SELECT u.uuid,u.rank,u.cldbid FROM $dbname.user AS u LEFT JOIN $dbname.stats_user As s On u.uuid=s.uuid WHERE s.uuid IS NULL) ORDER BY cldbid ASC LIMIT $job_begin, 10")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 3:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 3:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$uuids = $uuids->fetchAll();
|
||||
foreach($uuids as $uuid) {
|
||||
@@ -34,11 +34,11 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpat
|
||||
|
||||
// Calc Client Stats
|
||||
if ($mysqlcon->exec("UPDATE $dbname.stats_user AS t LEFT JOIN $dbname.user AS u ON t.uuid=u.uuid SET t.removed='1' WHERE u.uuid IS NULL") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 4:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 4:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
if(($statsuserhis = $mysqlcon->query("SELECT uuid, removed FROM $dbname.stats_user")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 5:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 5:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$statsuserhis = $statsuserhis->fetchAll();
|
||||
foreach($statsuserhis as $userhis) {
|
||||
@@ -49,19 +49,19 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpat
|
||||
if(isset($sqlhis)) {
|
||||
//enter_logfile($logpath,$timezone,6,"Update User Stats between ".$job_begin." and ".$job_end.":");
|
||||
if(($userdataweekbegin = $mysqlcon->query("SELECT uuid,count,idle 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)")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 6:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 6:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$userdataweekbegin = $userdataweekbegin->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_ASSOC);
|
||||
if(($userdataweekend = $mysqlcon->query("SELECT uuid,count,idle 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)")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 7:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 7:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$userdataweekend = $userdataweekend->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_ASSOC);
|
||||
if(($userdatamonthbegin = $mysqlcon->query("SELECT uuid,count,idle 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)")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 8:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 8:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$userdatamonthbegin = $userdatamonthbegin->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_ASSOC);
|
||||
if(($userdatamonthend = $mysqlcon->query("SELECT uuid,count,idle 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)")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 9:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 9:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$userdatamonthend = $userdatamonthend->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_ASSOC);
|
||||
|
||||
@@ -119,20 +119,20 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpat
|
||||
}
|
||||
|
||||
if ($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp=$job_end WHERE job_name='calc_user_limit'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 11:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 11:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
if ($allupdateuuid != '') {
|
||||
$allupdateuuid = substr($allupdateuuid, 0, -1);
|
||||
if ($mysqlcon->exec("UPDATE $dbname.stats_user set rank = CASE uuid $allupdaterank END, count_week = CASE uuid $allupdatecountw END, count_month = CASE uuid $allupdatecountm END, idle_week = CASE uuid $allupdateidlew END, idle_month = CASE uuid $allupdateidlem END, total_connections = CASE uuid $allupdatetotac END, base64hash = CASE uuid $allupdatebase64 END, client_total_up = CASE uuid $allupdatecldtup END, client_total_down = CASE uuid $allupdatecldtdo END, client_description = CASE uuid $allupdateclddes END WHERE uuid IN ($allupdateuuid)") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 12:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 12:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
if($allinsertuserstats != '') {
|
||||
$allinsertuserstats = substr($allinsertuserstats, 0, -1);
|
||||
if ($mysqlcon->exec("INSERT INTO $dbname.stats_user (uuid,rank,count_week,count_month,idle_week,idle_month,total_connections,base64hash,client_total_up,client_total_down,client_description) VALUES $allinsertuserstats") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 13:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?PHP
|
||||
function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
$newversion = '1.1.1';
|
||||
$newversion = '1.1.2';
|
||||
enter_logfile($logpath,$timezone,5,"Check Ranksystem database for updates.");
|
||||
|
||||
function set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath) {
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set currvers='$newversion'") === false) {
|
||||
enter_logfile($logpath,$timezone,1," An error happens due updating the Ranksystem Database:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1," An error happens due updating the Ranksystem Database:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile($logpath,$timezone,1," Check the database connection properties in other/dbconfig.php and check also the database permissions.");
|
||||
exit;
|
||||
} else {
|
||||
@@ -26,6 +26,14 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
enter_logfile($logpath,$timezone,2,sprintf($lang['isntwichm'],'avatars'));
|
||||
}
|
||||
}
|
||||
|
||||
function check_config($mysqlcon,$dbname) {
|
||||
if(($dbdata = $mysqlcon->query("SELECT * FROM $dbname.config")) === false) { } else {
|
||||
if($dbdata->rowCount() > 1) {
|
||||
if($mysqlcon->exec("DELETE FROM $dbname.config WHERE webuser IS NULL") === false) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function old_files($timezone,$logpath) {
|
||||
if(is_file(substr(__DIR__,0,-4).'install.php')) {
|
||||
@@ -124,127 +132,128 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
enter_logfile($logpath,$timezone,5," No newer version detected; Database check finished.");
|
||||
old_files($timezone,$logpath);
|
||||
check_chmod($timezone);
|
||||
check_config($mysqlcon,$dbname);
|
||||
} elseif($currvers=="0.13-beta") {
|
||||
enter_logfile($logpath,$timezone,4," Update the Ranksystem Database to version 1.0.1");
|
||||
|
||||
$errcount=1;
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.user ADD (boosttime bigint(11) NOT NULL default '0', rank bigint(11) NOT NULL default '0', platform text default NULL, nation text default NULL, version text default NULL, firstcon bigint(11) NOT NULL default '0', except int(1) NOT NULL default '0')") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"user\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"user\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (boost text default NULL, showcolas int(1) NOT NULL default '0', defchid bigint(11) NOT NULL default '0', timezone varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci, logpath varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci)") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"config\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"config\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
$logpath = addslashes(__DIR__."/logs/");
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config MODIFY slowmode bigint(11) NOT NULL default '0'") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"config\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"config\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set defchid='0', timezome='Europe/Berlin', slowmode='0', logpath='$logpath'") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"config\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"config\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.groups ADD (icondate bigint(11) NOT NULL default '0')") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"groups\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"groups\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE $dbname.server_usage (timestamp bigint(11) NOT NULL default '0', clients bigint(11) NOT NULL default '0', channel bigint(11) NOT NULL default '0')") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"server_usage\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"server_usage\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE $dbname.user_snapshot (timestamp bigint(11) NOT NULL default '0', uuid varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci, count bigint(11) NOT NULL default '0', idle bigint(11) NOT NULL default '0')") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"user_snapshot\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"user_snapshot\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE INDEX snapshot_timestamp ON $dbname.user_snapshot (timestamp)") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"snapshot_timestamp\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"snapshot_timestamp\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE INDEX serverusage_timestamp ON $dbname.server_usage (timestamp)") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"snapshot_timestamp\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"snapshot_timestamp\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE $dbname.stats_server (total_user bigint(11) NOT NULL default '0', total_online_time bigint(13) NOT NULL default '0', total_online_month bigint(11) NOT NULL default '0', total_online_week bigint(11) NOT NULL default '0', total_active_time bigint(11) NOT NULL default '0', total_inactive_time bigint(11) NOT NULL default '0', country_nation_name_1 varchar(3) NOT NULL default '0', country_nation_name_2 varchar(3) NOT NULL default '0', country_nation_name_3 varchar(3) NOT NULL default '0', country_nation_name_4 varchar(3) NOT NULL default '0', country_nation_name_5 varchar(3) NOT NULL default '0', country_nation_1 bigint(11) NOT NULL default '0', country_nation_2 bigint(11) NOT NULL default '0', country_nation_3 bigint(11) NOT NULL default '0', country_nation_4 bigint(11) NOT NULL default '0', country_nation_5 bigint(11) NOT NULL default '0', country_nation_other bigint(11) NOT NULL default '0', platform_1 bigint(11) NOT NULL default '0', platform_2 bigint(11) NOT NULL default '0', platform_3 bigint(11) NOT NULL default '0', platform_4 bigint(11) NOT NULL default '0', platform_5 bigint(11) NOT NULL default '0', platform_other bigint(11) NOT NULL default '0', version_name_1 varchar(35) NOT NULL default '0', version_name_2 varchar(35) NOT NULL default '0', version_name_3 varchar(35) NOT NULL default '0', version_name_4 varchar(35) NOT NULL default '0', version_name_5 varchar(35) NOT NULL default '0', version_1 bigint(11) NOT NULL default '0', version_2 bigint(11) NOT NULL default '0', version_3 bigint(11) NOT NULL default '0', version_4 bigint(11) NOT NULL default '0', version_5 bigint(11) NOT NULL default '0', version_other bigint(11) NOT NULL default '0', server_status int(1) NOT NULL default '0', server_free_slots bigint(11) NOT NULL default '0', server_used_slots bigint(11) NOT NULL default '0', server_channel_amount bigint(11) NOT NULL default '0', server_ping bigint(11) NOT NULL default '0', server_packet_loss float (4,4), server_bytes_down bigint(11) NOT NULL default '0', server_bytes_up bigint(11) NOT NULL default '0', server_uptime bigint(11) NOT NULL default '0', server_id bigint(11) NOT NULL default '0', server_name text CHARACTER SET utf8 COLLATE utf8_unicode_ci, server_pass int(1) NOT NULL default '0', server_creation_date bigint(11) NOT NULL default '0', server_platform text CHARACTER SET utf8 COLLATE utf8_unicode_ci, server_weblist text CHARACTER SET utf8 COLLATE utf8_unicode_ci, server_version text CHARACTER SET utf8 COLLATE utf8_unicode_ci)") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"stats_server\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"stats_server\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE $dbname.stats_user (uuid varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, removed int(1) NOT NULL default '0', rank bigint(11) NOT NULL default '0', total_connections bigint(11) NOT NULL default '0', count_week bigint(11) NOT NULL default '0', count_month bigint(11) NOT NULL default '0', idle_week bigint(11) NOT NULL default '0', idle_month bigint(11) NOT NULL default '0', achiev_count bigint(11) NOT NULL default '0', achiev_time bigint(11) NOT NULL default '0', achiev_connects bigint(11) NOT NULL default '0', achiev_battles bigint(11) NOT NULL default '0', achiev_time_perc int(3) NOT NULL default '0', achiev_connects_perc int(3) NOT NULL default '0', achiev_battles_perc int(3) NOT NULL default '0', battles_total bigint(11) NOT NULL default '0', battles_won bigint(11) NOT NULL default '0', battles_lost bigint(11) NOT NULL default '0', client_description text CHARACTER SET utf8 COLLATE utf8_unicode_ci, base64hash varchar(58) CHARACTER SET utf8 COLLATE utf8_unicode_ci, client_total_up bigint(15) NOT NULL default '0', client_total_down bigint(15) NOT NULL default '0')") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"stats_user\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"stats_user\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.stats_server SET total_user='9999'") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"stats_server\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"stats_server\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE $dbname.job_check (job_name varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, timestamp bigint(11) NOT NULL default '0')") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_check\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_check\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.job_check (job_name) VALUES ('calc_user_limit'),('calc_user_lastscan'),('check_update'),('check_clean')") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_check\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_check\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE $dbname.job_log (id bigint(11) AUTO_INCREMENT PRIMARY KEY, timestamp bigint(11) NOT NULL default '0', job_name varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci, status int(1) NOT NULL default '0', err_msg text CHARACTER SET utf8 COLLATE utf8_unicode_ci, runtime float (4,4))") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_log\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_log\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
|
||||
if(($lastscan = $mysqlcon->query("SELECT timestamp FROM $dbname.lastscan")) === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"lastscan\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"lastscan\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
} else {
|
||||
$timestampls = $lastscan->fetchAll();
|
||||
$calc_user_lastscan = $timestampls[0]['timestamp'];
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$calc_user_lastscan' WHERE job_name='calc_user_lastscan'") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_check\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_check\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
} elseif($mysqlcon->exec("DROP TABLE $dbname.lastscan") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"lastscan\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"lastscan\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
}
|
||||
|
||||
if(($lastupdate = $mysqlcon->query("SELECT timestamp FROM $dbname.upcheck")) === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
} else {
|
||||
$timestampuc = $lastupdate->fetchAll();
|
||||
$check_update = $timestampuc[0]['timestamp'];
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$check_update' WHERE job_name='check_update'") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_check\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"job_check\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
} elseif($mysqlcon->exec("DROP TABLE $dbname.upcheck") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
}
|
||||
|
||||
if(($lastclean = $mysqlcon->query("SELECT timestamp FROM $dbname.cleanclients")) === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
} else {
|
||||
$timestamplc = $lastclean->fetchAll();
|
||||
$check_clean = $timestampls[0]['timestamp'];
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$check_clean' WHERE job_name='check_clean'") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
} elseif($mysqlcon->exec("DROP TABLE $dbname.cleanclients") === false) {
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo(), true));
|
||||
$errcount++;
|
||||
}
|
||||
}
|
||||
@@ -260,28 +269,28 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
}
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,4," Update the Ranksystem Database to new version...");
|
||||
if($mysqlcon->exec("CREATE INDEX serverusage_timestamp ON $dbname.server_usage (timestamp)") === false) { }
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (advancemode int(1) NOT NULL default '0', count_access int(2) NOT NULL default '0', last_access bigint(11) NOT NULL default '0', ignoreidle bigint(11) NOT NULL default '0', exceptcid text CHARACTER SET utf8 COLLATE utf8_unicode_ci, rankupmsg text CHARACTER SET utf8 COLLATE utf8_unicode_ci, boost_mode int(1) NOT NULL default '0', newversion varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci)") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.0] Adjusted table config successfully.");
|
||||
}
|
||||
if(version_compare($currvers, '1.1.0', '<')) {
|
||||
if(version_compare($currvers, '1.0.2', '<=')) {
|
||||
if($mysqlcon->exec("CREATE INDEX serverusage_timestamp ON $dbname.server_usage (timestamp)") === false) { }
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (advancemode int(1) NOT NULL default '0', count_access int(2) NOT NULL default '0', last_access bigint(11) NOT NULL default '0', ignoreidle bigint(11) NOT NULL default '0', exceptcid text CHARACTER SET utf8 COLLATE utf8_unicode_ci, rankupmsg text CHARACTER SET utf8 COLLATE utf8_unicode_ci, boost_mode int(1) NOT NULL default '0', newversion varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci)") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.0] Adjusted table config successfully.");
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set ignoreidle='600', rankupmsg='\\nHey, you got a rank up, cause you reached an activity of %s days, %s hours, %s minutes and %s seconds.', newversion='1.1.0'") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.0] Set default values to new fields in table config.");
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.job_check (job_name) VALUES ('get_version')") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.0] Set new values to table job_check.");
|
||||
}
|
||||
if(($password = $mysqlcon->query("SELECT webpass FROM $dbname.config")) === false) { }
|
||||
$password = $password->fetchAll();
|
||||
if(strlen($password[0]['webpass']) != 60) {
|
||||
$newwebpass = password_hash($password[0]['webpass'], PASSWORD_DEFAULT);
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set webpass='$newwebpass'") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.0] Encrypted password for the webinterface and wrote hash to database.");
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.job_check (job_name) VALUES ('get_version')") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.0] Set new values to table job_check.");
|
||||
}
|
||||
if(($password = $mysqlcon->query("SELECT webpass FROM $dbname.config")) === false) { }
|
||||
$password = $password->fetchAll();
|
||||
if(strlen($password[0]['webpass']) != 60) {
|
||||
$newwebpass = password_hash($password[0]['webpass'], PASSWORD_DEFAULT);
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set webpass='$newwebpass'") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.0] Encrypted password for the webinterface and wrote hash to database.");
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config DROP COLUMN showexgrp, DROP COLUMN showgen, DROP COLUMN bgcolor, DROP COLUMN hdcolor, DROP COLUMN txcolor, DROP COLUMN hvcolor, DROP COLUMN ifcolor, DROP COLUMN wncolor, DROP COLUMN sccolor") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.0] Delete old configs, which are no more needed.");
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config DROP COLUMN showexgrp, DROP COLUMN showgen, DROP COLUMN bgcolor, DROP COLUMN hdcolor, DROP COLUMN txcolor, DROP COLUMN hvcolor, DROP COLUMN ifcolor, DROP COLUMN wncolor, DROP COLUMN sccolor") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.0] Delete old configs, which are no more needed.");
|
||||
}
|
||||
if(version_compare($currvers, '1.1.0', '<=')) {
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.user CHANGE ip clientip bigint(11) NOT NULL default '0'") === false) { }
|
||||
@@ -309,7 +318,7 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (servernews text CHARACTER SET utf8 COLLATE utf8_unicode_ci)") === false) { } else {
|
||||
$servernews = $mysqlcon->quote(file_get_contents('../server-news'));
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.config (servernews) VALUES ($servernews)") === false) { } else {
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set servernews='$servernews')") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.1] Adjusted table config successfully.");
|
||||
}
|
||||
}
|
||||
@@ -317,9 +326,30 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.1] Drop table job_log, which is no more needed.");
|
||||
}
|
||||
}
|
||||
if(version_compare($currvers, '1.1.1', '<=')) {
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (adminuuid varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci, nextupinfo int(1) NOT NULL default '0', nextupinfomsg1 text CHARACTER SET utf8 COLLATE utf8_unicode_ci, nextupinfomsg2 text CHARACTER SET utf8 COLLATE utf8_unicode_ci, nextupinfomsg3 text CHARACTER SET utf8 COLLATE utf8_unicode_ci)") === false) { } else {
|
||||
$nextupinfomsg1 = $mysqlcon->quote("Your next rank up will be in %1\$s days, %2\$s hours, %3\$s minutes and %4\$s seconds. The next servergroup you will reach is [B]%5\$s[/B].");
|
||||
$nextupinfomsg2 = $mysqlcon->quote("You have already reached the highest rank.");
|
||||
$nextupinfomsg3 = $mysqlcon->quote("You are excepted from the Ranksystem. If you wish to rank contact an admin on the TS3 server.");
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set nextupinfo='1', nextupinfomsg1=$nextupinfomsg1, nextupinfomsg2=$nextupinfomsg2, nextupinfomsg3=$nextupinfomsg3") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.2] Adjusted table config (part1) successfully.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(version_compare($currvers, '1.1.1', '<=')) {
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (shownav int(1) NOT NULL default '0', showgrpsince int(1) NOT NULL default '0')") === false) { } else {
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set shownav='1', showgrpsince='1'") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.2] Adjusted table config (part2) successfully.");
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.user ADD (grpsince bigint(11) NOT NULL default '0')") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.1.2] Adjusted table user successfully.");
|
||||
}
|
||||
}
|
||||
$currvers = set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath);
|
||||
old_files($timezone,$logpath);
|
||||
check_chmod($timezone);
|
||||
check_config($mysqlcon,$dbname);
|
||||
}
|
||||
return $currvers;
|
||||
}
|
||||
|
||||
@@ -5,24 +5,24 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$c
|
||||
|
||||
// clean usersnaps older then 1 month
|
||||
if($mysqlcon->query("DELETE a FROM $dbname.user_snapshot AS a CROSS JOIN(SELECT DISTINCT(timestamp) FROM $dbname.user_snapshot ORDER BY timestamp DESC LIMIT 1000 OFFSET 121) AS b WHERE a.timestamp=b.timestamp") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"clean 2.1:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"clean 2.1:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
// clean old server usage - older then a year
|
||||
if($mysqlcon->query("DELETE FROM $dbname.server_usage WHERE timestamp < (UNIX_TIMESTAMP() - 31536000)") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"clean 2.2:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"clean 2.2:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
// clean old clients out of the database
|
||||
if ($cleanclients == 1) {
|
||||
$cleantime = $nowtime - $cleanperiod;
|
||||
if(($lastclean = $mysqlcon->query("SELECT * FROM $dbname.job_check WHERE job_name='check_clean'")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"clean 3:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"clean 3:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$lastclean = $lastclean->fetchAll();
|
||||
if ($lastclean[0]['timestamp'] < $cleantime) {
|
||||
if(($dbuserdata = $mysqlcon->query("SELECT uuid FROM $dbname.user")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"clean 4:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"clean 4:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$countrs = $dbuserdata->rowCount();
|
||||
$uuids = $dbuserdata->fetchAll();
|
||||
@@ -69,18 +69,18 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$c
|
||||
$alldeldata = "(".$alldeldata.")";
|
||||
if ($alldeldata != '') {
|
||||
if($mysqlcon->exec("DELETE FROM $dbname.user WHERE uuid IN $alldeldata") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"clean 5:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"clean 5:".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,4," ".sprintf($lang['cleandel'], $countdel));
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='check_clean'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"clean 6:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"clean 6:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,4," ".$lang['cleanno']);
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='check_clean'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"clean 7:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"clean 7:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
129
jobs/handle_messages.php
Normal file
129
jobs/handle_messages.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?PHP
|
||||
function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host) {
|
||||
global $lang, $logpath, $timezone, $nextupinfo, $nextupinfomsg1, $nextupinfomsg2, $nextupinfomsg3, $mysqlcon, $dbname, $grouptime, $substridle, $slowmode, $currvers, $newversion, $adminuuid;
|
||||
if($host->whoami()["client_unique_identifier"] != $event["invokeruid"]) { //check whoami need to slowmode or is already stored?
|
||||
$uuid = $event["invokeruid"];
|
||||
|
||||
|
||||
if(strstr($event["msg"], 'nextup') && $nextupinfo == 1) {
|
||||
//enter_logfile($logpath,$timezone,6,"Client ".$event["invokername"]." (".$event["invokeruid"].") sent textmessage: ".$event["msg"]);
|
||||
if(($dbuserdata = $mysqlcon->query("SELECT count,nextup,idle,except FROM $dbname.user WHERE uuid='$uuid'")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 1:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$user = $dbuserdata->fetchAll(PDO::FETCH_ASSOC);
|
||||
$nextup = $user[0]['nextup'];
|
||||
$dtF = new DateTime("@0");
|
||||
$dtT = new DateTime("@$nextup");
|
||||
$days = $dtF->diff($dtT)->format('%a');
|
||||
$hours = $dtF->diff($dtT)->format('%h');
|
||||
$mins = $dtF->diff($dtT)->format('%i');
|
||||
$secs = $dtF->diff($dtT)->format('%s');
|
||||
|
||||
if(($dbgroups = $mysqlcon->query("SELECT * FROM $dbname.groups")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 2:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$servergroups = $dbgroups->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach($servergroups as $servergroup) {
|
||||
$sqlhisgroup[$servergroup['sgid']] = $servergroup['sgidname'];
|
||||
}
|
||||
|
||||
ksort($grouptime);
|
||||
$countgrp = count($grouptime);
|
||||
$grpcount=0;
|
||||
foreach ($grouptime as $time => $groupid) {
|
||||
$grpcount++;
|
||||
if ($substridle == 1) {
|
||||
$activetime = $user[0]['count'] - $user[0]['idle'];
|
||||
} else {
|
||||
$activetime = $user[0]['count'];
|
||||
}
|
||||
if ($activetime < $time || $grpcount == $countgrp && $nextup <= 0) {
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
if ($grpcount == $countgrp && $nextup == 0) {
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg2, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid]));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 3:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
} elseif ($user[0]['except'] == 1) {
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg3, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid]));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 4:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg1, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid]));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 5:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(strstr($event["msg"], 'version')) {
|
||||
if(version_compare(substr($newversion, 0, 5), substr($currvers, 0, 5), '>') && $newversion != '') {
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($lang['upmsg'], $currvers, $newversion));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 6:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($lang['msg0001'], $currvers));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 7:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(strstr($event["msg"], 'help') || strstr($event["msg"], 'info') || strstr($event["msg"], 'commands')) {
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0002']);
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 8:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if((strstr($event["msg"], 'shutdown') || strstr($event["msg"], 'quit') || strstr($event["msg"], 'stop')) && $event["invokeruid"] == $adminuuid) {
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['msg0004'], $event["invokername"], $event["invokeruid"]));
|
||||
$path = substr(__DIR__, 0, -4);
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0005']);
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 9:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
exec("php ".$path."worker.php stop");
|
||||
} elseif (strstr($event["msg"], 'shutdown') || strstr($event["msg"], 'exit')) {
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0003']);
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 10:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if((strstr($event["msg"], 'restart') || strstr($event["msg"], 'reboot')) && $event["invokeruid"] == $adminuuid) {
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['msg0007'], $event["invokername"], $event["invokeruid"]));
|
||||
$path = substr(__DIR__, 0, -4);
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0006']);
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 11:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
exec("start php ".$path."worker.php restart");
|
||||
} else {
|
||||
exec("php ".$path."worker.php restart > /dev/null 2>/dev/null &");
|
||||
}
|
||||
} elseif (strstr($event["msg"], 'shutdown') || strstr($event["msg"], 'exit')) {
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0003']);
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 12:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -24,7 +24,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serveri
|
||||
}
|
||||
|
||||
if(($dbgroups = $mysqlcon->query("SELECT * FROM $dbname.groups")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 3:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 3:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if ($dbgroups->rowCount() == 0) {
|
||||
$sqlhisgroup = "empty";
|
||||
@@ -93,7 +93,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serveri
|
||||
try {
|
||||
$iconfile = $servergroup->iconDownload();
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 5:".$e->getCode().': '."Error while downloading servericon: ".$e->getMessage());
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 5:".$e->getCode().': '."Error while downloading servergroupicon: ".$e->getMessage());
|
||||
}
|
||||
if(file_put_contents(substr(dirname(__FILE__),0,-4) . "icons/" . $sgid . ".png", $iconfile) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"Error while writing out the servergroup icon. Please check the permission for the folder 'icons'");
|
||||
@@ -103,6 +103,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serveri
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($iconarr["i".$iconid])) {
|
||||
$iconarr["i".$iconid] = 0;
|
||||
}
|
||||
@@ -115,7 +116,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serveri
|
||||
"sgidname" => $sgname,
|
||||
"iconid" => $iconid,
|
||||
"icon" => $iconfile,
|
||||
"icondate" => $groups['icondate']
|
||||
"icondate" => $iconarr["i".$iconid]
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -143,16 +144,12 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serveri
|
||||
if (isset($insertgroups)) {
|
||||
$allinsertdata = '';
|
||||
foreach ($insertgroups as $insertarr) {
|
||||
if( $insertarr['iconid'] == 0 || $insertarr['icondate'] == null || $insertarr['icondate'] == 0) {
|
||||
//enter_logfile($logpath,$timezone,6,"IconID is 0 for (servergroup) ".$insertarr['sgidname']." (".$insertarr['sgid'].")");
|
||||
continue;
|
||||
}
|
||||
$allinsertdata = $allinsertdata . "('" . $insertarr['sgid'] . "', " . $insertarr['sgidname'] . ", '" . $insertarr['iconid'] . "', '" . $insertarr['icondate'] . "'),";
|
||||
}
|
||||
$allinsertdata = substr($allinsertdata, 0, -1);
|
||||
if ($allinsertdata != '') {
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.groups (sgid, sgidname, iconid, icondate) VALUES $allinsertdata") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 7:".$allinsertdata.print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 7:".$allinsertdata.print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,7 +167,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serveri
|
||||
}
|
||||
$allsgids = substr($allsgids, 0, -1);
|
||||
if($mysqlcon->exec("UPDATE $dbname.groups set sgidname = CASE sgid $allupdatesgid END, iconid = CASE sgid $allupdateiconid END, icondate = CASE sgid $allupdatedate END WHERE sgid IN ($allsgids)") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 8:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 8:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +182,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serveri
|
||||
if(isset($delsgroupids)) {
|
||||
$delsgroupids = substr($delsgroupids, 0, -1);
|
||||
if($mysqlcon->exec("DELETE FROM $dbname.groups WHERE sgid IN ($delsgroupids)") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 9:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"update_groups 9:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user