release 1.2.2
This commit is contained in:
48
jobs/addon_assign_groups.php
Normal file
48
jobs/addon_assign_groups.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?PHP
|
||||
function addon_assign_groups($addons_config,$ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath,$allclients) {
|
||||
|
||||
if(($lastupdate = $mysqlcon->query("SELECT * FROM $dbname.job_check WHERE job_name='check_update'")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 0:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
if(($dbdata = $mysqlcon->query("SELECT * FROM $dbname.addon_assign_groups")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"addon_assign_groups: Error while getting data out of db: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$dbdata_fetched = $dbdata->fetchAll();
|
||||
|
||||
foreach($dbdata_fetched as $entry) {
|
||||
$cld_groups = explode(',', $entry['grpids']);
|
||||
foreach($cld_groups as $group) {
|
||||
foreach ($allclients as $client) {
|
||||
if($client['client_unique_identifier'] == $entry['uuid']) {
|
||||
$cldbid = $client['client_database_id'];
|
||||
$nickname = htmlspecialchars($client['client_nickname'], ENT_QUOTES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isset($cldbid)) {
|
||||
if(strstr($group, '-')) {
|
||||
$group = str_replace('-','',$group);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($group, $cldbid);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"addon_assign_groups:".$e->getCode().': '."Error while removing group: ".$e->getMessage());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$ts3->serverGroupClientAdd($group, $cldbid);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"addon_assign_groups:".$e->getCode().': '."Error while adding group: ".$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("DELETE FROM $dbname.addon_assign_groups") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"addon_assign_groups: Error while deleting data out of db: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
?>
|
||||
29
jobs/bot.php
29
jobs/bot.php
@@ -93,6 +93,18 @@ function get_data($url,$currvers,$ts) {
|
||||
$currvers = check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath);
|
||||
enter_logfile($logpath,$timezone,5," Ranksystem Version: ".$currvers);
|
||||
|
||||
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);
|
||||
if($addons_config['assign_groups_active']['value'] == '1') {
|
||||
enter_logfile($logpath,$timezone,5," Addon: 'assign_groups' [ON]");
|
||||
include(substr(__DIR__,0,-4).'jobs/addon_assign_groups.php');
|
||||
define('assign_groups',1);
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,5," Addon: 'assign_groups' [OFF]");
|
||||
}
|
||||
enter_logfile($logpath,$timezone,5,"Loading addons [done]");
|
||||
|
||||
enter_logfile($logpath,$timezone,5,"Connect to TS3 Server (Address: \"".$ts['host']."\" Voice-Port: \"".$ts['voice']."\" Query-Port: \"".$ts['query']."\").");
|
||||
try {
|
||||
$ts3 = TeamSpeak3::factory("serverquery://".$ts['user'].":".$ts['pass']."@".$ts['host'].":".$ts['query']."/?server_port=".$ts['voice']."&blocking=0");
|
||||
@@ -139,7 +151,7 @@ try {
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,4," No channel defined where the Ranksystem Bot should be entered.");
|
||||
}
|
||||
|
||||
|
||||
enter_logfile($logpath,$timezone,5,"Bot starts now his work!");
|
||||
$looptime = 1;
|
||||
usleep(5000000);
|
||||
@@ -151,14 +163,15 @@ try {
|
||||
}
|
||||
$starttime = microtime(true);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$addons_config = load_addons_config($mysqlcon,$lang,$dbname,$timezone,$logpath);
|
||||
$ts3->clientListReset();
|
||||
$allclients = $ts3->clientList();
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$ts3->serverInfoReset();
|
||||
$serverinfo = $ts3->serverInfo();
|
||||
calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid,$ts,$resetexcept,$upchannel);
|
||||
calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid,$ts,$resetexcept,$upchannel,$phpcommand);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath);
|
||||
get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath,$avatar_delay);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serverinfo,$logpath);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
@@ -167,6 +180,16 @@ try {
|
||||
calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$cleanperiod,$logpath);
|
||||
if($addons_config['assign_groups_active']['value'] == '1') {
|
||||
if(!defined('assign_groups')) {
|
||||
enter_logfile($logpath,$timezone,5,"Loading new addon...");
|
||||
enter_logfile($logpath,$timezone,5," Addon: 'assign_groups' [ON]");
|
||||
include(substr(__DIR__,0,-4).'jobs/addon_assign_groups.php');
|
||||
define('assign_groups',1);
|
||||
enter_logfile($logpath,$timezone,5,"Loading new addon [done]");
|
||||
}
|
||||
addon_assign_groups($addons_config,$ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath,$allclients);
|
||||
}
|
||||
$looptime = microtime(true) - $starttime;
|
||||
try { $ts3->getAdapter(); } catch (Exception $e) {}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?PHP
|
||||
function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid,$ts,$resetexcept,$upchannel) {
|
||||
function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid,$ts,$resetexcept,$upchannel,$phpcommand) {
|
||||
$nowtime = time();
|
||||
|
||||
if(($getversion = $mysqlcon->query("SELECT * FROM $dbname.job_check WHERE job_name='get_version'")) === false) {
|
||||
@@ -29,7 +29,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
}
|
||||
$getversion = $getversion->fetch(PDO::FETCH_ASSOC);
|
||||
$newversion = $getversion['newversion'];
|
||||
if(version_compare($newversion, $currvers, '>') && $newversion != '') {
|
||||
if(version_compare($newversion, $currvers, '>') && $newversion != NULL) {
|
||||
if ($update == 1) {
|
||||
enter_logfile($logpath,$timezone,4,$lang['upinf']);
|
||||
foreach ($uniqueid as $clientid) {
|
||||
@@ -46,7 +46,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
}
|
||||
}
|
||||
}
|
||||
update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion);
|
||||
update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$phpcommand);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,8 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
enter_logfile($logpath,$timezone,4,"Negative time between now and last scan (Error in your server time!).. reset time difference to zero.");
|
||||
$lastscan = $nowtime;
|
||||
}
|
||||
if ($dbdata->rowCount() != 0) {
|
||||
$uidarr = array();
|
||||
if ($dbdata->rowCount() != NULL) {
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='calc_user_lastscan'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 5:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
@@ -90,8 +91,9 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
unset($uuids);
|
||||
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$yetonline[] = '';
|
||||
$insertdata = '';
|
||||
$yetonline = array();
|
||||
$insertdata = array();
|
||||
$updatedata = array();
|
||||
if(empty($grouptime)) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 7:".$lang['wiconferr']);
|
||||
exit;
|
||||
@@ -128,10 +130,13 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
} elseif(array_intersect($sgroups, $exceptgroup)) {
|
||||
$except = 2;
|
||||
} else {
|
||||
if(($sqlhis[$uid]['except'] == 3 || $sqlhis[$uid]['except'] == 2) && $resetexcept == 2) {
|
||||
if(isset($sqlhis[$uid]['except']) && ($sqlhis[$uid]['except'] == 3 || $sqlhis[$uid]['except'] == 2) && $resetexcept == 2) {
|
||||
$sqlhis[$uid]['count'] = 0;
|
||||
$sqlhis[$uid]['idle'] = 0;
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['resettime'], $name, $uid, $cldbid));
|
||||
if($mysqlcon->exec("DELETE FROM $dbname.user_snapshot WHERE uuid='$uid'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 5:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
$except = 0;
|
||||
}
|
||||
@@ -204,7 +209,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
}
|
||||
} elseif ($activetime > $time && !in_array($uid, $exceptuuid) && !array_intersect($sgroups, $exceptgroup)) {
|
||||
if ($sqlhis[$uid]['grpid'] != $groupid) {
|
||||
if ($sqlhis[$uid]['grpid'] != 0 && in_array($sqlhis[$uid]['grpid'], $sgroups)) {
|
||||
if ($sqlhis[$uid]['grpid'] != NULL && in_array($sqlhis[$uid]['grpid'], $sgroups)) {
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($sqlhis[$uid]['grpid'], $cldbid);
|
||||
@@ -298,13 +303,13 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
if ($insertdata != '') {
|
||||
if ($insertdata != NULL) {
|
||||
$allinsertdata = '';
|
||||
foreach ($insertdata as $insertarr) {
|
||||
$allinsertdata = $allinsertdata . "(" . $insertarr['uuid'] . ", '" . $insertarr['cldbid'] . "', '1', " . $insertarr['ip'] . ", " . $insertarr['name'] . ", '" . $insertarr['lastseen'] . "', '" . $insertarr['grpid'] . "', '" . $insertarr['nextup'] . "', '" . $insertarr['cldgroup'] . "', '" . $insertarr['platform'] . "', '" . $insertarr['nation'] . "', '" . $insertarr['version'] . "', '" . $insertarr['firstcon'] . "', '" . $insertarr['except'] . "','1'),";
|
||||
}
|
||||
$allinsertdata = substr($allinsertdata, 0, -1);
|
||||
if ($allinsertdata != '') {
|
||||
if ($allinsertdata != NULL) {
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.user (uuid, cldbid, count, ip, name, lastseen, grpid, nextup, cldgroup, platform, nation, version, firstcon, except, online) VALUES $allinsertdata") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 14:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
@@ -313,7 +318,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
|
||||
|
||||
unset($insertdata);
|
||||
unset($allinsertdata);
|
||||
if ($updatedata != 0) {
|
||||
if ($updatedata != NULL) {
|
||||
$allupdateuuid = '';
|
||||
$allupdatecldbid = '';
|
||||
$allupdatecount = '';
|
||||
|
||||
@@ -71,6 +71,8 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpat
|
||||
$allupdatecountm = '';
|
||||
$allupdateidlew = '';
|
||||
$allupdateidlem = '';
|
||||
$allupdateactw = '';
|
||||
$allupdateactm = '';
|
||||
$allupdatetotac = '';
|
||||
$allupdatebase64 = '';
|
||||
$allupdatecldtup = '';
|
||||
@@ -86,16 +88,20 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpat
|
||||
if(isset($userdataweekend[$userstats['uuid']]) && isset($userdataweekbegin[$userstats['uuid']])) {
|
||||
$count_week = $userdataweekend[$userstats['uuid']][0]['count'] - $userdataweekbegin[$userstats['uuid']][0]['count'];
|
||||
$idle_week = $userdataweekend[$userstats['uuid']][0]['idle'] - $userdataweekbegin[$userstats['uuid']][0]['idle'];
|
||||
$active_week = $count_week - $idle_week;
|
||||
} else {
|
||||
$count_week = 0;
|
||||
$idle_week = 0;
|
||||
$active_week = 0;
|
||||
}
|
||||
if(isset($userdatamonthend[$userstats['uuid']]) && isset($userdatamonthbegin[$userstats['uuid']])) {
|
||||
$count_month = $userdatamonthend[$userstats['uuid']][0]['count'] - $userdatamonthbegin[$userstats['uuid']][0]['count'];
|
||||
$idle_month = $userdatamonthend[$userstats['uuid']][0]['idle'] - $userdatamonthbegin[$userstats['uuid']][0]['idle'];
|
||||
$active_month = $count_month - $idle_month;
|
||||
} else {
|
||||
$count_month = 0;
|
||||
$idle_month = 0;
|
||||
$active_month = 0;
|
||||
}
|
||||
$clientdesc = $mysqlcon->quote($clientinfo['client_description'], ENT_QUOTES);;
|
||||
if(isset($uidarrstats[$userstats['uuid']])) {
|
||||
@@ -105,13 +111,15 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpat
|
||||
$allupdatecountm = $allupdatecountm . "WHEN '" . $userstats['uuid'] . "' THEN '" . $count_month . "' ";
|
||||
$allupdateidlew = $allupdateidlew . "WHEN '" . $userstats['uuid'] . "' THEN '" . $idle_week . "' ";
|
||||
$allupdateidlem = $allupdateidlem . "WHEN '" . $userstats['uuid'] . "' THEN '" . $idle_month . "' ";
|
||||
$allupdateactw = $allupdateactw . "WHEN '" . $userstats['uuid'] . "' THEN '" . $active_week . "' ";
|
||||
$allupdateactm = $allupdateactm . "WHEN '" . $userstats['uuid'] . "' THEN '" . $active_month . "' ";
|
||||
$allupdatetotac = $allupdatetotac . "WHEN '" . $userstats['uuid'] . "' THEN '" . $clientinfo['client_totalconnections'] . "' ";
|
||||
$allupdatebase64 = $allupdatebase64 . "WHEN '" . $userstats['uuid'] . "' THEN '" . $clientinfo['client_base64HashClientUID'] . "' ";
|
||||
$allupdatecldtup = $allupdatecldtup . "WHEN '" . $userstats['uuid'] . "' THEN '" . $clientinfo['client_total_bytes_uploaded'] . "' ";
|
||||
$allupdatecldtdo = $allupdatecldtdo . "WHEN '" . $userstats['uuid'] . "' THEN '" . $clientinfo['client_total_bytes_downloaded'] . "' ";
|
||||
$allupdateclddes = $allupdateclddes . "WHEN '" . $userstats['uuid'] . "' THEN " . $clientdesc . " ";
|
||||
} else {
|
||||
$allinsertuserstats = $allinsertuserstats . "('" . $userstats['uuid'] . "', '" .$userstats['rank'] . "', '" . $count_week . "', '" . $count_month . "', '" . $idle_week . "', '" . $idle_month . "', '" . $clientinfo['client_totalconnections'] . "', '" . $clientinfo['client_base64HashClientUID'] . "', '" . $clientinfo['client_total_bytes_uploaded'] . "', '" . $clientinfo['client_total_bytes_downloaded'] . "', " . $clientdesc . "),";
|
||||
$allinsertuserstats = $allinsertuserstats . "('" . $userstats['uuid'] . "', '" .$userstats['rank'] . "', '" . $count_week . "', '" . $count_month . "', '" . $idle_week . "', '" . $idle_month . "', '" . $active_week . "', '" . $active_month . "', '" . $clientinfo['client_totalconnections'] . "', '" . $clientinfo['client_base64HashClientUID'] . "', '" . $clientinfo['client_total_bytes_uploaded'] . "', '" . $clientinfo['client_total_bytes_downloaded'] . "', " . $clientdesc . "),";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
//enter_logfile($logpath,$timezone,6,$e->getCode() . ': ' . $e->getMessage()."; Client (uuid: ".$userstats['cldbid']." cldbid: ".$userstats['cldbid'].") was missing in TS database, perhaps its already deleted".);
|
||||
@@ -124,14 +132,14 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpat
|
||||
|
||||
if ($allupdateuuid != '') {
|
||||
$allupdateuuid = substr($allupdateuuid, 0, -1);
|
||||
if ($mysqlcon->exec("UPDATE $dbname.stats_user set rank = CASE uuid $allupdaterank END, count_week = CASE uuid $allupdatecountw END, count_month = CASE uuid $allupdatecountm END, idle_week = CASE uuid $allupdateidlew END, idle_month = CASE uuid $allupdateidlem END, total_connections = CASE uuid $allupdatetotac END, base64hash = CASE uuid $allupdatebase64 END, client_total_up = CASE uuid $allupdatecldtup END, client_total_down = CASE uuid $allupdatecldtdo END, client_description = CASE uuid $allupdateclddes END WHERE uuid IN ($allupdateuuid)") === false) {
|
||||
if ($mysqlcon->exec("UPDATE $dbname.stats_user set rank = CASE uuid $allupdaterank END, count_week = CASE uuid $allupdatecountw END, count_month = CASE uuid $allupdatecountm END, idle_week = CASE uuid $allupdateidlew END, idle_month = CASE uuid $allupdateidlem END, active_week = CASE uuid $allupdateactw END, active_month = CASE uuid $allupdateactm END, total_connections = CASE uuid $allupdatetotac END, base64hash = CASE uuid $allupdatebase64 END, client_total_up = CASE uuid $allupdatecldtup END, client_total_down = CASE uuid $allupdatecldtdo END, client_description = CASE uuid $allupdateclddes END WHERE uuid IN ($allupdateuuid)") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 12:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
if($allinsertuserstats != '') {
|
||||
$allinsertuserstats = substr($allinsertuserstats, 0, -1);
|
||||
if ($mysqlcon->exec("INSERT INTO $dbname.stats_user (uuid,rank,count_week,count_month,idle_week,idle_month,total_connections,base64hash,client_total_up,client_total_down,client_description) VALUES $allinsertuserstats") === false) {
|
||||
if ($mysqlcon->exec("INSERT INTO $dbname.stats_user (uuid,rank,count_week,count_month,idle_week,idle_month,active_week,active_month,total_connections,base64hash,client_total_up,client_total_down,client_description) VALUES $allinsertuserstats") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_userstats 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
$newversion = '1.2.1';
|
||||
$newversion = '1.2.2';
|
||||
enter_logfile($logpath,$timezone,5,"Check Ranksystem database for updates.");
|
||||
|
||||
function set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath) {
|
||||
@@ -365,7 +365,7 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(version_compare($currvers, '1.2.1', '<=')) {
|
||||
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.");
|
||||
}
|
||||
@@ -391,13 +391,34 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.1] Adjusted table groups successfully.");
|
||||
}
|
||||
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) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.1] Create table stats_nations successfully.");
|
||||
enter_logfile($logpath,$timezone,4," [1.2.1] Created table stats_nations successfully.");
|
||||
}
|
||||
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) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.1] Create table stats_versions successfully.");
|
||||
enter_logfile($logpath,$timezone,4," [1.2.1] Created table stats_versions successfully.");
|
||||
}
|
||||
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) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.1] Create table stats_platforms successfully.");
|
||||
enter_logfile($logpath,$timezone,4," [1.2.1] Created table stats_platforms successfully.");
|
||||
}
|
||||
}
|
||||
if(version_compare($currvers, '1.2.1', '<=')) {
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.stats_user ADD (active_week int(10) NOT NULL default '0', active_month int(10) NOT NULL default '0')") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.2] Adjusted table stats_user successfully.");
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (avatar_delay smallint(5) UNSIGNED NOT NULL default '0')") === false) { } else {
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set avatar_delay='0'") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.2] Adjusted table config (part 1) successfully.");
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config MODIFY COLUMN tsquery smallint(5) UNSIGNED NOT NULL default '0'") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.2] Adjusted table config (part 2) successfully.");
|
||||
}
|
||||
if($mysqlcon->exec("CREATE TABLE $dbname.addons_config (param varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci UNIQUE, value varchar(5000) CHARACTER SET utf8 COLLATE utf8_unicode_ci)") === false) { } else {
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.addons_config (param,value) VALUES ('assign_groups_active','0'),('assign_groups_groupids',''),('assign_groups_limit','')") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.2] Created table addons_config successfully.");
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("CREATE TABLE $dbname.addon_assign_groups (uuid varchar(29) CHARACTER SET utf8 COLLATE utf8_unicode_ci, grpids varchar(1000) CHARACTER SET utf8 COLLATE utf8_unicode_ci)") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.2] Created table addon_assign_groups successfully.");
|
||||
}
|
||||
}
|
||||
$currvers = set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?PHP
|
||||
function get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath) {
|
||||
function get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath,$avatar_delay) {
|
||||
$count = 0;
|
||||
|
||||
try {
|
||||
@@ -21,7 +21,7 @@ function get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath)
|
||||
foreach($tsfilelist as $tsfile) {
|
||||
$fullfilename = '/'.$tsfile['name'];
|
||||
$uuidasbase16 = substr($tsfile['name'],7);
|
||||
if (!isset($fsfilelistarray[$uuidasbase16.'.png']) || $tsfile['datetime']>$fsfilelistarray[$uuidasbase16.'.png']) {
|
||||
if (!isset($fsfilelistarray[$uuidasbase16.'.png']) || ($tsfile['datetime'] - $avatar_delay) > $fsfilelistarray[$uuidasbase16.'.png']) {
|
||||
if (substr($tsfile['name'],0,7) == 'avatar_') {
|
||||
try {
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
|
||||
@@ -44,7 +44,7 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"handle_messages 3:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
} elseif ($user[0]['except'] == 1) {
|
||||
} elseif ($user[0]['except'] == 2 || $user[0]['except'] == 3) {
|
||||
try {
|
||||
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg3, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid]));
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?PHP
|
||||
function update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$norotate=NULL) {
|
||||
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);
|
||||
$countbackuperr = 0;
|
||||
|
||||
$tables = array('config','groups','job_check','server_usage','stats_nations','stats_platforms','stats_server','stats_user','stats_versions','user','user_snapshot');
|
||||
$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');
|
||||
|
||||
foreach ($tables as $table) {
|
||||
if($mysqlcon->query("SELECT 1 FROM bak_$table LIMIT 1") !== false) {
|
||||
@@ -21,6 +21,7 @@ function update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$norot
|
||||
foreach ($tables as $table) {
|
||||
if($mysqlcon->exec("CREATE TABLE $dbname.bak_$table LIKE $dbname.$table") === false) {
|
||||
enter_logfile($logpath,$timezone,1," Error due creating table bak_".$table.".",$norotate);
|
||||
$countbackuperr++;
|
||||
} else {
|
||||
if($mysqlcon->exec("INSERT $dbname.bak_$table SELECT * FROM $dbname.$table") === false) {
|
||||
enter_logfile($logpath,$timezone,1," Error due inserting data from table ".$table.".",$norotate);
|
||||
@@ -111,6 +112,15 @@ function update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$norot
|
||||
enter_logfile($logpath,$timezone,5," Cleaned update folder.",$norotate);
|
||||
}
|
||||
enter_logfile($logpath,$timezone,4," Files updated successfully. Wait for restart via cron/task. Shutting down!\n\n",$norotate);
|
||||
|
||||
$path = substr(__DIR__, 0, -4);
|
||||
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
exec("start ".$phpcommand." ".$path."worker.php restart");
|
||||
} else {
|
||||
exec($phpcommand." ".$path."worker.php restart > /dev/null 2>/dev/null &");
|
||||
}
|
||||
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
$WshShell = new COM("WScript.Shell");
|
||||
$oExec = $WshShell->Run("cmd /C php ".substr(__DIR__,0,-4)."\worker.php stop", 0, false);
|
||||
|
||||
Reference in New Issue
Block a user