release 1.2.5
This commit is contained in:
73
jobs/bot.php
73
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') {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
$newversion = '1.2.4';
|
||||
$newversion = '1.2.5';
|
||||
enter_logfile($logpath,$timezone,5,"Check Ranksystem database for updates.");
|
||||
|
||||
function set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath) {
|
||||
@@ -47,66 +47,6 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: install.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'list_rankup.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'list_rankup.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: list_rankup.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'lang.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'lang.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: lang.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'license.txt')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'license.txt')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: license.txt");
|
||||
}
|
||||
}
|
||||
if(is_dir(substr(__DIR__,0,-4).'jquerylib/')) {
|
||||
if(!rmdir(substr(__DIR__,0,-4).'jquerylib/')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary folder, please delete it from your webserver: jquerylib/");
|
||||
}
|
||||
}
|
||||
if(is_dir(substr(__DIR__,0,-4).'ts3_lib/')) {
|
||||
if(!rmdir(substr(__DIR__,0,-4).'ts3_lib/')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary folder, please delete it from your webserver: ts3_lib/");
|
||||
}
|
||||
}
|
||||
if(is_dir(substr(__DIR__,0,-4).'bootstrap/')) {
|
||||
if(!rmdir(substr(__DIR__,0,-4).'bootstrap/')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary folder, please delete it from your webserver: bootstrap/");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'other/webinterface_list.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'other/webinterface_list.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: other/webinterface_list.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'other/webinterface_login.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'other/webinterface_login.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: other/webinterface_login.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'webinterface.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'webinterface.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: webinterface.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'other/style.css.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'other/style.css.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: other/style.css.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'other/search.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'other/search.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: other/search.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'server-news')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'server-news')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: server-news");
|
||||
}
|
||||
}
|
||||
if(is_dir(substr(__DIR__,0,-4).'icons/')) {
|
||||
if(!rmdir(substr(__DIR__,0,-4).'icons/')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary folder, please delete it from your webserver: icons/");
|
||||
@@ -134,6 +74,7 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
if (!$object->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);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?PHP
|
||||
function update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$phpcommand,$norotate=NULL) {
|
||||
$norotate = true;
|
||||
enter_logfile($logpath,$timezone,4," Start updating the Ranksystem...\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Backup the database due cloning tables...\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Start updating the Ranksystem...",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Backup the database due cloning tables...",$norotate);
|
||||
$countbackuperr = 0;
|
||||
|
||||
$tables = array('addons_config','addon_assign_groups','config','groups','job_check','server_usage','stats_nations','stats_platforms','stats_server','stats_user','stats_versions','user','user_snapshot');
|
||||
@@ -33,34 +33,34 @@ function update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$phpco
|
||||
}
|
||||
|
||||
if($countbackuperr != 0) {
|
||||
enter_logfile($logpath,$timezone,4," Backup failed. Please check your database permissions.\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Update failed. Go on with normal work on old version.\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Backup failed. Please check your database permissions.",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Update failed. Go on with normal work on old version.",$norotate);
|
||||
return;
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,4," Database-tables successfully backuped.\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Database-tables successfully backuped.",$norotate);
|
||||
}
|
||||
|
||||
if(!is_file(substr(__DIR__,0,-4).'update/'.$newversion.'.zip')) {
|
||||
enter_logfile($logpath,$timezone,4," Downloading new update...\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Downloading new update...",$norotate);
|
||||
$newUpdate = file_get_contents('https://ts-n.net/downloads/ranksystem_'.$newversion.'.zip');
|
||||
if(!is_dir(substr(__DIR__,0,-4).'update/')) {
|
||||
mkdir (substr(__DIR__,0,-4).'update/');
|
||||
}
|
||||
$dlHandler = fopen(substr(__DIR__,0,-4).'update/ranksystem_'.$newversion.'.zip', 'w');
|
||||
if(!fwrite($dlHandler,$newUpdate)) {
|
||||
enter_logfile($logpath,$timezone,1," Could not save new update. Please check the permissions for folder 'update'.\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Update failed. Go on with normal work on old version.\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,1," Could not save new update. Please check the permissions for folder 'update'.",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Update failed. Go on with normal work on old version.",$norotate);
|
||||
return;
|
||||
}
|
||||
if(!is_file(substr(__DIR__,0,-4).'update/ranksystem_'.$newversion.'.zip')) {
|
||||
enter_logfile($logpath,$timezone,4," Something gone wrong with downloading/saving the new update file.\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Update failed. Go on with normal work on old version.\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Something gone wrong with downloading/saving the new update file.",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Update failed. Go on with normal work on old version.",$norotate);
|
||||
return;
|
||||
}
|
||||
fclose($dlHandler);
|
||||
enter_logfile($logpath,$timezone,4," New update successfully saved.\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," New update successfully saved.",$norotate);
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,5," New update file already here...\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,5," New update file already here...",$norotate);
|
||||
}
|
||||
|
||||
$zipHandle = zip_open(substr(__DIR__,0,-4).'update/ranksystem_'.$newversion.'.zip');
|
||||
@@ -78,9 +78,9 @@ function update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$phpco
|
||||
|
||||
if(!is_dir(substr(__DIR__,0,-4).'/'.$thisFileDir)) {
|
||||
if(mkdir(substr(__DIR__,0,-4).$thisFileDir, 0777, true)) {
|
||||
enter_logfile($logpath,$timezone,4," Create new folder ".$thisFileDir."\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Create new folder ".$thisFileDir,$norotate);
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,1," Error by creating folder ".$thisFileDir.". Please check the permissions on your folder ".substr(__DIR__,0,-4).".\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,1," Error by creating folder ".$thisFileDir.". Please check the permissions on your folder ".substr(__DIR__,0,-4),$norotate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,16 +88,16 @@ function update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$phpco
|
||||
$contents = zip_entry_read($aF, zip_entry_filesize($aF));
|
||||
$updateThis = '';
|
||||
if($thisFileName == 'other/dbconfig.php' || $thisFileName == 'install.php' || $thisFileName == 'other/phpcommand.php') {
|
||||
enter_logfile($logpath,$timezone,5," Did not touch ".$thisFileName."\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,5," Did not touch ".$thisFileName,$norotate);
|
||||
} else {
|
||||
if(($updateThis = fopen(substr(__DIR__,0,-4).'/'.$thisFileName, 'w')) === false) {
|
||||
enter_logfile($logpath,$timezone,1," Failed to open file ".$thisFileName."\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,1," Failed to open file ".$thisFileName,$norotate);
|
||||
$countwrongfiles++;
|
||||
} elseif(!fwrite($updateThis, $contents)) {
|
||||
enter_logfile($logpath,$timezone,1," Failed to write file ".$thisFileName."\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,1," Failed to write file ".$thisFileName,$norotate);
|
||||
$countwrongfiles++;
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,4," Replaced file ".$thisFileName."\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,4," Replaced file ".$thisFileName,$norotate);
|
||||
$countchangedfiles++;
|
||||
}
|
||||
fclose($updateThis);
|
||||
@@ -123,7 +123,7 @@ function update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$phpco
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,1," Files updated with at least one error. Please check the log!\n",$norotate);
|
||||
enter_logfile($logpath,$timezone,1," Files updated with at least one error. Please check the log!",$norotate);
|
||||
// how to handle this.. Perhaps try again automatically in 30 minutes
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user