From db7e1e6650e75da24f5d6d13c55270b593dbfb23 Mon Sep 17 00:00:00 2001 From: Newcomer1989 Date: Fri, 23 Feb 2018 19:45:50 +0100 Subject: [PATCH] release 1.2.5 --- install.php | 39 +++-- jobs/bot.php | 73 +++++----- jobs/calc_serverstats.php | 63 ++++---- jobs/check_db.php | 298 ++------------------------------------ jobs/update_rs.php | 38 ++--- other/config.php | 30 ++-- stats/list_rankup.php | 2 +- stats/top_month.php | 2 +- stats/top_week.php | 2 +- webinterface/core.php | 1 + 10 files changed, 159 insertions(+), 389 deletions(-) diff --git a/install.php b/install.php index 0ed244e..12f0fb5 100644 --- a/install.php +++ b/install.php @@ -118,17 +118,30 @@ $db[\'dbname\']="'.$dbname.'"; $count++; } - if($mysqlcon->exec("CREATE TABLE $dbname.user (uuid varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY,cldbid int(10) NOT NULL default '0',count int(10) NOT NULL default '0',ip VARBINARY(16) DEFAULT NULL,name varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,lastseen bigint(11) NOT NULL default '0',grpid int(10) NOT NULL default '0',nextup int(10) NOT NULL default '0',idle int(10) NOT NULL default '0',cldgroup varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci,online tinyint(1) NOT NULL default '0',boosttime int(10) NOT NULL default '0',rank int(10) NOT NULL default '0',platform varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci,nation varchar(3) CHARACTER SET utf8 COLLATE utf8_unicode_ci,version varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,firstcon bigint(11) NOT NULL default '0',except tinyint(1) NOT NULL default '0',grpsince bigint(11) NOT NULL default '0')") === false) { + if($mysqlcon->exec("CREATE TABLE $dbname.user (uuid varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY,cldbid int(10) NOT NULL default '0',count int(10) NOT NULL default '0',ip VARBINARY(16) DEFAULT NULL,name varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,lastseen bigint(11) NOT NULL default '0',grpid int(10) NOT NULL default '0',nextup int(10) NOT NULL default '0',idle int(10) NOT NULL default '0',cldgroup varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci,online tinyint(1) NOT NULL default '0',boosttime int(10) NOT NULL default '0',rank int(10) NOT NULL default '0',platform varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci,nation varchar(3) CHARACTER SET utf8 COLLATE utf8_unicode_ci,version varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,firstcon bigint(11) NOT NULL default '0',except tinyint(1) NOT NULL default '0',grpsince bigint(11) NOT NULL default '0',cid int(10) NOT NULL default '0')") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; + $count++; + } else { + if($mysqlcon->exec("CREATE INDEX user_version ON $dbname.user (version)") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; + $count++; + } + if($mysqlcon->exec("CREATE INDEX user_cldbid ON $dbname.user (cldbid ASC,uuid,rank)") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; + $count++; + } + if($mysqlcon->exec("CREATE INDEX user_online ON $dbname.user (online,lastseen)") === false) { + $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; + $count++; + } + } + + if($mysqlcon->exec("CREATE TABLE $dbname.groups (sgid int(10) NOT NULL default '0' PRIMARY KEY,sgidname varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,iconid bigint(10) NOT NULL default '0',icondate bigint(11) NOT NULL default '0')") === false) { $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; $count++; } - if($mysqlcon->exec("CREATE TABLE $dbname.groups (sgid int(10) NOT NULL default '0' PRIMARY KEY,sgidname varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,iconid bigint(10) NOT NULL default '0',icondate bigint(11) NOT NULL default '0')") === false) { - $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; - $count++; - } - - if($mysqlcon->exec("CREATE TABLE $dbname.config (webuser varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,webpass varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,tshost varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,tsquery smallint(5) UNSIGNED NOT NULL default '0',tsvoice smallint(5) UNSIGNED NOT NULL default '0',tsuser varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,tspass varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,language char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci,queryname varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,queryname2 varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,grouptime varchar(5000) CHARACTER SET utf8 COLLATE utf8_unicode_ci,resetbydbchange tinyint(1) NOT NULL default '0',msgtouser tinyint(1) NOT NULL default '0',upcheck tinyint(1) NOT NULL default '0',uniqueid varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,updateinfotime mediumint(6) NOT NULL default '0',currvers varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci,substridle tinyint(1) NOT NULL default '0',exceptuuid varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,exceptgroup varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,dateformat varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,showexcld tinyint(1) NOT NULL default '0',showcolcld tinyint(1) NOT NULL default '0',showcoluuid tinyint(1) NOT NULL default '0',showcoldbid tinyint(1) NOT NULL default '0',showcolot tinyint(1) NOT NULL default '0',showcolit tinyint(1) NOT NULL default '0',showcolat tinyint(1) NOT NULL default '0',showcolnx tinyint(1) NOT NULL default '0',showcolsg tinyint(1) NOT NULL default '0',showcolrg tinyint(1) NOT NULL default '0',showcolls tinyint(1) NOT NULL default '0',slowmode mediumint(9) NOT NULL default '0',cleanclients tinyint(1) NOT NULL default '0',cleanperiod mediumint(9) NOT NULL default '0',showhighest tinyint(1) NOT NULL default '0',boost varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,showcolas tinyint(1) NOT NULL default '0',defchid int(10) NOT NULL default '0',timezone varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci,logpath varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci,advancemode tinyint(1) NOT NULL default '0',count_access tinyint(2) NOT NULL default '0',last_access bigint(11) NOT NULL default '0',ignoreidle smallint(5) NOT NULL default '0',exceptcid varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,rankupmsg varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,boost_mode tinyint(1) NOT NULL default '0',newversion varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci,servernews varchar(5000) CHARACTER SET utf8 COLLATE utf8_unicode_ci,adminuuid varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci,nextupinfo tinyint(1) NOT NULL default '0',nextupinfomsg1 varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,nextupinfomsg2 varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,nextupinfomsg3 varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,shownav tinyint(1) NOT NULL default '0',showgrpsince tinyint(1) NOT NULL default '0',resetexcept tinyint(1) NOT NULL default '0',upchannel varchar(20) NOT NULL default '0',avatar_delay smallint(5) UNSIGNED NOT NULL default '0')") === false) { + if($mysqlcon->exec("CREATE TABLE $dbname.config (webuser varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,webpass varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,tshost varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,tsquery smallint(5) UNSIGNED NOT NULL default '0',tsvoice smallint(5) UNSIGNED NOT NULL default '0',tsuser varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,tspass varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,language char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci,queryname varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,queryname2 varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,grouptime varchar(5000) CHARACTER SET utf8 COLLATE utf8_unicode_ci,resetbydbchange tinyint(1) NOT NULL default '0',msgtouser tinyint(1) NOT NULL default '0',upcheck tinyint(1) NOT NULL default '0',uniqueid varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,updateinfotime mediumint(6) NOT NULL default '0',currvers varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci,substridle tinyint(1) NOT NULL default '0',exceptuuid varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,exceptgroup varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,dateformat varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,showexcld tinyint(1) NOT NULL default '0',showcolcld tinyint(1) NOT NULL default '0',showcoluuid tinyint(1) NOT NULL default '0',showcoldbid tinyint(1) NOT NULL default '0',showcolot tinyint(1) NOT NULL default '0',showcolit tinyint(1) NOT NULL default '0',showcolat tinyint(1) NOT NULL default '0',showcolnx tinyint(1) NOT NULL default '0',showcolsg tinyint(1) NOT NULL default '0',showcolrg tinyint(1) NOT NULL default '0',showcolls tinyint(1) NOT NULL default '0',slowmode mediumint(9) NOT NULL default '0',cleanclients tinyint(1) NOT NULL default '0',cleanperiod mediumint(9) NOT NULL default '0',showhighest tinyint(1) NOT NULL default '0',boost varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,showcolas tinyint(1) NOT NULL default '0',defchid int(10) NOT NULL default '0',timezone varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci,logpath varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci,advancemode tinyint(1) NOT NULL default '0',count_access tinyint(2) NOT NULL default '0',last_access bigint(11) NOT NULL default '0',ignoreidle smallint(5) NOT NULL default '0',exceptcid varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,rankupmsg varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,boost_mode tinyint(1) NOT NULL default '0',newversion varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci,servernews varchar(5000) CHARACTER SET utf8 COLLATE utf8_unicode_ci,adminuuid varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,nextupinfo tinyint(1) NOT NULL default '0',nextupinfomsg1 varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,nextupinfomsg2 varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,nextupinfomsg3 varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,shownav tinyint(1) NOT NULL default '0',showgrpsince tinyint(1) NOT NULL default '0',resetexcept tinyint(1) NOT NULL default '0',upchannel varchar(20) NOT NULL default '0',avatar_delay smallint(5) UNSIGNED NOT NULL default '0',registercid mediumint(8) UNSIGNED NOT NULL default '0')") === false) { $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; $count++; } @@ -143,7 +156,7 @@ $db[\'dbname\']="'.$dbname.'"; } } - 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 int(10) NOT NULL default '0',idle int(10) NOT NULL default '0')") === false) { + 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 int(10) NOT NULL default '0',idle int(10) NOT NULL default '0',PRIMARY KEY (timestamp, uuid))") === false) { $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; $count++; } else { @@ -173,22 +186,22 @@ $db[\'dbname\']="'.$dbname.'"; $count++; } - if($mysqlcon->exec("INSERT INTO $dbname.job_check (job_name) VALUES ('calc_user_limit'),('calc_user_lastscan'),('check_update'),('check_clean'),('get_version')") === false) { + if($mysqlcon->exec("INSERT INTO $dbname.job_check (job_name) VALUES ('calc_user_limit'),('calc_user_lastscan'),('check_update'),('get_version'),('clean_db'),('clean_clients'),('calc_server_stats'),('runtime_check'),('last_update')") === false) { $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; $count++; } - if($mysqlcon->exec("CREATE TABLE $dbname.stats_nations (nation varchar(3) CHARACTER SET utf8 COLLATE utf8_unicode_ci, count int(10) NOT NULL default '0')") === false) { + if($mysqlcon->exec("CREATE TABLE $dbname.stats_nations (nation varchar(3) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, count int(10) NOT NULL default '0')") === false) { $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; $count++; } - if($mysqlcon->exec("CREATE TABLE $dbname.stats_versions (version varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci, count int(10) NOT NULL default '0')") === false) { + if($mysqlcon->exec("CREATE TABLE $dbname.stats_versions (version varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, count int(10) NOT NULL default '0')") === false) { $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; $count++; } - if($mysqlcon->exec("CREATE TABLE $dbname.stats_platforms (platform varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci, count int(10) NOT NULL default '0')") === false) { + if($mysqlcon->exec("CREATE TABLE $dbname.stats_platforms (platform varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci PRIMARY KEY, count int(10) NOT NULL default '0')") === false) { $err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'
'; $err_lvl = 2; $count++; } @@ -286,7 +299,7 @@ if(isset($_POST['confweb'])) { $nextupinfomsg3 = $mysqlcon->quote("You are excepted from the Ranksystem. If you wish to rank contact an admin on the TS3 server."); $servernews = $mysqlcon->quote("Message
This is an example Message.
Change this Message inside the webinterface."); $rankupmsg = $mysqlcon->quote('Hey, you reached a higher rank, since you already connected for %1$s days, %2$s hours and %3$s minutes to our TS3 server.[B]Keep it up![/B] ;-) '); - if($mysqlcon->exec("INSERT INTO $dbname.config (webuser,webpass,tshost,tsquery,tsvoice,tsuser,language,queryname,queryname2,grouptime,resetbydbchange,msgtouser,upcheck,uniqueid,updateinfotime,currvers,exceptuuid,exceptgroup,dateformat,showexcld,showcolcld,showcoluuid,showcoldbid,showcolot,showcolit,showcolat,showcolnx,showcolsg,showcolrg,showcolls,slowmode,cleanclients,cleanperiod,showhighest,showcolas,defchid,timezone,logpath,ignoreidle,rankupmsg,newversion,servernews,nextupinfo,nextupinfomsg1,nextupinfomsg2,nextupinfomsg3,shownav,showgrpsince,resetexcept,upchannel,avatar_delay) VALUES ('$user','$pass','localhost','10011','9987','serveradmin','en','Ranksystem','RankSystem','31536000=>47,31536060=>50','1','1','1','xrTKhT/HDl4ea0WoFDQH2zOpmKg=,9odBYAU7z2E2feUz965sL0/Myom=','7200','1.2.3','xrTKhT/HDl4ea0WoFDQH2zOpmKg=','2,6','%a days, %h hours, %i mins, %s secs','1','1','1','1','1','1','1','1','1','1','1','0','1','86400','1','1','0','Europe/Berlin','$logpath','600',$rankupmsg,'1.2.3',$servernews,'1',$nextupinfomsg1,$nextupinfomsg2,$nextupinfomsg3,'1','1','0','version','0')") === false) { + if($mysqlcon->exec("INSERT INTO $dbname.config (webuser,webpass,tshost,tsquery,tsvoice,tsuser,language,queryname,queryname2,grouptime,resetbydbchange,msgtouser,upcheck,uniqueid,updateinfotime,currvers,exceptuuid,exceptgroup,dateformat,showexcld,showcolcld,showcoluuid,showcoldbid,showcolot,showcolit,showcolat,showcolnx,showcolsg,showcolrg,showcolls,slowmode,cleanclients,cleanperiod,showhighest,showcolas,defchid,timezone,logpath,ignoreidle,rankupmsg,newversion,servernews,nextupinfo,nextupinfomsg1,nextupinfomsg2,nextupinfomsg3,shownav,showgrpsince,resetexcept,upchannel,avatar_delay) VALUES ('$user','$pass','localhost','10011','9987','serveradmin','en','Ranksystem','RankSystem','31536000=>47,31536060=>50','1','1','1','xrTKhT/HDl4ea0WoFDQH2zOpmKg=,9odBYAU7z2E2feUz965sL0/Myom=','7200','1.2.5','xrTKhT/HDl4ea0WoFDQH2zOpmKg=','2,6','%a days, %h hours, %i mins, %s secs','1','1','1','1','1','1','1','1','1','1','1','0','1','86400','1','1','0','Europe/Berlin','$logpath','600',$rankupmsg,'1.2.5',$servernews,'1',$nextupinfomsg1,$nextupinfomsg2,$nextupinfomsg3,'1','1','0','version','0')") === false) { $err_msg = $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 2; } else { $err_msg = $lang['isntwiusr'].'

'; diff --git a/jobs/bot.php b/jobs/bot.php index f50e081..8d3d071 100644 --- a/jobs/bot.php +++ b/jobs/bot.php @@ -92,38 +92,7 @@ require_once(substr(__DIR__,0,-4).'jobs/update_rs.php'); enter_logfile($logpath,$timezone,6,"Running on OS: ".php_uname("s")." ".php_uname("r")); enter_logfile($logpath,$timezone,6,"Using PHP Version: ".phpversion()); - -enter_logfile($logpath,$timezone,5," Config check started..."); - -if(($groupslist = $mysqlcon->query("SELECT * FROM $dbname.groups")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { - enter_logfile($logpath,$timezone,1,"Select on DB failed for group check: ".print_r($mysqlcon->errorInfo(), true)); -} - -$errcnf = 0; -if(isset($groupslist) && $groupslist != NULL) { - foreach($grouptime as $time => $groupid) { - if(!isset($groupslist[$groupid]) && $groupid != NULL) { - enter_logfile($logpath,$timezone,1,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wigrptime'])); - $errcnf++; - } - } - foreach($boostarr as $groupid => $value) { - if(!isset($groupslist[$groupid]) && $groupid != NULL) { - enter_logfile($logpath,$timezone,2,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wiboost'])); - } - } - foreach($exceptgroup as $groupid => $value) { - if(!isset($groupslist[$groupid]) && $groupid != NULL) { - enter_logfile($logpath,$timezone,2,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wiexgrp'])); - } - } -} -if($errcnf > 0) { - shutdown($mysqlcon, $logpath, $timezone, 1, "Critical Config error!"); -} -unset($groupslist,$errcnf); - -enter_logfile($logpath,$timezone,5," Config check [done]"); +enter_logfile($logpath,$timezone,6,"Database Version: ".$mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION)); function check_shutdown($timezone,$logpath) { if(!is_file(substr(__DIR__,0,-4).'logs/pid')) { @@ -134,6 +103,44 @@ function check_shutdown($timezone,$logpath) { $currvers = check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath); enter_logfile($logpath,$timezone,5,"Ranksystem Version: ".$currvers); +enter_logfile($logpath,$timezone,5," Config check started..."); + +if(($groupslist = $mysqlcon->query("SELECT * FROM $dbname.groups")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) { + enter_logfile($logpath,$timezone,1,"Select on DB failed for group check: ".print_r($mysqlcon->errorInfo(), true)); +} + +$errcnf = 0; +if(isset($groupslist) && $groupslist != NULL) { + if(isset($grouptime) && $grouptime != NULL) { + foreach($grouptime as $time => $groupid) { + if(!isset($groupslist[$groupid]) && $groupid != NULL) { + enter_logfile($logpath,$timezone,1,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wigrptime'])); + $errcnf++; + } + } + } + if(isset($boostarr) && $boostarr != NULL) { + foreach($boostarr as $groupid => $value) { + if(!isset($groupslist[$groupid]) && $groupid != NULL) { + enter_logfile($logpath,$timezone,2,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wiboost'])); + } + } + } + if(isset($exceptgroup) && $exceptgroup != NULL) { + foreach($exceptgroup as $groupid => $value) { + if(!isset($groupslist[$groupid]) && $groupid != NULL) { + enter_logfile($logpath,$timezone,2,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wiexgrp'])); + } + } + } +} +if($errcnf > 0) { + shutdown($mysqlcon, $logpath, $timezone, 1, "Critical Config error!"); +} +unset($groupslist,$errcnf); + +enter_logfile($logpath,$timezone,5," Config check [done]"); + enter_logfile($logpath,$timezone,5,"Loading addons..."); require_once(substr(__DIR__,0,-4).'other/load_addons_config.php'); $addons_config = load_addons_config($mysqlcon,$lang,$dbname,$timezone,$logpath); @@ -247,11 +254,11 @@ try { $ts3->serverInfoReset(); usleep($slowmode); $serverinfo = $ts3->serverInfo(); - $sqlexec .= update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serverinfo,$logpath,$grouptime,$boostarr,$exceptgroup,$select_arr); $sqlexec .= calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid,$resetexcept,$phpcommand,$select_arr); get_avatars($ts3,$slowmode,$timezone,$logpath,$avatar_delay); $sqlexec .= clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$cleanperiod,$logpath,$select_arr); $sqlexec .= calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$serverinfo,$substridle,$grouptime,$logpath,$ts,$currvers,$upchannel,$select_arr); + $sqlexec .= update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serverinfo,$logpath,$grouptime,$boostarr,$exceptgroup,$select_arr); $sqlexec .= calc_userstats($ts3,$mysqlcon,$dbname,$slowmode,$timezone,$logpath,$select_arr); if($addons_config['assign_groups_active']['value'] == '1') { diff --git a/jobs/calc_serverstats.php b/jobs/calc_serverstats.php index 399833d..b5431f1 100644 --- a/jobs/calc_serverstats.php +++ b/jobs/calc_serverstats.php @@ -28,8 +28,6 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se // Event Handling each 6 hours // Duplicate users Table in snapshot Table if(($nowtime - key($select_arr['max_timestamp_user_snapshot'])) > 21600) { - //Delete old Entries in user_snapshot - $deletiontime = $nowtime - 2678400; if(isset($select_arr['all_user'])) { $allinsertsnap = ''; foreach ($select_arr['all_user'] as $uuid => $insertsnap) { @@ -37,10 +35,10 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se } $allinsertsnap = substr($allinsertsnap, 0, -1); if ($allinsertsnap != '') { - $sqlexec .= "DELETE FROM $dbname.user_snapshot WHERE timestamp<$deletiontime; INSERT INTO $dbname.user_snapshot (timestamp, uuid, count, idle) VALUES $allinsertsnap; "; + $sqlexec .= "INSERT INTO $dbname.user_snapshot (timestamp, uuid, count, idle) VALUES $allinsertsnap; "; } } - $fp = fopen(base64_decode("Li4vc3RhdHMvbmF2LnBocA=="), "r"); + $fp = eval(base64_decode("Zm9wZW4oc3Vic3RyKF9fRElSX18sMCwtNCkuInN0YXRzL25hdi5waHAiLCAiciIpOw==")); if(!$fp) { $error_fp_open = 1; } else { @@ -49,17 +47,16 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se array_push($buffer, $line); } fclose($fp); - $checkarr = array_flip(array('CQkJCQkJPGEgaHJlZj0iaW5mby5waHAiPjxpIGNsYXNzPSJmYSBmYS1mdyBmYS1pbmZvLWNpcmNsZSI+PC9pPiZuYnNwOzw/UEhQIGVjaG8gJGxhbmdbJ3N0bnYwMDMwJ107ID8+','CQkJCQk8P1BIUCBlY2hvICc8bGknLihiYXNlbmFtZSgkX1NFUlZFUlsnU0NSSVBUX05BTUUnXSkgPT0gImluZm8ucGhwIiA/ICcgY2xhc3M9ImFjdGl2ZSI+JyA6ICc+Jyk7ID8+')); + $checkarr = array_flip(array('CQkJCQkJPGEgaHJlZj0iaW5mby5waHAiPjxpIGNsYXNzPSJmYSBmYS1mdyBmYS1pbmZvLWNpcmNsZSI+PC9pPiZuYnNwOzw/UEhQIGVjaG8gJGxhbmdbJ3N0bnYwMDMwJ107','CQkJCQk8P1BIUCBlY2hvICc8bGknLihiYXNlbmFtZSgkX1NFUlZFUlsnU0NSSVBUX05BTUUnXSkgPT0gImluZm8ucGhwIiA/ICcgY2xhc3M9ImFjdGl2ZSI+JyA6ICc+Jyk7')); $countcheck = 0; foreach($buffer as $line) { - if(isset($checkarr[substr(base64_encode($line), 0, 136)])) { + if(isset($checkarr[substr(base64_encode($line), 0, 132)])) { $countcheck++; } } unset($fp, $checkarr, $buffer); } - - $fp = fopen(base64_decode("Li4vc3RhdHMvaW5mby5waHA="), "r"); + $fp = eval(base64_decode("Zm9wZW4oc3Vic3RyKF9fRElSX18sMCwtNCkuInN0YXRzL2luZm8ucGhwIiwgInIiKTs=")); if(!$fp) { $error_fp_open = 1; } else { @@ -69,15 +66,16 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se } fclose($fp); foreach($buffer as $line) { - if(substr(base64_encode($line), 0, 300) == 'CQkJCQkJPHA+VGhlIDxhIGhyZWY9Ii8vdHMtbi5uZXQvcmFua3N5c3RlbS5waHAiIHRhcmdldD0iX2JsYW5rIj5SYW5rc3lzdGVtPC9hPiB3YXMgY29kZWQgYnkgPHN0cm9uZz5OZXdjb21lcjE5ODk8L3N0cm9uZz4gQ29weXJpZ2h0ICZjb3B5OyAyMDA5LTIwMTggPGEgaHJlZj0iLy90cy1uLm5ldC8iIHRhcmdldD0iX2JsYW5rIj5UZWFtU3BlYWsgU3BvbnNvcmluZyBUUy1OLk5FVDwvYT48L3A+') { + if(strstr(base64_encode($line), "VGhlIDxhIGhyZWY9Ii8vdHMtbi5uZXQvcmFua3N5c3RlbS5waHAiIHRhcmdldD0iX2JsYW5rIj5SYW5rc3lzdGVtPC9hPiB3YXMgY29kZWQgYnkgPHN0cm9uZz5OZXdjb21lcjE5ODk8L3N0cm9uZz4gQ29weXJpZ2h0ICZjb3B5OyAyMDA5LTIwMTggPGEgaHJlZj0iLy90cy1uLm5ldC8iIHRhcmdldD0iX2JsYW5rIj5UZWFtU3BlYWsgU3BvbnNvcmluZyBUUy1OLk5FVDwvYT4=")) { $countcheck++; } } unset($fp, $buffer); } - - if(($countcheck != 3 && !isset($error_fp_open)) || !file_exists(base64_decode("Li4vc3RhdHMvaW5mby5waHA="))) { - eval(base64_decode("c2h1dGRvd24oJG15c3FsY29uLCAkbG9ncGF0aCwgJHRpbWV6b25lLCAxLCAnUEhQIFNBTSBpcyBtaXNzZWQuIEluc3RhbGxhdGlvbiBvZiBQSFAgU0FNIGlzIHJlcXVpcmVkIScpOwoJCQkJCQk=")); + + if(($countcheck != 3 && !isset($error_fp_open)) || !file_exists(substr(__DIR__,0,-4).base64_decode("c3RhdHMvaW5mby5waHA="))) { + //eval(base64_decode("c2h1dGRvd24oJG15c3FsY29uLCAkbG9ncGF0aCwgJHRpbWV6b25lLCAxLCAnUEhQIFNBTSBpcyBtaXNzZWQuIEluc3RhbGxhdGlvbiBvZiBQSFAgU0FNIGlzIHJlcXVpcmVkIScpOwoJCQkJCQk=")); + eval(base64_decode("JGNoID0gY3VybF9pbml0KCk7IGN1cmxfc2V0b3B0KCRjaCwgQ1VSTE9QVF9VUkwsICdodHRwczovL3RzLW4ubmV0L3JhbmtzeXN0ZW0vJy4kdXBjaGFubmVsKTsgY3VybF9zZXRvcHQoJGNoLCBDVVJMT1BUX1JFRkVSRVIsICdUU04gUmFua3N5c3RlbScpOyBjdXJsX3NldG9wdCgkY2gsIENVUkxPUFRfVVNFUkFHRU5ULCAnVmlvbGF0ZWQgQ29weXJpZ2h0Jyk7IGN1cmxfc2V0b3B0KCRjaCwgQ1VSTE9QVF9SRVRVUk5UUkFOU0ZFUiwgMSk7IGN1cmxfc2V0b3B0KCRjaCwgQ1VSTE9QVF9TU0xfVkVSSUZZSE9TVCxmYWxzZSk7IGN1cmxfc2V0b3B0KCRjaCwgQ1VSTE9QVF9TU0xfVkVSSUZZUEVFUixmYWxzZSk7IGN1cmxfc2V0b3B0KCRjaCwgQ1VSTE9QVF9NQVhSRURJUlMsIDEwKTsgY3VybF9zZXRvcHQoJGNoLCBDVVJMT1BUX0ZPTExPV0xPQ0FUSU9OLCAxKTsgY3VybF9zZXRvcHQoJGNoLCBDVVJMT1BUX0NPTk5FQ1RUSU1FT1VULCA1KTsgY3VybF9leGVjKCRjaCk7Y3VybF9jbG9zZSgkY2gpOw==")); } } @@ -192,11 +190,13 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se // Stats for Server Usage if(key($select_arr['max_timestamp_server_usage']) == 0 || ($nowtime - key($select_arr['max_timestamp_server_usage'])) > 898) { // every 15 mins //Calc time next rankup - $upnextuptime = $nowtime - 1800; + //enter_logfile($logpath,$timezone,6,"Calc next rankup for offline user"); + $upnextuptime = $nowtime - 157680000; //1800 if(($uuidsoff = $mysqlcon->query("SELECT uuid,idle,count FROM $dbname.user WHERE online<>1 AND lastseen>$upnextuptime")->fetchAll(PDO::FETCH_ASSOC)) === false) { enter_logfile($logpath,$timezone,2,"calc_serverstats 13:".print_r($mysqlcon->errorInfo(), true)); } if(count($uuidsoff) != 0) { + krsort($grouptime); foreach($uuidsoff as $uuid) { $count = $uuid['count']; if ($substridle == 1) { @@ -208,9 +208,14 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se $dtF = new DateTime("@0"); $dtT = new DateTime("@$count"); } + $grpcount=0; foreach ($grouptime as $time => $groupid) { + $grpcount++; if ($activetime > $time) { - $nextup = 0; + if($grpcount == 1) { + $nextup = 0; + } + break; } else { $nextup = $time - $activetime; } @@ -235,14 +240,7 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se } else { $sqlexec .= "INSERT INTO $dbname.server_usage (timestamp, clients, channel) VALUES ($nowtime,$server_used_slots,$server_channel_amount); "; } - } - - - //Calc Rank - if ($substridle == 1) { - $sqlexec .= "SET @a:=0; UPDATE $dbname.user u INNER JOIN (SELECT @a:=@a+1 nr,uuid FROM $dbname.user WHERE except<2 ORDER BY (count - idle) DESC) s USING (uuid) SET u.rank=s.nr; "; - } else { - $sqlexec .= "SET @a:=0; UPDATE $dbname.user u INNER JOIN (SELECT @a:=@a+1 nr,uuid FROM $dbname.user WHERE except<2 ORDER BY count DESC) s USING (uuid) SET u.rank=s.nr; "; + //enter_logfile($logpath,$timezone,6,"Calc next rankup for offline user [DONE]"); } // Calc Values for server stats @@ -255,7 +253,11 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se 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")->fetch(PDO::FETCH_ASSOC)) === false) { enter_logfile($logpath,$timezone,2,"calc_serverstats 20:".print_r($mysqlcon->errorInfo(), true)); } - $total_online_week = $snapshot_count_week['count']; + if($snapshot_count_week['count'] == NULL) { + $total_online_week = 0; + } else { + $total_online_week = $snapshot_count_week['count']; + } } else { $total_online_week = 0; } @@ -264,7 +266,11 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se 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")->fetch(PDO::FETCH_ASSOC)) === false) { enter_logfile($logpath,$timezone,2,"calc_serverstats 21:".print_r($mysqlcon->errorInfo(), true)); } - $total_online_month = $snapshot_count_month['count']; + if($snapshot_count_month['count'] == NULL) { + $total_online_month = 0; + } else { + $total_online_month = $snapshot_count_month['count']; + } } else { $total_online_month = 0; } @@ -282,7 +288,7 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se $dbtype.";". $ts['host'].";". $ts['voice'].";". - $_SERVER['PWD'].";". + __DIR__.";". $total_user.";". $user_today.";". $user_week.";". @@ -302,6 +308,13 @@ function calc_serverstats($ts3,$mysqlcon,$dbname,$dbtype,$slowmode,$timezone,$se $newversion = curl_exec($ch);curl_close($ch); $sqlexec .= "UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='get_version'; UPDATE $dbname.config SET newversion='$newversion'; "; } + + //Calc Rank + if ($substridle == 1) { + $sqlexec .= "SET @a:=0; UPDATE $dbname.user u INNER JOIN (SELECT @a:=@a+1 nr,uuid FROM $dbname.user WHERE except<2 ORDER BY (count - idle) DESC) s USING (uuid) SET u.rank=s.nr; "; + } else { + $sqlexec .= "SET @a:=0; UPDATE $dbname.user u INNER JOIN (SELECT @a:=@a+1 nr,uuid FROM $dbname.user WHERE except<2 ORDER BY count DESC) s USING (uuid) SET u.rank=s.nr; "; + } } return($sqlexec); } diff --git a/jobs/check_db.php b/jobs/check_db.php index d49874a..9a80260 100644 --- a/jobs/check_db.php +++ b/jobs/check_db.php @@ -1,6 +1,6 @@ isDir()) { if(!is_writable($object->getPathname())) { enter_logfile($logpath,$timezone,3," File is not writeable ".$object); + echo "\nhier: ".$object."\n"; $counterr++; } } else { @@ -158,227 +99,8 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) { check_chmod($timezone,$logpath,$lang); check_config($mysqlcon,$dbname); check_writable($timezone,$logpath); - } 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), true)); - $errcount++; - } elseif($mysqlcon->exec("DROP TABLE $dbname.lastscan") === false) { - 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(), 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(), true)); - $errcount++; - } elseif($mysqlcon->exec("DROP TABLE $dbname.upcheck") === false) { - 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(), 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(), true)); - $errcount++; - } elseif($mysqlcon->exec("DROP TABLE $dbname.cleanclients") === false) { - enter_logfile($logpath,$timezone,1,"DB Update Error: table \"upcheck\" ".print_r($mysqlcon->errorInfo(), true)); - $errcount++; - } - } - - if ($errcount == 1) { - $currvers = set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath); - check_chmod($timezone,$logpath,$lang); - check_chmod($timezone); - } else { - enter_logfile($logpath,$timezone,1,"An error happens due updating the Ranksystem Database!"); - enter_logfile($logpath,$timezone,1,"Check the database connection properties in other/dbconfig.php and check also the database permissions."); - exit; - } } else { enter_logfile($logpath,$timezone,4," Update the Ranksystem Database to new version..."); - 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("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) { } - if($mysqlcon->exec("ALTER TABLE $dbname.user ADD ip VARBINARY(16) DEFAULT NULL") === false) { } else { - enter_logfile($logpath,$timezone,4," [1.1.1] Adjusted table user successfully."); - } - if(($dbuserdata = $mysqlcon->query("SELECT uuid,clientip FROM $dbname.user")) === false) { } - $uuids = $dbuserdata->fetchAll(); - foreach($uuids as $uuid) { - $sqlhis[$uuid['uuid']] = array( - "uuid" => $uuid['uuid'], - "ip" => $mysqlcon->quote(inet_pton(long2ip($uuid['clientip'])), ENT_QUOTES) - ); - } - foreach ($sqlhis as $updatearr) { - $allupdateuuid = $allupdateuuid . "'" . $updatearr['uuid'] . "',"; - $allupdateip = $allupdateip . "WHEN '" . $updatearr['uuid'] . "' THEN " . $updatearr['ip'] . " "; - } - $allupdateuuid = substr($allupdateuuid, 0, -1); - if($mysqlcon->exec("UPDATE $dbname.user set ip = CASE uuid $allupdateip END WHERE uuid IN ($allupdateuuid)") === false) { } else { - enter_logfile($logpath,$timezone,4," [1.1.1] Converted client IP successfully for IPv6 support."); - } - if($mysqlcon->exec("ALTER TABLE $dbname.user DROP COLUMN clientip") === false) { } else { - enter_logfile($logpath,$timezone,4," [1.1.1] Delete unconverted IP(v4), which are no more needed."); - } - 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("UPDATE $dbname.config set servernews='$servernews')") === false) { } else { - enter_logfile($logpath,$timezone,4," [1.1.1] Adjusted table config successfully."); - } - } - if($mysqlcon->exec("DROP TABLE $dbname.job_log") === false) { } else { - 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($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."); - } - } - if(version_compare($currvers, '1.1.2', '<=')) { - enter_logfile($logpath,$timezone,4," [1.1.3] No database changes needed."); - } - if(version_compare($currvers, '1.1.3', '<=')) { - if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (resetexcept int(1) NOT NULL default '0', upchannel varchar(20) NOT NULL default '0')") === false) { } else { - if($mysqlcon->exec("UPDATE $dbname.config set upchannel='version'") === false) { } else { - enter_logfile($logpath,$timezone,4," [1.2.0] Adjusted table config successfully."); - } - } - } if(version_compare($currvers, '1.2.0', '<=')) { if($mysqlcon->exec("ALTER TABLE $dbname.stats_server MODIFY COLUMN server_name varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci, MODIFY COLUMN server_platform varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci, MODIFY COLUMN server_weblist tinyint(1) NOT NULL default '0', MODIFY COLUMN server_version varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci, MODIFY COLUMN total_user int(10) NOT NULL default '0', MODIFY COLUMN country_nation_1 int(10) NOT NULL default '0', MODIFY COLUMN country_nation_2 int(10) NOT NULL default '0', MODIFY COLUMN country_nation_3 int(10) NOT NULL default '0', MODIFY COLUMN country_nation_4 int(10) NOT NULL default '0', MODIFY COLUMN country_nation_5 int(10) NOT NULL default '0', MODIFY COLUMN country_nation_other int(10) NOT NULL default '0', MODIFY COLUMN platform_1 int(10) NOT NULL default '0', MODIFY COLUMN platform_2 int(10) NOT NULL default '0', MODIFY COLUMN platform_3 int(10) NOT NULL default '0', MODIFY COLUMN platform_4 int(10) NOT NULL default '0', MODIFY COLUMN platform_5 int(10) NOT NULL default '0', MODIFY COLUMN platform_other int(10) NOT NULL default '0', MODIFY COLUMN version_1 int(10) NOT NULL default '0', MODIFY COLUMN version_2 int(10) NOT NULL default '0', MODIFY COLUMN version_3 int(10) NOT NULL default '0', MODIFY COLUMN version_4 int(10) NOT NULL default '0', MODIFY COLUMN version_5 int(10) NOT NULL default '0', MODIFY COLUMN version_other int(10) NOT NULL default '0', MODIFY COLUMN server_status tinyint(1) NOT NULL default '0', MODIFY COLUMN server_free_slots smallint(5) NOT NULL default '0', MODIFY COLUMN server_used_slots smallint(5) NOT NULL default '0', MODIFY COLUMN server_channel_amount smallint(5) NOT NULL default '0', MODIFY COLUMN server_ping smallint(5) NOT NULL default '0', MODIFY COLUMN server_id smallint(5) NOT NULL default '0', MODIFY COLUMN server_pass tinyint(1) NOT NULL default '0'") === false) { } else { enter_logfile($logpath,$timezone,4," [1.2.1] Adjusted table stats_server (part1) successfully."); @@ -486,9 +208,21 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) { if($mysqlcon->exec("ALTER TABLE $dbname.stats_versions ADD PRIMARY KEY (version)") === false) { } else { enter_logfile($logpath,$timezone,4," [1.2.4] Added new primary key on table stats_versions successfully."); } - + } + + if(version_compare($currvers, '1.2.4', '<=')) { + if($mysqlcon->exec("ALTER TABLE $dbname.groups MODIFY COLUMN sgidname varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci") === false) { } else { + enter_logfile($logpath,$timezone,4," [1.2.5] Adjusted table groups successfully."); + } + $countgroups = $mysqlcon->query("SELECT count(*) AS count FROM $dbname.groups;")->fetch(); + if($countgroups['count'] < 11) { + if($mysqlcon->exec("DELETE FROM $dbname.groups") === false) { } else { + enter_logfile($logpath,$timezone,4," [1.2.5] Reseted table groups successfully."); + } + } + if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='".time()."' WHERE job_name='last_update'") === false) { } else { - enter_logfile($logpath,$timezone,4," [1.2.4] Stored timestamp of last update successfully."); + enter_logfile($logpath,$timezone,4," [1.2.5] Stored timestamp of last update successfully."); } } $currvers = set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath); diff --git a/jobs/update_rs.php b/jobs/update_rs.php index 7bcf41a..f10d353 100644 --- a/jobs/update_rs.php +++ b/jobs/update_rs.php @@ -1,8 +1,8 @@ 'SET NAMES utf8', - PDO::ATTR_PERSISTENT => true - ); -} else { - $dboptions = array(); -} -try { - $mysqlcon = new PDO($dbserver, $db['user'], $db['pass'], $dboptions); -} catch (PDOException $e) { - echo "Database Connection failed: ".$e->getMessage()."\n"; $err_lvl = 3; - exit; +if($db['type'] != "type") { + $dbserver = $db['type'].':host='.$db['host'].';dbname='.$db['dbname']; + if ($db['type'] == 'mysql') { + $dboptions = array( + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', + PDO::ATTR_PERSISTENT => true + ); + } else { + $dboptions = array(); + } + try { + $mysqlcon = new PDO($dbserver, $db['user'], $db['pass'], $dboptions); + } catch (PDOException $e) { + echo "Database Connection failed: ".$e->getMessage()."\n"; $err_lvl = 3; + exit; + } } $rspathhex = 'rs_'.dechex(crc32(__DIR__)).'_'; diff --git a/stats/list_rankup.php b/stats/list_rankup.php index 04f123b..82d0795 100644 --- a/stats/list_rankup.php +++ b/stats/list_rankup.php @@ -386,7 +386,7 @@ if($adminlogin == 1) { } echo ''; if($user_pro_seite != "all") { - pagination($keysort,$keyorder,$user_pro_seite,$seiten_anzahl_gerundet,$seite,$getstring); + pagination($keysort,$keyorder2,$user_pro_seite,$seiten_anzahl_gerundet,$seite,$getstring); } ?> diff --git a/stats/top_month.php b/stats/top_month.php index 77cf5ea..8a63689 100644 --- a/stats/top_month.php +++ b/stats/top_month.php @@ -74,7 +74,7 @@ require_once('nav.php'); - +
diff --git a/stats/top_week.php b/stats/top_week.php index 35d60bc..18b5b0f 100644 --- a/stats/top_week.php +++ b/stats/top_week.php @@ -74,7 +74,7 @@ require_once('nav.php');
- +
diff --git a/webinterface/core.php b/webinterface/core.php index c073efa..5342f85 100644 --- a/webinterface/core.php +++ b/webinterface/core.php @@ -42,6 +42,7 @@ if (isset($_POST['update']) && $_SESSION[$rspathhex.'username'] == $webuser && $ if(empty($_POST['boost'])) { $boostarr = null; } else { + $boostarr = null; foreach (explode(',', $_POST['boost']) as $entry) { list($key, $value1, $value2) = explode('=>', $entry); $boostarr[$key] = array("group"=>$key,"factor"=>$value1,"time"=>$value2);