release 1.3.22
This commit is contained in:
@@ -20,18 +20,18 @@ function addon_assign_groups($addons_config,$ts3,$cfg,$dbname,$allclients,&$db_c
|
||||
try {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$ts3->serverGroupClientDel($group, $cldbid);
|
||||
enter_logfile($cfg,6,"Removed servergroup $group from user $nickname (UID: $uid), requested by Add-on 'Assign Servergroups'");
|
||||
enter_logfile(6,"Removed servergroup $group from user $nickname (UID: $uid), requested by Add-on 'Assign Servergroups'");
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"addon_assign_groups:".$e->getCode().': '."Error while removing group: ".$e->getMessage());
|
||||
enter_logfile(2,"addon_assign_groups:".$e->getCode().': '."Error while removing group: ".$e->getMessage());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$ts3->serverGroupClientAdd($group, $cldbid);
|
||||
enter_logfile($cfg,6,"Added servergroup $group from user $nickname (UID: $uid), requested by Add-on 'Assign Servergroups'");
|
||||
enter_logfile(6,"Added servergroup $group from user $nickname (UID: $uid), requested by Add-on 'Assign Servergroups'");
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"addon_assign_groups:".$e->getCode().': '."Error while adding group: ".$e->getMessage());
|
||||
enter_logfile(2,"addon_assign_groups:".$e->getCode().': '."Error while adding group: ".$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ function addon_channelinfo_toplist(&$addons_config,$ts3,$mysqlcon,$cfg,$dbname,$
|
||||
|
||||
$smarty = new Smarty();
|
||||
|
||||
$smarty->setTemplateDir($cfg['logs_path'].'smarty/templates');
|
||||
$smarty->setCompileDir($cfg['logs_path'].'smarty/templates_c');
|
||||
$smarty->setCacheDir($cfg['logs_path'].'smarty/cache');
|
||||
$smarty->setConfigDir($cfg['logs_path'].'smarty/configs');
|
||||
$smarty->setTemplateDir($GLOBALS['logpath'].'smarty/templates');
|
||||
$smarty->setCompileDir($GLOBALS['logpath'].'smarty/templates_c');
|
||||
$smarty->setCacheDir($GLOBALS['logpath'].'smarty/cache');
|
||||
$smarty->setConfigDir($GLOBALS['logpath'].'smarty/configs');
|
||||
|
||||
if(isset($addons_config['channelinfo_toplist_active']['value']) && $addons_config['channelinfo_toplist_active']['value'] == '1') {
|
||||
if($addons_config['channelinfo_toplist_lastupdate']['value'] < ($nowtime - $addons_config['channelinfo_toplist_delay']['value'])) {
|
||||
@@ -46,10 +46,10 @@ function addon_channelinfo_toplist(&$addons_config,$ts3,$mysqlcon,$cfg,$dbname,$
|
||||
}
|
||||
|
||||
$filter = " AND `user`.`uuid` NOT IN ($notinuuid) AND `user`.`cldgroup` NOT IN ($notingroup) $andnotgroup ".$filter;
|
||||
#enter_logfile($cfg,2,'SQL: '."SELECT * FROM `$dbname`.`stats_user` INNER JOIN `$dbname`.`user` ON `user`.`uuid` = `stats_user`.`uuid` WHERE `removed`='0' {$filter} DESC LIMIT 10");
|
||||
#enter_logfile(2,'SQL: '."SELECT * FROM `$dbname`.`stats_user` INNER JOIN `$dbname`.`user` ON `user`.`uuid` = `stats_user`.`uuid` WHERE `removed`='0' {$filter} DESC LIMIT 10");
|
||||
|
||||
if(($userdata = $mysqlcon->query("SELECT * FROM `$dbname`.`stats_user` INNER JOIN `$dbname`.`user` ON `user`.`uuid` = `stats_user`.`uuid` WHERE `removed`='0' {$filter} DESC LIMIT 10")->fetchAll(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,2,'addon_channelinfo1: '.print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,'addon_channelinfo1: '.print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$smarty->assign('LAST_UPDATE_TIME',(DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($cfg['logs_timezone']))->format("Y-m-d H:i:s")));
|
||||
@@ -125,16 +125,16 @@ function addon_channelinfo_toplist(&$addons_config,$ts3,$mysqlcon,$cfg,$dbname,$
|
||||
$addons_config['channelinfo_toplist_lastupdate']['value'] = $nowtime;
|
||||
$toplist_desc = $mysqlcon->quote($toplist_desc, ENT_QUOTES);
|
||||
$sqlexec .= "INSERT IGNORE INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('channelinfo_toplist_lastdesc',{$toplist_desc}),('channelinfo_toplist_lastupdate','{$nowtime}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);\n";
|
||||
enter_logfile($cfg,5,' Addon: \'channelinfo_toplist\' writing new channelinfo toplist to channel description.');
|
||||
enter_logfile(5,' Addon: \'channelinfo_toplist\' writing new channelinfo toplist to channel description.');
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,'addon_channelinfo2: ['.$e->getCode().']: '.$e->getMessage());
|
||||
enter_logfile(2,'addon_channelinfo2: ['.$e->getCode().']: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$errmsg = str_replace('"', '\'', $e->getMessage());
|
||||
$addons_config['channelinfo_toplist_lastupdate']['value'] = $nowtime;
|
||||
$sqlexec .= "INSERT IGNORE INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('channelinfo_toplist_lastupdate','{$nowtime}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);\n";
|
||||
enter_logfile($cfg,2,' Addon: \'channelinfo_toplist\'; There might be a syntax error in your \'channel description\', which is defined in the webinterface! Error message: ['.$e->getCode().']: '.$errmsg);
|
||||
enter_logfile(2,' Addon: \'channelinfo_toplist\'; There might be a syntax error in your \'channel description\', which is defined in the webinterface! Error message: ['.$e->getCode().']: '.$errmsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
258
jobs/bot.php
258
jobs/bot.php
@@ -16,111 +16,110 @@ set_time_limit(0);
|
||||
error_reporting(E_ALL);
|
||||
ini_set("log_errors", 1);
|
||||
|
||||
require_once(substr(__DIR__,0,-4).'other/_functions.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'other/_functions.php');
|
||||
$persistent = 1;
|
||||
require_once(substr(__DIR__,0,-4).'other/config.php');
|
||||
$lang = set_language(get_language($cfg));
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'other/config.php');
|
||||
$lang = set_language(get_language());
|
||||
|
||||
set_error_handler("php_error_handling");
|
||||
ini_set("error_log", $cfg['logs_path'].'ranksystem.log');
|
||||
ini_set("error_log", $GLOBALS['logfile']);
|
||||
|
||||
require_once(substr(__DIR__,0,-4).'other/phpcommand.php');
|
||||
|
||||
if((isset($_SERVER['HTTP_HOST']) || isset($_SERVER['REMOTE_ADDR'])) && isset($cfg_params['default_cmdline_sec_switch']) && $cfg_params['default_cmdline_sec_switch'] == 1) {
|
||||
shutdown($mysqlcon,$cfg,1,"Request to start the Ranksystem from ".$_SERVER['REMOTE_ADDR'].". It seems the request came not from the command line!");
|
||||
if((isset($_SERVER['HTTP_HOST']) || isset($_SERVER['REMOTE_ADDR'])) && isset($cfg['default_cmdline_sec_switch']) && $cfg['default_cmdline_sec_switch'] == 1) {
|
||||
shutdown($mysqlcon,3,"Request to start the Ranksystem from ".$_SERVER['REMOTE_ADDR'].". It seems the request came not from the command line!",FALSE);
|
||||
}
|
||||
if(version_compare(PHP_VERSION, '5.5.0', '<')) {
|
||||
shutdown($mysqlcon,$cfg,1,"Your PHP version (".PHP_VERSION.") is below 5.5.0. Update of PHP is required!");
|
||||
shutdown($mysqlcon,1,"Your PHP version (".PHP_VERSION.") is below 5.5.0. Update of PHP is required!");
|
||||
}
|
||||
if(!function_exists('simplexml_load_file')) {
|
||||
shutdown($mysqlcon,$cfg,1,sprintf($lang['errphp'],'PHP SimpleXML'));
|
||||
shutdown($mysqlcon,1,sprintf($lang['errphp'],'PHP SimpleXML'));
|
||||
}
|
||||
if(!in_array('curl', get_loaded_extensions())) {
|
||||
shutdown($mysqlcon,$cfg,1,sprintf($lang['errphp'],'PHP cURL'));
|
||||
shutdown($mysqlcon,1,sprintf($lang['errphp'],'PHP cURL'));
|
||||
}
|
||||
if(!in_array('zip', get_loaded_extensions())) {
|
||||
shutdown($mysqlcon,$cfg,1,sprintf($lang['errphp'],'PHP Zip'));
|
||||
shutdown($mysqlcon,1,sprintf($lang['errphp'],'PHP Zip'));
|
||||
}
|
||||
if(!in_array('mbstring', get_loaded_extensions())) {
|
||||
shutdown($mysqlcon,$cfg,1,sprintf($lang['errphp'],'PHP mbstring'));
|
||||
shutdown($mysqlcon,1,sprintf($lang['errphp'],'PHP mbstring'));
|
||||
}
|
||||
|
||||
|
||||
enter_logfile($cfg,9,"");
|
||||
enter_logfile($cfg,9,"###################################################################");
|
||||
enter_logfile($cfg,9,"Initialize Bot...");
|
||||
require_once(substr(__DIR__,0,-4).'libs/ts3_lib/TeamSpeak3.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/calc_user.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/get_avatars.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/update_channel.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/update_groups.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/calc_serverstats.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/server_usage.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/calc_user_snapshot.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/calc_userstats.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/clean.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/check_db.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/handle_messages.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/event_userenter.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/update_rs.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/reset_rs.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/db_ex_imp.php');
|
||||
require_once(substr(__DIR__,0,-4).'libs/smarty/Smarty.class.php');
|
||||
enter_logfile(9,"");
|
||||
enter_logfile(9,"###################################################################");
|
||||
enter_logfile(9,"Initialize Bot...");
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'libs/ts3_lib/TeamSpeak3.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/calc_user.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/get_avatars.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/update_channel.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/update_groups.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/calc_serverstats.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/server_usage.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/calc_user_snapshot.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/calc_userstats.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/clean.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/check_db.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/handle_messages.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/event_userenter.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/update_rs.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/reset_rs.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/db_ex_imp.php');
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'libs/smarty/Smarty.class.php');
|
||||
|
||||
enter_logfile($cfg,9,"Running on OS: ".php_uname("s")." ".php_uname("r"));
|
||||
enter_logfile($cfg,9,"Using PHP Version: ".PHP_VERSION);
|
||||
if(version_compare(PHP_VERSION, '7.2.0', '<')) {
|
||||
enter_logfile($cfg,3,"Your PHP Version: (".PHP_VERSION.") is outdated and no longer supported. Please update it!");
|
||||
enter_logfile(9,"Running on OS: ".php_uname("s")." ".php_uname("r"));
|
||||
enter_logfile(9,"Installation Path: ".__DIR__);
|
||||
enter_logfile(9,"Using PHP Version: ".PHP_VERSION);
|
||||
if(version_compare(PHP_VERSION, '8.0.0', '<')) {
|
||||
enter_logfile(3,"Your PHP Version: (".PHP_VERSION.") is outdated and no longer supported. Please update it!");
|
||||
}
|
||||
enter_logfile($cfg,9,"Database Version: ".$mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION));
|
||||
enter_logfile(9,"Database Version: ".$mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION));
|
||||
|
||||
enter_logfile($cfg,9,"Starting connection test to the Ranksystem update-server (may need a few seconds)...");
|
||||
enter_logfile(9,"Starting connection test to the Ranksystem update-server (may need a few seconds)...");
|
||||
$update_server = fsockopen('193.70.102.252', 443, $errno, $errstr, 10);
|
||||
if(!$update_server) {
|
||||
enter_logfile($cfg,2," Connection to Ranksystem update-server failed: $errstr ($errno)");
|
||||
enter_logfile($cfg,3," This connection is neccessary to receive updates for the Ranksystem!");
|
||||
enter_logfile($cfg,3," Please whitelist the IP 193.70.102.252 (TCP port 443) on your network (firewall)");
|
||||
enter_logfile(2," Connection to Ranksystem update-server failed: $errstr ($errno)");
|
||||
enter_logfile(3," This connection is neccessary to receive updates for the Ranksystem!");
|
||||
enter_logfile(3," Please whitelist the IP 193.70.102.252 (TCP port 443) on your network (firewall)");
|
||||
} else {
|
||||
enter_logfile($cfg,9," Connection test successful");
|
||||
enter_logfile(9," Connection test successful");
|
||||
}
|
||||
enter_logfile($cfg,9,"Starting connection test to the Ranksystem update-server [done]");
|
||||
enter_logfile(9,"Starting connection test to the Ranksystem update-server [done]");
|
||||
|
||||
check_db($mysqlcon,$lang,$cfg,$dbname);
|
||||
$cfg['temp_updatedone'] = check_db($mysqlcon,$lang,$cfg,$dbname);
|
||||
$cfg['temp_db_version'] = $mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
$cfg['temp_last_botstart'] = time();
|
||||
$cfg['temp_reconnect_attempts'] = 0;
|
||||
$cfg['temp_ts_no_reconnection'] = 0;
|
||||
enter_logfile($cfg,4,"Check Ranksystem files for updates...");
|
||||
enter_logfile(4,"Check Ranksystem files for updates...");
|
||||
if(isset($cfg['version_current_using']) && isset($cfg['version_latest_available']) && $cfg['version_latest_available'] != NULL && version_compare($cfg['version_latest_available'], $cfg['version_current_using'], '>')) {
|
||||
update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand);
|
||||
update_rs($mysqlcon,$lang,$cfg,$dbname);
|
||||
}
|
||||
enter_logfile($cfg,4,"Check Ranksystem files for updates [done]");
|
||||
enter_logfile($cfg,9,"Ranksystem Version: ".$cfg['version_current_using']." (on Update-Channel: ".$cfg['version_update_channel'].")");
|
||||
enter_logfile($cfg,4,"Loading addons...");
|
||||
require_once(substr(__DIR__,0,-4).'other/load_addons_config.php');
|
||||
enter_logfile(4,"Check Ranksystem files for updates [done]");
|
||||
enter_logfile(9,"Ranksystem Version: ".$cfg['version_current_using']." (on Update-Channel: ".$cfg['version_update_channel'].")");
|
||||
enter_logfile(4,"Loading addons...");
|
||||
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'other/load_addons_config.php');
|
||||
$addons_config = load_addons_config($mysqlcon,$lang,$cfg,$dbname);
|
||||
if($addons_config['assign_groups_active']['value'] == '1') {
|
||||
enter_logfile($cfg,4," Addon: 'assign_groups' [ON]");
|
||||
include(substr(__DIR__,0,-4).'jobs/addon_assign_groups.php');
|
||||
enter_logfile(4," Addon: 'assign_groups' [ON]");
|
||||
include(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/addon_assign_groups.php');
|
||||
$cfg['temp_addon_assign_groups'] = "enabled";
|
||||
} else {
|
||||
enter_logfile($cfg,4," Addon: 'assign_groups' [OFF]");
|
||||
enter_logfile(4," Addon: 'assign_groups' [OFF]");
|
||||
$cfg['temp_addon_assign_groups'] = "disabled";
|
||||
}
|
||||
if($addons_config['channelinfo_toplist_active']['value'] == '1') {
|
||||
enter_logfile($cfg,4," Addon: 'channelinfo_toplist' [ON]");
|
||||
include(substr(__DIR__,0,-4).'jobs/addon_channelinfo_toplist.php');
|
||||
enter_logfile(4," Addon: 'channelinfo_toplist' [ON]");
|
||||
include(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/addon_channelinfo_toplist.php');
|
||||
$cfg['temp_addon_channelinfo_toplist'] = "enabled";
|
||||
} else {
|
||||
enter_logfile($cfg,4," Addon: 'channelinfo_toplist' [OFF]");
|
||||
enter_logfile(4," Addon: 'channelinfo_toplist' [OFF]");
|
||||
$cfg['temp_addon_channelinfo_toplist'] = "disabled";
|
||||
}
|
||||
enter_logfile($cfg,4,"Loading addons [done]");
|
||||
enter_logfile(4,"Loading addons [done]");
|
||||
|
||||
function run_bot(&$cfg) {
|
||||
global $mysqlcon, $db, $dbname, $dbtype, $lang, $phpcommand, $addons_config, $max_execution_time, $memory_limit, $ts3server;
|
||||
|
||||
enter_logfile($cfg,9,"Connect to TS3 Server (Address: '".$cfg['teamspeak_host_address']."' Voice-Port: '".$cfg['teamspeak_voice_port']."' Query-Port: '".$cfg['teamspeak_query_port']."' SSH: '".$cfg['teamspeak_query_encrypt_switch']."' Query-Slowmode: '".number_format(($cfg['teamspeak_query_command_delay']/1000000),1)."').");
|
||||
enter_logfile(9,"Connect to TS3 Server (Address: '".$cfg['teamspeak_host_address']."' Voice-Port: '".$cfg['teamspeak_voice_port']."' Query-Port: '".$cfg['teamspeak_query_port']."' SSH: '".$cfg['teamspeak_query_encrypt_switch']."' Query-Slowmode: '".number_format(($cfg['teamspeak_query_command_delay']/1000000),1)."').");
|
||||
|
||||
try {
|
||||
if($cfg['temp_ts_no_reconnection'] != 1) {
|
||||
@@ -130,20 +129,20 @@ function run_bot(&$cfg) {
|
||||
$ts3host = TeamSpeak3::factory("serverquery://".rawurlencode($cfg['teamspeak_query_user']).":".rawurlencode($cfg['teamspeak_query_pass'])."@".$cfg['teamspeak_host_address'].":".$cfg['teamspeak_query_port']."/?blocking=0");
|
||||
}
|
||||
|
||||
enter_logfile($cfg,9,"Connection to TS3 Server established.");
|
||||
enter_logfile(9,"Connection to TS3 Server established.");
|
||||
try{
|
||||
$ts3version = $ts3host->version();
|
||||
enter_logfile($cfg,5," TS3 Server version: ".$ts3version['version']." on ".$ts3version['platform']." [Build: ".$ts3version['build']." from ".date("Y-m-d H:i:s",$ts3version['build'])."]");
|
||||
enter_logfile(5," TS3 Server version: ".$ts3version['version']." on ".$ts3version['platform']." [Build: ".$ts3version['build']." from ".date("Y-m-d H:i:s",$ts3version['build'])."]");
|
||||
$cfg['temp_ts_version'] = $ts3version['version'];
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2," Error due getting TS3 server version - ".$e->getCode().': '.$e->getMessage());
|
||||
enter_logfile(2," Error due getting TS3 server version - ".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
|
||||
if(version_compare($ts3version['version'],'3.13.2','<=') && version_compare($ts3version['version'],'3.0.0','>=')) {
|
||||
enter_logfile($cfg,3," Your TS3 server is outdated, please update it!");
|
||||
if(version_compare($ts3version['version'],'3.13.7','<') && version_compare($ts3version['version'],'3.0.0','>=')) {
|
||||
enter_logfile(3," Your TS3 server is outdated, please update it!");
|
||||
}
|
||||
|
||||
enter_logfile($cfg,9," Select virtual server...");
|
||||
enter_logfile(9," Select virtual server...");
|
||||
try {
|
||||
if(version_compare($ts3version['version'],'3.4.0','>=') || version_compare($ts3version['version'],'3.0.0','<=')) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
@@ -161,15 +160,15 @@ function run_bot(&$cfg) {
|
||||
}
|
||||
break;
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,3,' '.$lang['errorts3'].$e->getCode().': '.$e->getMessage());
|
||||
shutdown($mysqlcon,$cfg,1,"Critical TS3 error on core function!");
|
||||
enter_logfile(3,' '.$lang['errorts3'].$e->getCode().': '.$e->getMessage());
|
||||
shutdown($mysqlcon,1,"Critical TS3 error on core function!");
|
||||
}
|
||||
}
|
||||
}
|
||||
enter_logfile($cfg,9," Select virtual server [done]");
|
||||
enter_logfile(9," Select virtual server [done]");
|
||||
$cfg['temp_reconnect_attempts'] = 0;
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2," Error due selecting virtual server - ".$e->getCode().': '.$e->getMessage()." (bad Voice-Port or Bot name?)");
|
||||
enter_logfile(2," Error due selecting virtual server - ".$e->getCode().': '.$e->getMessage()." (bad Voice-Port or Bot name?)");
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -181,7 +180,7 @@ function run_bot(&$cfg) {
|
||||
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", "handle_messages");
|
||||
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyCliententerview", "event_userenter");
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2," Error due notifyRegister on TS3 server - ".$e->getCode().': '.$e->getMessage());
|
||||
enter_logfile(2," Error due notifyRegister on TS3 server - ".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
|
||||
$whoami = $ts3server->whoami();
|
||||
@@ -189,19 +188,38 @@ function run_bot(&$cfg) {
|
||||
try {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$ts3server->clientMove($whoami['client_id'],$cfg['teamspeak_default_channel_id']);
|
||||
enter_logfile($cfg,5," Joined to specified TS channel with channel-ID ".$cfg['teamspeak_default_channel_id'].".");
|
||||
enter_logfile(5," Joined to specified TS channel with channel-ID ".$cfg['teamspeak_default_channel_id'].".");
|
||||
} catch (Exception $e) {
|
||||
if($e->getCode() != 770) {
|
||||
enter_logfile($cfg,2," Could not join specified TS channel (channel-ID: ".$cfg['teamspeak_default_channel_id'].") - ".$e->getCode().': '.$e->getMessage());
|
||||
enter_logfile(2," Could not join specified TS channel (channel-ID: ".$cfg['teamspeak_default_channel_id'].") - ".$e->getCode().': '.$e->getMessage());
|
||||
} else {
|
||||
enter_logfile($cfg,5," Joined to specified TS channel with channel-ID ".$cfg['teamspeak_default_channel_id']." (already member of it).");
|
||||
enter_logfile(5," Joined to specified TS channel with channel-ID ".$cfg['teamspeak_default_channel_id']." (already member of it).");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,5," No channel defined where the Ranksystem Bot should be entered.");
|
||||
enter_logfile(5," No channel defined where the Ranksystem Bot should be entered.");
|
||||
}
|
||||
|
||||
if($cfg['temp_updatedone'] === TRUE) {
|
||||
enter_logfile(4,$lang['upinf']);
|
||||
if(isset($cfg['webinterface_admin_client_unique_id_list']) && $cfg['webinterface_admin_client_unique_id_list'] != NULL) {
|
||||
foreach(array_flip($cfg['webinterface_admin_client_unique_id_list']) as $clientid) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
if(isset($cfg['teamspeak_news_bb']) && $cfg['teamspeak_news_bb'] != '') {
|
||||
sendmessage($ts3server, $cfg, $clientid, sprintf($lang['upmsg2'], $cfg['version_current_using'], 'https://ts-ranksystem.com/#changelog')."\n\n[U]Latest News:[/U]\n".$cfg['teamspeak_news_bb'], 1, NULL, sprintf($lang['upusrerr'], $clientid), 6, sprintf($lang['upusrinf'], $clientid));
|
||||
} else {
|
||||
sendmessage($ts3server, $cfg, $clientid, sprintf($lang['upmsg2'], $cfg['version_current_using'], 'https://ts-ranksystem.com/#changelog'), 1, NULL, sprintf($lang['upusrerr'], $clientid), 6, sprintf($lang['upusrinf'], $clientid));
|
||||
}
|
||||
enter_logfile(4," ".sprintf($lang['upusrinf'], $clientid));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile(6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enter_logfile($cfg,9,"Config check started...");
|
||||
enter_logfile(9,"Config check started...");
|
||||
switch ($cfg['logs_debug_level']) {
|
||||
case 1:
|
||||
$loglevel = "1 - CRITICAL";
|
||||
@@ -224,13 +242,13 @@ function run_bot(&$cfg) {
|
||||
default:
|
||||
$loglevel = "UNKNOWN";
|
||||
}
|
||||
enter_logfile($cfg,9," Log Level: ".$loglevel);
|
||||
enter_logfile($cfg,6," Serverside config 'max_execution_time' (PHP.ini): ".$max_execution_time." sec.");
|
||||
enter_logfile($cfg,6," Serverside config 'memory_limit' (PHP.ini): ".$memory_limit);
|
||||
enter_logfile(9," Log Level: ".$loglevel);
|
||||
enter_logfile(6," Serverside config 'max_execution_time' (PHP.ini): ".$max_execution_time." sec.");
|
||||
enter_logfile(6," Serverside config 'memory_limit' (PHP.ini): ".$memory_limit);
|
||||
krsort($cfg['rankup_definition']);
|
||||
|
||||
if(($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups`")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,1," Select on DB failed for group check: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(1," Select on DB failed for group check: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$checkgroups = 0;
|
||||
@@ -258,31 +276,31 @@ function run_bot(&$cfg) {
|
||||
}
|
||||
}
|
||||
if($checkgroups > 0) {
|
||||
enter_logfile($cfg,3," Found servergroups in config, which are unknown. Redownload all servergroups from TS3 server.");
|
||||
enter_logfile(3," Found servergroups in config, which are unknown. Redownload all servergroups from TS3 server.");
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`groups`;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$serverinfo = $ts3server->serverInfo();
|
||||
$select_arr = array();
|
||||
$db_cache = array();
|
||||
$sqlexec2 = update_groups($ts3server,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,$db_cache,1);
|
||||
if($mysqlcon->exec($sqlexec2) === false) {
|
||||
enter_logfile($cfg,2,"Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
if($sqlexec2 != NULL && $mysqlcon->exec($sqlexec2) === false) {
|
||||
enter_logfile(2,"Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
unset($sqlexec2,$select_arr,$db_cache,$groupslist,$serverinfo,$ts3version);
|
||||
$errcnf = 0;
|
||||
enter_logfile($cfg,4," Downloading of servergroups finished. Recheck the config.");
|
||||
enter_logfile(4," Downloading of servergroups finished. Recheck the config.");
|
||||
|
||||
if(($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups`")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,1," Select on DB failed for group check: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(1," Select on DB failed for group check: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
if(isset($groupslist) && $groupslist != NULL) {
|
||||
if(isset($cfg['rankup_definition']) && $cfg['rankup_definition'] != NULL) {
|
||||
foreach($cfg['rankup_definition'] as $rank) {
|
||||
if(!isset($groupslist[$rank['group']]) && $rank['group'] != NULL) {
|
||||
enter_logfile($cfg,1,' '.sprintf($lang['upgrp0001'], $rank['group'], $lang['wigrptime']));
|
||||
enter_logfile(1,' '.sprintf($lang['upgrp0001'], $rank['group'], $lang['wigrptime']));
|
||||
$errcnf++;
|
||||
}
|
||||
}
|
||||
@@ -290,55 +308,43 @@ function run_bot(&$cfg) {
|
||||
if(isset($cfg['rankup_boost_definition']) && $cfg['rankup_boost_definition'] != NULL) {
|
||||
foreach($cfg['rankup_boost_definition'] as $groupid => $value) {
|
||||
if(!isset($groupslist[$groupid]) && $groupid != NULL) {
|
||||
enter_logfile($cfg,2,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wiboost']));
|
||||
enter_logfile(2,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wiboost']));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($cfg['rankup_excepted_group_id_list']) && $cfg['rankup_excepted_group_id_list'] != NULL) {
|
||||
foreach($cfg['rankup_excepted_group_id_list'] as $groupid => $value) {
|
||||
if(!isset($groupslist[$groupid]) && $groupid != NULL) {
|
||||
enter_logfile($cfg,2,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wiexgrp']));
|
||||
enter_logfile(2,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wiexgrp']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($errcnf > 0) {
|
||||
shutdown($mysqlcon,$cfg,1,"Critical Config error!");
|
||||
shutdown($mysqlcon,1,"Critical Config error!");
|
||||
} else {
|
||||
enter_logfile($cfg,4," No critical problems found! All seems to be fine...");
|
||||
}
|
||||
}
|
||||
|
||||
if(($lastupdate = $mysqlcon->query("SELECT `timestamp` FROM `$dbname`.`job_check` WHERE `job_name`='last_update'")->fetch()) === false) {
|
||||
enter_logfile($cfg,1," Select on DB failed for job check: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
if($lastupdate['timestamp'] != 0 && ($lastupdate['timestamp'] + 10) > time()) {
|
||||
if(isset($cfg['webinterface_admin_client_unique_id_list']) && $cfg['webinterface_admin_client_unique_id_list'] != NULL) {
|
||||
foreach(array_flip($cfg['webinterface_admin_client_unique_id_list']) as $clientuuid) {
|
||||
sendmessage($ts3server, $cfg, $clientuuid, sprintf($lang['upmsg2'], $cfg['version_current_using'], 'https://ts-ranksystem.com/#changelog'), 1, NULL, sprintf($lang['upusrerr'], $clientuuid), 6, sprintf($lang['upusrinf'], $clientuuid));
|
||||
}
|
||||
}
|
||||
enter_logfile(4," No critical problems found! All seems to be fine...");
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($cfg['webinterface_fresh_installation']) && $cfg['webinterface_fresh_installation'] == 1) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`cfg_params` SET `value`=0 WHERE `param`='webinterface_fresh_installation'") === false) {
|
||||
enter_logfile($cfg,2,"Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
unset($groupslist,$errcnf,$checkgroups,$lastupdate,$updcld,$loglevel,$whoami,$ts3host,$max_execution_time,$memory_limit,$memory_limit);
|
||||
enter_logfile($cfg,9,"Config check [done]");
|
||||
enter_logfile(9,"Config check [done]");
|
||||
} else {
|
||||
enter_logfile($cfg,9," Try to use the restored TS3 connection");
|
||||
enter_logfile(9," Try to use the restored TS3 connection");
|
||||
}
|
||||
|
||||
enter_logfile($cfg,9,"Bot starts now his work!");
|
||||
enter_logfile(9,"Bot starts now his work!");
|
||||
$looptime = $cfg['temp_count_laps'] = $cfg['temp_whole_laptime'] = $cfg['temp_count_laptime'] = 0; $cfg['temp_last_laptime'] = '';
|
||||
usleep(3000000);
|
||||
|
||||
if(($get_db_data = $mysqlcon->query("SELECT * FROM `$dbname`.`user`; SELECT MAX(`timestamp`) AS `timestamp` FROM `$dbname`.`server_usage`; SELECT * FROM `$dbname`.`job_check`; SELECT * FROM `$dbname`.`groups`; SELECT * FROM `$dbname`.`channel`; SELECT * FROM `$dbname`.`addon_assign_groups`; SELECT * FROM `$dbname`.`admin_addtime`; ")) === false) {
|
||||
shutdown($mysqlcon,$cfg,1,"Select on DB failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
shutdown($mysqlcon,1,"Select on DB failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$count_select = 0;
|
||||
@@ -382,13 +388,13 @@ function run_bot(&$cfg) {
|
||||
|
||||
unset($db_cache['job_check']);
|
||||
if(($db_cache['job_check'] = $mysqlcon->query("SELECT * FROM `$dbname`.`job_check`")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,3," Select on DB failed for job check: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(3," Select on DB failed for job check: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
if($db_cache['job_check']['reload_trigger']['timestamp'] == 1) {
|
||||
if(intval($db_cache['job_check']['reload_trigger']['timestamp']) == 1) {
|
||||
unset($db_cache['addon_assign_groups'],$db_cache['admin_addtime']);
|
||||
if(($get_db_data = $mysqlcon->query("SELECT * FROM `$dbname`.`addon_assign_groups`; SELECT * FROM `$dbname`.`admin_addtime`; SELECT * FROM `$dbname`.`groups`; SELECT * FROM `$dbname`.`channel`;")) === false) {
|
||||
shutdown($mysqlcon,$cfg,1,"Select on DB failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
shutdown($mysqlcon,1,"Select on DB failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$count_select = 0;
|
||||
@@ -417,9 +423,9 @@ function run_bot(&$cfg) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=0 WHERE `job_name`='reload_trigger';\n";
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"SQL Select needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"SQL Select needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
|
||||
check_shutdown($cfg);
|
||||
check_shutdown();
|
||||
|
||||
$ts3server->clientListReset();
|
||||
$allclients = $ts3server->clientListtsn("-uid -groups -times -info -country");
|
||||
@@ -452,23 +458,23 @@ function run_bot(&$cfg) {
|
||||
foreach($sqlarr as $singlesql) {
|
||||
if(strpos($singlesql, 'UPDATE') !== false || strpos($singlesql, 'INSERT') !== false || strpos($singlesql, 'DELETE') !== false || strpos($singlesql, 'SET') !== false) {
|
||||
if($mysqlcon->exec($singlesql) === false) {
|
||||
enter_logfile($cfg,4,"Executing SQL: ".$singlesql);
|
||||
enter_logfile($cfg,2,"Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(4,"Executing SQL: ".$singlesql);
|
||||
enter_logfile(2,"Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
} elseif(strpos($singlesql, ' ') === false) {
|
||||
enter_logfile($cfg,2,"Command not recognized as SQL: ".$singlesql);
|
||||
enter_logfile(2,"Command not recognized as SQL: ".$singlesql);
|
||||
}
|
||||
}
|
||||
$sqlfile = $cfg['logs_path'].'temp_sql_dump.sql';
|
||||
$sqlfile = $GLOBALS['logpath'].'temp_sql_dump.sql';
|
||||
$sqldump = fopen($sqlfile, 'wa+');
|
||||
fwrite($sqldump, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($cfg['logs_timezone']))->format("Y-m-d H:i:s.u ")." SQL:\n".$sqlexec);
|
||||
fclose($sqldump);
|
||||
} else {
|
||||
if($mysqlcon->exec($sqlexec) === false) {
|
||||
enter_logfile($cfg,2,"Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
enter_logfile($cfg,6,"SQL executions needs: ".(number_format(round((microtime(true) - $startsql), 5),5)));
|
||||
enter_logfile(6,"SQL executions needs: ".(number_format(round((microtime(true) - $startsql), 5),5)));
|
||||
|
||||
reset_rs($ts3server,$mysqlcon,$lang,$cfg,$dbname,$phpcommand,$db_cache);
|
||||
db_ex_imp($ts3server,$mysqlcon,$lang,$cfg,$dbname,$db_cache);
|
||||
@@ -480,7 +486,7 @@ function run_bot(&$cfg) {
|
||||
$cfg['temp_count_laptime']++;
|
||||
$cfg['temp_last_laptime'] = substr((number_format(round($looptime, 5),5) . ';' . $cfg['temp_last_laptime']),0,79);
|
||||
|
||||
enter_logfile($cfg,6,"last loop: ".round($looptime, 5)." sec.");
|
||||
enter_logfile(6,"last loop: ".round($looptime, 5)." sec.");
|
||||
|
||||
if($looptime < 1) {
|
||||
$loopsleep = (1 - $looptime);
|
||||
@@ -493,10 +499,10 @@ function run_bot(&$cfg) {
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,$lang['error'].': ['.$e->getCode().']: '.$e->getMessage());
|
||||
enter_logfile(2,$lang['error'].': ['.$e->getCode().']: '.$e->getMessage());
|
||||
if(in_array($e->getCode(), array(110,257,258,1024,1026,1031,1032,1033,1034,1280,1793))) {
|
||||
if($mysqlcon->exec("UPDATE $dbname.stats_server SET server_status='0'") === false) {
|
||||
enter_logfile($cfg,2,$lang['error'].print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,$lang['error'].print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,11 +521,11 @@ function run_bot(&$cfg) {
|
||||
$wait_reconnect = 43200;
|
||||
}
|
||||
|
||||
enter_logfile($cfg,4,"Try to reconnect in ".$wait_reconnect." seconds.");
|
||||
enter_logfile(4,"Try to reconnect in ".$wait_reconnect." seconds.");
|
||||
|
||||
for($z = 1; $z <= $wait_reconnect; $z++) {
|
||||
sleep(1);
|
||||
check_shutdown($cfg);
|
||||
check_shutdown();
|
||||
}
|
||||
|
||||
$check_db_arr = array_flip(array('HY000',10054,70100));
|
||||
@@ -527,9 +533,9 @@ function run_bot(&$cfg) {
|
||||
$cfg['temp_ts_no_reconnection'] = 1;
|
||||
try {
|
||||
$mysqlcon = db_connect($db['type'], $db['host'], $db['dbname'], $db['user'], $db['pass'], "no_exit");
|
||||
enter_logfile($cfg,9,"Connection to database restored");
|
||||
enter_logfile(9,"Connection to database restored");
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,$lang['error'].print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,$lang['error'].print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
} else {
|
||||
$cfg['temp_ts_no_reconnection'] = 0;
|
||||
@@ -538,7 +544,7 @@ function run_bot(&$cfg) {
|
||||
$cfg['temp_reconnect_attempts']++;
|
||||
return $ts3server;
|
||||
} else {
|
||||
shutdown($mysqlcon,$cfg,1,"Critical TS3 error on core function!");
|
||||
shutdown($mysqlcon,1,"Critical TS3 error on core function!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
if($db_cache['job_check']['calc_donut_chars']['timestamp'] < ($nowtime - 8) || $db_cache['job_check']['get_version']['timestamp'] < ($nowtime - 43199)) {
|
||||
if(intval($db_cache['job_check']['calc_donut_chars']['timestamp']) < ($nowtime - 8) || intval($db_cache['job_check']['get_version']['timestamp']) < ($nowtime - 43199)) {
|
||||
$db_cache['job_check']['calc_donut_chars']['timestamp'] = $nowtime;
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`={$nowtime} WHERE `job_name`='calc_donut_chars';\n";
|
||||
|
||||
@@ -44,8 +44,8 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$count_version_user[$version] = 1;
|
||||
}
|
||||
|
||||
$total_online_time = $total_online_time + $uuid['count'];
|
||||
$total_inactive_time = $total_inactive_time + $uuid['idle'];
|
||||
if($uuid['count']>0) $total_online_time += $uuid['count'];
|
||||
if($uuid['idle']>0) $total_inactive_time += $uuid['idle'];
|
||||
}
|
||||
|
||||
arsort($country_array);
|
||||
@@ -342,20 +342,21 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
|
||||
|
||||
// Calc Values for server stats
|
||||
if($db_cache['job_check']['calc_server_stats']['timestamp'] < ($nowtime - 899)) {
|
||||
if(intval($db_cache['job_check']['calc_server_stats']['timestamp']) < ($nowtime - 899)) {
|
||||
$db_cache['job_check']['calc_server_stats']['timestamp'] = $nowtime;
|
||||
$weekago = $db_cache['job_check']['last_snapshot_id']['timestamp'] - 28;
|
||||
$monthago = $db_cache['job_check']['last_snapshot_id']['timestamp'] - 120;
|
||||
$weekago = intval($db_cache['job_check']['last_snapshot_id']['timestamp']) - 28;
|
||||
$monthago = intval($db_cache['job_check']['last_snapshot_id']['timestamp']) - 120;
|
||||
if ($weekago < 1) $weekago = $weekago + 121;
|
||||
if ($monthago < 1) $monthago = $monthago + 121;
|
||||
|
||||
if(($entry_snapshot_count = $mysqlcon->query("SELECT count(DISTINCT(`id`)) AS `id` FROM `$dbname`.`user_snapshot`")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,2,"calc_serverstats 19:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"calc_serverstats 19:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if ($entry_snapshot_count['id'] > 28) {
|
||||
// Calc total_online_week
|
||||
if(($snapshot_count_week = $mysqlcon->query("SELECT (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$db_cache['job_check']['last_snapshot_id']['timestamp']}) - (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$weekago}) AS `count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,2,"calc_serverstats 20:".print_r($mysqlcon->errorInfo(), true));
|
||||
#if(($snapshot_count_week = $mysqlcon->query("SELECT (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$db_cache['job_check']['last_snapshot_id']['timestamp']}) - (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$weekago}) AS `count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
if(($snapshot_count_week = $mysqlcon->query("SELECT SUM(`a`.`count` - `b`.`count`) AS `count` FROM `$dbname`.`user_snapshot` `a`, `$dbname`.`user_snapshot` `b` WHERE `b`.`cldbid` = `a`.`cldbid` AND `a`.`id`={$db_cache['job_check']['last_snapshot_id']['timestamp']} AND `b`.`id`={$weekago} AND `a`.`count`>`b`.`count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile(2,"calc_serverstats 20:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if($snapshot_count_week['count'] == NULL) {
|
||||
$total_online_week = 0;
|
||||
@@ -367,8 +368,9 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
}
|
||||
if ($entry_snapshot_count['id'] > 120) {
|
||||
// Calc total_online_month
|
||||
if(($snapshot_count_month = $mysqlcon->query("SELECT (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$db_cache['job_check']['last_snapshot_id']['timestamp']}) - (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$monthago}) AS `count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,2,"calc_serverstats 21:".print_r($mysqlcon->errorInfo(), true));
|
||||
#if(($snapshot_count_month = $mysqlcon->query("SELECT (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$db_cache['job_check']['last_snapshot_id']['timestamp']}) - (SELECT SUM(`count`) FROM `$dbname`.`user_snapshot` WHERE `id`={$monthago}) AS `count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
if(($snapshot_count_month = $mysqlcon->query("SELECT SUM(`a`.`count` - `b`.`count`) AS `count` FROM `$dbname`.`user_snapshot` `a`, `$dbname`.`user_snapshot` `b` WHERE `b`.`cldbid` = `a`.`cldbid` AND `a`.`id`={$db_cache['job_check']['last_snapshot_id']['timestamp']} AND `b`.`id`={$monthago} AND `a`.`count`>`b`.`count`;")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile(2,"calc_serverstats 21:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if($snapshot_count_month['count'] == NULL) {
|
||||
$total_online_month = 0;
|
||||
@@ -380,9 +382,9 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
}
|
||||
$sqlexec .= "UPDATE `$dbname`.`stats_server` SET `total_online_month`={$total_online_month},`total_online_week`={$total_online_week};\nUPDATE `$dbname`.`job_check` SET `timestamp`={$nowtime} WHERE `job_name`='calc_server_stats';\n";
|
||||
|
||||
if ($db_cache['job_check']['get_version']['timestamp'] < ($nowtime - 43199)) {
|
||||
if (intval($db_cache['job_check']['get_version']['timestamp']) < ($nowtime - 43199)) {
|
||||
$db_cache['job_check']['get_version']['timestamp'] = $nowtime;
|
||||
enter_logfile($cfg,6,"Get the latest Ranksystem Version.");
|
||||
enter_logfile(6,"Get the latest Ranksystem Version.");
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://ts-n.net/ranksystem/'.$cfg['version_update_channel']);
|
||||
curl_setopt($ch, CURLOPT_REFERER, 'TSN Ranksystem');
|
||||
@@ -412,22 +414,58 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
$cfg['version_latest_available'] = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
curl_close($ch); unset($ch);
|
||||
|
||||
if(!isset($cfg['stats_news_html']) || $cfg['stats_news_html'] != '') {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='0' WHERE `job_name`='news_html';\nUPDATE `$dbname`.`cfg_params` SET `value`='' WHERE `param`='stats_news_html';\n";
|
||||
}
|
||||
$newh = curl_init();
|
||||
curl_setopt($newh, CURLOPT_URL, 'https://ts-n.net/ranksystem/news_html');
|
||||
curl_setopt($newh, CURLOPT_REFERER, 'TSN Ranksystem - News HTML');
|
||||
curl_setopt($newh, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($newh, CURLOPT_MAXREDIRS, 10);
|
||||
curl_setopt($newh, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($newh, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
$cfg['stats_news_html'] = curl_exec($newh);
|
||||
curl_close($newh); unset($newh);
|
||||
if($cfg['stats_news_html'] != '') {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$nowtime WHERE `job_name`='news_html';\nUPDATE `$dbname`.`cfg_params` SET `value`='{$cfg['stats_news_html']}' WHERE `param`='stats_news_html';\n";
|
||||
}
|
||||
|
||||
if(!isset($cfg['teamspeak_news_bb']) || $cfg['teamspeak_news_bb'] != '') {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='0' WHERE `job_name`='news_bb';\nUPDATE `$dbname`.`cfg_params` SET `value`='' WHERE `param`='teamspeak_news_bb';\n";
|
||||
}
|
||||
$newb = curl_init();
|
||||
curl_setopt($newb, CURLOPT_URL, 'https://ts-n.net/ranksystem/news_bb');
|
||||
curl_setopt($newb, CURLOPT_REFERER, 'TSN Ranksystem - News BB');
|
||||
curl_setopt($newb, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($newb, CURLOPT_MAXREDIRS, 10);
|
||||
curl_setopt($newb, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($newb, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
$cfg['teamspeak_news_bb'] = curl_exec($newb);
|
||||
curl_close($newb); unset($newb);
|
||||
if($cfg['teamspeak_news_bb'] != '') {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$nowtime WHERE `job_name`='news_bb';\nUPDATE `$dbname`.`cfg_params` SET `value`='{$cfg['teamspeak_news_bb']}' WHERE `param`='teamspeak_news_bb';\n";
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_latest_available'], $cfg['version_current_using'], '>') && $cfg['version_latest_available'] != NULL) {
|
||||
enter_logfile($cfg,4,$lang['upinf']);
|
||||
enter_logfile(4,$lang['upinf']);
|
||||
if(isset($cfg['webinterface_admin_client_unique_id_list']) && $cfg['webinterface_admin_client_unique_id_list'] != NULL) {
|
||||
foreach(array_flip($cfg['webinterface_admin_client_unique_id_list']) as $clientid) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upmsg'], $cfg['version_current_using'], $cfg['version_latest_available'], 'https://ts-ranksystem.com/#changelog'));
|
||||
enter_logfile($cfg,4," ".sprintf($lang['upusrinf'], $clientid));
|
||||
if(isset($cfg['teamspeak_news_bb']) && $cfg['teamspeak_news_bb'] != '') {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upmsg'], $cfg['version_current_using'], $cfg['version_latest_available'], 'https://ts-ranksystem.com/#changelog')."\n\n[U]Latest News:[/U]\n".$cfg['teamspeak_news_bb']);
|
||||
} else {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upmsg'], $cfg['version_current_using'], $cfg['version_latest_available'], 'https://ts-ranksystem.com/#changelog'));
|
||||
}
|
||||
enter_logfile(4," ".sprintf($lang['upusrinf'], $clientid));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
enter_logfile(6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
}
|
||||
}
|
||||
}
|
||||
$sqlexec .= update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand);
|
||||
$sqlexec .= update_rs($mysqlcon,$lang,$cfg,$dbname);
|
||||
}
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$nowtime WHERE `job_name`='get_version';\nUPDATE `$dbname`.`cfg_params` SET `value`='{$cfg['version_latest_available']}' WHERE `param`='version_latest_available';\n";
|
||||
}
|
||||
@@ -436,13 +474,13 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$dbversion = $mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
preg_match("/^[0-9\.-]+/", $dbversion, $version_number);
|
||||
if ($cfg['rankup_time_assess_mode'] == 1) {
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '5.5.5-10.6', '>=')) {
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '8', '>=') && version_compare($version_number[0], '10', '<') || version_compare($version_number[0], '5.5.5-10.6', '>=') && version_compare($version_number[0], '5.5.6', '<')) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT RANK() OVER (ORDER BY (`count` - `idle`) DESC) AS `rank`, `uuid` FROM `$dbname`.`user` WHERE `except`<2) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`rank`;\n";
|
||||
} else {
|
||||
$sqlexec .= "SET @a:=0;\nUPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT @a:=@a+1 `nr`,`uuid` FROM `$dbname`.`user` WHERE `except`<2 ORDER BY (`count` - `idle`) DESC) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`nr`;\n";
|
||||
}
|
||||
} else {
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '5.5.5-10.6', '>=')) {
|
||||
if(version_compare($version_number[0], '10.6', '>=') || version_compare($version_number[0], '8', '>=') && version_compare($version_number[0], '10', '<') || version_compare($version_number[0], '5.5.5-10.6', '>=') && version_compare($version_number[0], '5.5.6', '<')) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT RANK() OVER (ORDER BY `count` DESC) AS `rank`, `uuid` FROM `$dbname`.`user` WHERE `except`<2) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`rank`;\n";
|
||||
} else {
|
||||
$sqlexec .= "SET @a:=0;\nUPDATE `$dbname`.`user` AS `u` INNER JOIN (SELECT @a:=@a+1 `nr`,`uuid` FROM `$dbname`.`user` WHERE `except`<2 ORDER BY `count` DESC) AS `s` USING (`uuid`) SET `u`.`rank`=`s`.`nr`;\n";
|
||||
@@ -450,7 +488,7 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
}
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"calc_serverstats needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"calc_serverstats needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
?>
|
||||
@@ -5,16 +5,16 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
$sqlexec = '';
|
||||
|
||||
if(empty($cfg['rankup_definition'])) {
|
||||
shutdown($mysqlcon,$cfg,1,"calc_user:".$lang['wiconferr']);
|
||||
shutdown($mysqlcon,1,"calc_user:".$lang['wiconferr']);
|
||||
}
|
||||
|
||||
$addtime = $nowtime - $db_cache['job_check']['calc_user_lastscan']['timestamp'];
|
||||
$addtime = $nowtime - intval($db_cache['job_check']['calc_user_lastscan']['timestamp']);
|
||||
|
||||
if($addtime > 1800) {
|
||||
enter_logfile($cfg,4,"Much time gone since last scan.. set addtime to 1 second.");
|
||||
enter_logfile(4,"Much time gone since last scan.. set addtime to 1 second.");
|
||||
$addtime = 1;
|
||||
} elseif($addtime < 0) {
|
||||
enter_logfile($cfg,3,"Negative time valie (now < last scan).. Error in your machine time!.. set addtime to 1 second.");
|
||||
enter_logfile(3,"Negative time valie (now < last scan).. Error in your machine time!.. set addtime to 1 second.");
|
||||
$addtime = 1;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
if($value['timecount'] == 0 && $value['timestamp'] == 4273093200) {
|
||||
//remove user
|
||||
if(($user = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` WHERE `uuid`='{$uuid}'")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
enter_logfile($cfg,2,"Database error on selecting user (admin function remove user): ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"Database error on selecting user (admin function remove user): ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$temp_cldbid = $user[$uuid]['cldbid'];
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`addon_assign_groups` WHERE `uuid`='{$uuid}';\nDELETE FROM `$dbname`.`admin_addtime` WHERE `uuid`='{$uuid}';\nDELETE FROM `$dbname`.`stats_user` WHERE `uuid`='{$uuid}';\nDELETE FROM `$dbname`.`user` WHERE `uuid`='{$uuid}';\nDELETE FROM `$dbname`.`user_iphash` WHERE `uuid`='{$uuid}';\nDELETE FROM `$dbname`.`user_snapshot` WHERE `cldbid`='{$temp_cldbid}';\n";
|
||||
enter_logfile($cfg,4,sprintf($lang['wihladm45'],$user[$uuid]['name'],$uuid,$temp_cldbid).' ('.$lang['wihladm46'].')');
|
||||
enter_logfile(4,sprintf($lang['wihladm45'],$user[$uuid]['name'],$uuid,$temp_cldbid).' ('.$lang['wihladm46'].')');
|
||||
if(isset($db_cache['all_user'][$uuid])) unset($db_cache['all_user'][$uuid]);
|
||||
if(isset($db_cache['admin_addtime'][$uuid])) unset($db_cache['admin_addtime'][$uuid]);
|
||||
if(isset($db_cache['addon_assign_groups'][$uuid])) unset($db_cache['addon_assign_groups'][$uuid]);
|
||||
@@ -55,17 +55,17 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
}
|
||||
if($isonline != 1) {
|
||||
if(($user = $mysqlcon->query("SELECT `uuid`,`cldbid` FROM `$dbname`.`user` WHERE `uuid`='{$uuid}'")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
enter_logfile($cfg,2,"Database error on selecting user (admin function remove/add time): ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"Database error on selecting user (admin function remove/add time): ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$temp_cldbid = $user[$uuid]['cldbid'];
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` SET `count`='{$db_cache['all_user'][$uuid]['count']}', `idle`='{$db_cache['all_user'][$uuid]['idle']}' WHERE `uuid`='{$uuid}';\n";
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`admin_addtime` WHERE `timestamp`=".$value['timestamp']." AND `uuid`='$uuid';") === false) {
|
||||
enter_logfile($cfg,2,"Database error on updating user (admin function remove/add time): ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"Database error on updating user (admin function remove/add time): ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if(($usersnap = $mysqlcon->query("SELECT `id`,`cldbid`,`count`,`idle` FROM `$dbname`.`user_snapshot` WHERE `cldbid`={$temp_cldbid}")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
enter_logfile($cfg,2,"Database error on selecting user (admin function remove/add time): ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"Database error on selecting user (admin function remove/add time): ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
foreach($usersnap as $id => $valuesnap) {
|
||||
$valuesnap['count'] += $value['timecount'];
|
||||
@@ -77,7 +77,7 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
$sqlexec .= "UPDATE `$dbname`.`user_snapshot` SET `count`='{$valuesnap['count']}', `idle`='{$valuesnap['idle']}' WHERE `cldbid`='{$temp_cldbid}' AND `id`='{$id}';\n";
|
||||
}
|
||||
}
|
||||
enter_logfile($cfg,4,sprintf($lang['sccupcount2'],$value['timecount'],$uuid).' ('.$lang['wihladm46'].')');
|
||||
enter_logfile(4,sprintf($lang['sccupcount2'],$value['timecount'],$uuid).' ('.$lang['wihladm46'].')');
|
||||
unset($user, $usersnap);
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
if(isset($db_cache['all_user'][$uid]['except']) && ($db_cache['all_user'][$uid]['except'] == 3 || $db_cache['all_user'][$uid]['except'] == 2) && $cfg['rankup_excepted_mode'] == 2) {
|
||||
$db_cache['all_user'][$uid]['count'] = 0;
|
||||
$db_cache['all_user'][$uid]['idle'] = 0;
|
||||
enter_logfile($cfg,5,sprintf($lang['resettime'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
enter_logfile(5,sprintf($lang['resettime'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`user_snapshot` WHERE `cldbid`='{$client['client_database_id']}';\n";
|
||||
}
|
||||
$except = 0;
|
||||
@@ -116,7 +116,7 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
if(isset($db_cache['all_user'][$uid])) {
|
||||
$idle = $db_cache['all_user'][$uid]['idle'] + $clientidle;
|
||||
if ($db_cache['all_user'][$uid]['cldbid'] != $client['client_database_id'] && $cfg['rankup_client_database_id_change_switch'] == 1) {
|
||||
enter_logfile($cfg,5,sprintf($lang['changedbid'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['all_user'][$uid]['cldbid']));
|
||||
enter_logfile(5,sprintf($lang['changedbid'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['all_user'][$uid]['cldbid']));
|
||||
$count = 1;
|
||||
$idle = 0;
|
||||
$boosttime = 0;
|
||||
@@ -135,9 +135,9 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
try {
|
||||
$ts3->serverGroupClientDel($boost['group'], $client['client_database_id']);
|
||||
$boosttime = 0;
|
||||
enter_logfile($cfg,5,sprintf($lang['sgrprm'], $db_cache['groups'][$boost['group']]['sgidname'], $boost['group'], $client['client_nickname'], $uid, $client['client_database_id']).' [Boost-Group]');
|
||||
enter_logfile(5,sprintf($lang['sgrprm'], $db_cache['groups'][$boost['group']]['sgidname'], $boost['group'], $client['client_nickname'], $uid, $client['client_database_id']).' [Boost-Group]');
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid']));
|
||||
enter_logfile(2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid']));
|
||||
$db_cache['all_user'][$uid]['grouperror'] = $nowtime;
|
||||
}
|
||||
}
|
||||
@@ -195,10 +195,10 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($db_cache['all_user'][$uid]['grpid'], $client['client_database_id']);
|
||||
enter_logfile($cfg,5,sprintf($lang['sgrprm'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
enter_logfile(5,sprintf($lang['sgrprm'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
if(isset($client_groups_rankup[$db_cache['all_user'][$uid]['grpid']])) unset($client_groups_rankup[$db_cache['all_user'][$uid]['grpid']]);
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid']));
|
||||
enter_logfile(2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$db_cache['all_user'][$uid]['grpid']]['sgidname'], $db_cache['all_user'][$uid]['grpid']));
|
||||
$db_cache['all_user'][$uid]['grouperror'] = $nowtime;
|
||||
}
|
||||
}
|
||||
@@ -208,7 +208,7 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
try {
|
||||
$ts3->serverGroupClientAdd($rank['group'], $client['client_database_id']);
|
||||
$db_cache['all_user'][$uid]['grpsince'] = $nowtime;
|
||||
enter_logfile($cfg,5,sprintf($lang['sgrpadd'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
enter_logfile(5,sprintf($lang['sgrpadd'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
if ($cfg['rankup_message_to_user_switch'] == 1) {
|
||||
$days = $dtF->diff($dtT)->format('%a');
|
||||
$hours = $dtF->diff($dtT)->format('%h');
|
||||
@@ -217,7 +217,7 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
sendmessage($ts3, $cfg, $uid, sprintf($cfg['rankup_message_to_user'],$days,$hours,$mins,$secs,$db_cache['groups'][$rank['group']]['sgidname'],$client['client_nickname']), 1, NULL, sprintf($lang['sgrprerr'], $name, $uid, $client['client_database_id'], $db_cache['groups'][$rank['group']]['sgidname'],$rank['group']), 2);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group']));
|
||||
enter_logfile(2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group']));
|
||||
$db_cache['all_user'][$uid]['grouperror'] = $nowtime;
|
||||
}
|
||||
}
|
||||
@@ -237,11 +237,15 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
try {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$ts3->serverGroupClientDel($removegroup, $client['client_database_id']);
|
||||
enter_logfile($cfg,5,sprintf("Removed WRONG servergroup %s (ID: %s) from user %s (unique Client-ID: %s; Client-database-ID %s).", $db_cache['groups'][$removegroup]['sgidname'], $removegroup, $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
enter_logfile(5,sprintf("Removed WRONG servergroup %s (ID: %s) from user %s (unique Client-ID: %s; Client-database-ID %s).", $db_cache['groups'][$removegroup]['sgidname'], $removegroup, $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$removegroup]['sgidname'], $removegroup));
|
||||
enter_logfile(2,"TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $client['client_nickname'], $uid, $client['client_database_id'], $db_cache['groups'][$removegroup]['sgidname'], $removegroup));
|
||||
$db_cache['all_user'][$uid]['grouperror'] = $nowtime;
|
||||
}
|
||||
} elseif ($cfg['rankup_excepted_remove_group_switch'] == 1 && $removegroup != NULL && $removegroup != 0 && $removegroup == $db_cache['all_user'][$uid]['grpid'] && $cfg['rankup_excepted_mode'] == 0 && ($db_cache['all_user'][$uid]['except'] == 3 || $db_cache['all_user'][$uid]['except'] == 2) && (!isset($db_cache['all_user'][$uid]['grouperror']) || $db_cache['all_user'][$uid]['grouperror'] < ($nowtime - 300))) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$ts3->serverGroupClientDel($removegroup, $client['client_database_id']);
|
||||
enter_logfile(5,sprintf("Removed servergroup %s (ID: %s) cause EXCEPTED (%s) from user %s (unique Client-ID: %s; Client-database-ID %s).", $db_cache['groups'][$removegroup]['sgidname'], $removegroup, exception_client_code($db_cache['all_user'][$uid]['except']), $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
}
|
||||
}
|
||||
unset($client_groups_rankup);
|
||||
@@ -302,7 +306,7 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
$db_cache['all_user'][$uid]['boosttime'] = 0;
|
||||
$db_cache['all_user'][$uid]['grpsince'] = 0;
|
||||
$db_cache['all_user'][$uid]['except'] = $except;
|
||||
enter_logfile($cfg,5,sprintf($lang['adduser'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
enter_logfile(5,sprintf($lang['adduser'], $client['client_nickname'], $uid, $client['client_database_id']));
|
||||
}
|
||||
$db_cache['all_user'][$uid]['name'] = $client['client_nickname'];
|
||||
$db_cache['all_user'][$uid]['lastseen'] = $nowtime;
|
||||
@@ -335,7 +339,7 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
unset($insertdata, $sqlinsertvalues);
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"calc_user needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"calc_user needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
?>
|
||||
@@ -6,9 +6,9 @@ function calc_user_snapshot($cfg,$dbname,&$db_cache) {
|
||||
|
||||
// Event Handling each 6 hours
|
||||
// Duplicate users Table in snapshot Table
|
||||
if(($nowtime - $db_cache['job_check']['last_snapshot_time']['timestamp']) > 21600) {
|
||||
if(($nowtime - intval($db_cache['job_check']['last_snapshot_time']['timestamp'])) > 21600) {
|
||||
if(isset($db_cache['all_user'])) {
|
||||
$db_cache['job_check']['last_snapshot_id']['timestamp'] = $nextid = $db_cache['job_check']['last_snapshot_id']['timestamp'] + 1;
|
||||
$db_cache['job_check']['last_snapshot_id']['timestamp'] = $nextid = intval($db_cache['job_check']['last_snapshot_id']['timestamp']) + 1;
|
||||
if ($nextid > 121) $nextid = $nextid - 121;
|
||||
|
||||
$allinsertsnap = '';
|
||||
@@ -25,6 +25,6 @@ function calc_user_snapshot($cfg,$dbname,&$db_cache) {
|
||||
}
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"calc_user_snapshot needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"calc_user_snapshot needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
<?PHP
|
||||
function calc_userstats($ts3,$mysqlcon,&$cfg,$dbname,&$db_cache) {
|
||||
function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,&$db_cache) {
|
||||
$starttime = microtime(true);
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
$job_begin = $db_cache['job_check']['calc_user_limit']['timestamp'];
|
||||
$job_begin = intval($db_cache['job_check']['calc_user_limit']['timestamp']);
|
||||
|
||||
$limit_calc = ceil(count($db_cache['all_user']) / 600);
|
||||
if($limit_calc < 5) $limit_calc = 5;
|
||||
@@ -23,29 +23,42 @@ function calc_userstats($ts3,$mysqlcon,&$cfg,$dbname,&$db_cache) {
|
||||
$cldbids .= $userstats['cldbid'].',';
|
||||
}
|
||||
$cldbids = substr($cldbids, 0, -1);
|
||||
|
||||
$weekago = $db_cache['job_check']['last_snapshot_id']['timestamp'] - 28;
|
||||
$monthago = $db_cache['job_check']['last_snapshot_id']['timestamp'] - 120;
|
||||
|
||||
$dayago = intval($db_cache['job_check']['last_snapshot_id']['timestamp']) - 4;
|
||||
$weekago = intval($db_cache['job_check']['last_snapshot_id']['timestamp']) - 28;
|
||||
$monthago = intval($db_cache['job_check']['last_snapshot_id']['timestamp']) - 120;
|
||||
if ($dayago < 1) $dayago += 121;
|
||||
if ($weekago < 1) $weekago += 121;
|
||||
if ($monthago < 1) $monthago += 121;
|
||||
|
||||
if(isset($sqlhis) && $sqlhis != NULL) {
|
||||
enter_logfile($cfg,6,"Update User Stats between ".$job_begin." and ".$job_end.":");
|
||||
if(($userdata = $mysqlcon->query("SELECT `cldbid`,`id`,`count`,`idle` FROM `$dbname`.`user_snapshot` WHERE `id` IN ({$db_cache['job_check']['last_snapshot_id']['timestamp']},{$weekago},{$monthago}) AND `cldbid` IN ($cldbids)")->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,2,"calc_userstats 6:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(6,"Update User Stats between ".$job_begin." and ".$job_end.":");
|
||||
if(($userdata = $mysqlcon->query("SELECT `cldbid`,`id`,`count`,`idle` FROM `$dbname`.`user_snapshot` WHERE `id` IN ({$db_cache['job_check']['last_snapshot_id']['timestamp']},{$dayago},{$weekago},{$monthago}) AND `cldbid` IN ($cldbids)")->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile(2,"calc_userstats 6:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$allupdateuuid = '';
|
||||
|
||||
foreach ($sqlhis as $uuid => $userstats) {
|
||||
if($userstats['lastseen'] > ($nowtime - 2678400)) {
|
||||
check_shutdown($cfg); usleep($cfg['teamspeak_query_command_delay']);
|
||||
check_shutdown(); usleep($cfg['teamspeak_query_command_delay']);
|
||||
|
||||
if(isset($userdata[$userstats['cldbid']]) && $userdata[$userstats['cldbid']] != NULL) {
|
||||
$keybase = array_search($db_cache['job_check']['last_snapshot_id']['timestamp'], array_column($userdata[$userstats['cldbid']], 'id'));
|
||||
$keyday = array_search($dayago, array_column($userdata[$userstats['cldbid']], 'id'));
|
||||
$keyweek = array_search($weekago, array_column($userdata[$userstats['cldbid']], 'id'));
|
||||
$keymonth = array_search($monthago, array_column($userdata[$userstats['cldbid']], 'id'));
|
||||
|
||||
if(isset($userdata[$userstats['cldbid']]) && isset($userdata[$userstats['cldbid']][$keyday]) && $userdata[$userstats['cldbid']][$keyday]['id'] == $dayago) {
|
||||
$count_day = $userdata[$userstats['cldbid']][$keybase]['count'] - $userdata[$userstats['cldbid']][$keyday]['count'];
|
||||
$idle_day = $userdata[$userstats['cldbid']][$keybase]['idle'] - $userdata[$userstats['cldbid']][$keyday]['idle'];
|
||||
$active_day = $count_day - $idle_day;
|
||||
if($count_day < 0 || $count_day < $idle_day) $count_day = 0;
|
||||
if($idle_day < 0 || $count_day < $idle_day) $idle_day = 0;
|
||||
if($active_day < 0 || $count_day < $idle_day) $active_day = 0;
|
||||
} else {
|
||||
$count_day = $idle_day = $active_day = 0;
|
||||
}
|
||||
if(isset($userdata[$userstats['cldbid']]) && isset($userdata[$userstats['cldbid']][$keyweek]) && $userdata[$userstats['cldbid']][$keyweek]['id'] == $weekago) {
|
||||
$count_week = $userdata[$userstats['cldbid']][$keybase]['count'] - $userdata[$userstats['cldbid']][$keyweek]['count'];
|
||||
$idle_week = $userdata[$userstats['cldbid']][$keybase]['idle'] - $userdata[$userstats['cldbid']][$keyweek]['idle'];
|
||||
@@ -67,7 +80,7 @@ function calc_userstats($ts3,$mysqlcon,&$cfg,$dbname,&$db_cache) {
|
||||
$count_month = $idle_month = $active_month = 0;
|
||||
}
|
||||
} else {
|
||||
$count_week = $idle_week = $active_week = $count_month = $idle_month = $active_month = 0;
|
||||
$count_day = $idle_day = $active_day = $count_week = $idle_week = $active_week = $count_month = $idle_month = $active_month = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -80,15 +93,15 @@ function calc_userstats($ts3,$mysqlcon,&$cfg,$dbname,&$db_cache) {
|
||||
if($clientinfo['client_totalconnections'] > 16777215) $clientinfo['client_totalconnections'] = 16777215;
|
||||
} catch (Exception $e) {
|
||||
if($e->getCode() == 512 || $e->getCode() == 1281) {
|
||||
enter_logfile($cfg,6,"Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") known by Ranksystem is missing in TS database, perhaps its already deleted or cldbid changed. Try to search for client by uuid.");
|
||||
enter_logfile(6,"Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") known by Ranksystem is missing in TS database, perhaps its already deleted or cldbid changed. Try to search for client by uuid.");
|
||||
try {
|
||||
$getcldbid = $ts3->clientFindDb($uuid, TRUE);
|
||||
if($getcldbid[0] != $userstats['cldbid']) {
|
||||
enter_logfile($cfg,4," Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") known by the Ranksystem changed its cldbid. New cldbid is ".$getcldbid[0].".");
|
||||
enter_logfile(4," Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") known by the Ranksystem changed its cldbid. New cldbid is ".$getcldbid[0].".");
|
||||
$db_cache['all_user'][$uuid]['cldbid'] = $getcldbid[0];
|
||||
if($cfg['rankup_client_database_id_change_switch'] == 1) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` SET `count`=0,`idle`=0 WHERE `uuid`='$uuid';\nUPDATE `$dbname`.`stats_user` SET `count_week`=0,`count_month`=0,`idle_week`=0,`idle_month`=0,`active_week`=0,`active_month`=0 WHERE `uuid`='$uuid';\nDELETE FROM `$dbname`.`user_snapshot` WHERE `cldbid`='{$userstats['cldbid']}';\n";
|
||||
enter_logfile($cfg,4," ".sprintf($lang['changedbid'], $userstats['name'], $uuid, $userstats['cldbid'], $getcldbid[0]));
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` SET `count`=0,`idle`=0 WHERE `uuid`='$uuid';\nUPDATE `$dbname`.`stats_user` SET `count_day`=0,`count_week`=0,`count_month`=0,`idle_day`=0,`idle_week`=0,`idle_month`=0,`active_day`=0,`active_week`=0,`active_month`=0 WHERE `uuid`='$uuid';\nDELETE FROM `$dbname`.`user_snapshot` WHERE `cldbid`='{$userstats['cldbid']}';\n";
|
||||
enter_logfile(4," ".sprintf($lang['changedbid'], $userstats['name'], $uuid, $userstats['cldbid'], $getcldbid[0]));
|
||||
} else {
|
||||
$sqlexec .= "UPDATE `$dbname`.`user` SET `cldbid`={$getcldbid[0]} WHERE `uuid`='$uuid';\n";
|
||||
// select current user_snapshot entries and insert this with the new database-ID
|
||||
@@ -103,49 +116,49 @@ function calc_userstats($ts3,$mysqlcon,&$cfg,$dbname,&$db_cache) {
|
||||
}
|
||||
unset($allinsert);
|
||||
}
|
||||
enter_logfile($cfg,4," Store new cldbid ".$getcldbid[0]." for client (uuid: ".$uuid." old cldbid: ".$userstats['cldbid'].")");
|
||||
enter_logfile(4," Store new cldbid ".$getcldbid[0]." for client (uuid: ".$uuid." old cldbid: ".$userstats['cldbid'].")");
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,3," Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") is missing in TS database, but TeamSpeak answers on question with the same cldbid (".$getcldbid[0].").. It's weird!");
|
||||
enter_logfile(3," Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") is missing in TS database, but TeamSpeak answers on question with the same cldbid (".$getcldbid[0].").. It's weird!");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
if($e->getCode() == 2568) {
|
||||
enter_logfile($cfg,4,$e->getCode() . ': ' . $e->getMessage()."; Error due command clientdbfind (permission: b_virtualserver_client_dbsearch needed).");
|
||||
enter_logfile(4,$e->getCode() . ': ' . $e->getMessage()."; Error due command clientdbfind (permission: b_virtualserver_client_dbsearch needed).");
|
||||
} else {
|
||||
enter_logfile($cfg,6,$e->getCode() . ': ' . $e->getMessage()."; Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") is missing in TS database, it seems to be deleted. Run the !clean command to correct this.");
|
||||
$sqlexec .= "UPDATE `$dbname`.`stats_user` SET `count_week`=0,`count_month`=0,`idle_week`=0,`idle_month`=0,`active_week`=0,`active_month`=0,`removed`=1 WHERE `uuid`='$uuid';\n";
|
||||
enter_logfile(6,$e->getCode() . ': ' . $e->getMessage()."; Client (uuid: ".$uuid." cldbid: ".$userstats['cldbid'].") is missing in TS database, it seems to be deleted. Run the !clean command to correct this.");
|
||||
$sqlexec .= "UPDATE `$dbname`.`stats_user` SET `count_day`=0,`count_week`=0,`count_month`=0,`idle_day`=0,`idle_week`=0,`idle_month`=0,`active_day`=0,`active_week`=0,`active_month`=0,`removed`=1 WHERE `uuid`='$uuid';\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.$e->getMessage()."; Error due command clientdbinfo for client-database-ID {$userstats['cldbid']} (permission: b_virtualserver_client_dbinfo needed).");
|
||||
enter_logfile(2,$lang['errorts3'].$e->getCode().': '.$e->getMessage()."; Error due command clientdbinfo for client-database-ID {$userstats['cldbid']} (permission: b_virtualserver_client_dbinfo needed).");
|
||||
}
|
||||
|
||||
$clientdesc = $clientinfo['client_base64HashClientUID'] = "NULL";
|
||||
$clientinfo['client_totalconnections'] = $clientinfo['client_total_bytes_uploaded'] = $clientinfo['client_total_bytes_downloaded'] = 0;
|
||||
}
|
||||
|
||||
$allupdateuuid .= "('$uuid',$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,$nowtime),";
|
||||
$allupdateuuid .= "('$uuid',$count_day,$count_week,$count_month,$idle_day,$idle_week,$idle_month,$active_day,$active_week,$active_month,{$clientinfo['client_totalconnections']},'{$clientinfo['client_base64HashClientUID']}',{$clientinfo['client_total_bytes_uploaded']},{$clientinfo['client_total_bytes_downloaded']},$clientdesc,$nowtime),";
|
||||
}
|
||||
}
|
||||
unset($sqlhis,$userdataweekbegin,$userdataend,$userdatamonthbegin,$clientinfo,$count_week,$idle_week,$active_week,$count_month,$idle_month,$active_month,$clientdesc);
|
||||
unset($sqlhis,$userdataweekbegin,$userdataend,$userdatamonthbegin,$clientinfo,$count_day,$idle_day,$active_day,$count_week,$idle_week,$active_week,$count_month,$idle_month,$active_month,$clientdesc);
|
||||
|
||||
$db_cache['job_check']['calc_user_limit']['timestamp'] = $job_end;
|
||||
if ($allupdateuuid != '') {
|
||||
$allupdateuuid = substr($allupdateuuid, 0, -1);
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$job_end WHERE `job_name`='calc_user_limit';\nINSERT INTO `$dbname`.`stats_user` (`uuid`,`count_week`,`count_month`,`idle_week`,`idle_month`,`active_week`,`active_month`,`total_connections`,`base64hash`,`client_total_up`,`client_total_down`,`client_description`,`last_calculated`) VALUES $allupdateuuid ON DUPLICATE KEY UPDATE `count_week`=VALUES(`count_week`),`count_month`=VALUES(`count_month`),`idle_week`=VALUES(`idle_week`),`idle_month`=VALUES(`idle_month`),`active_week`=VALUES(`active_week`),`active_month`=VALUES(`active_month`),`total_connections`=VALUES(`total_connections`),`base64hash`=VALUES(`base64hash`),`client_total_up`=VALUES(`client_total_up`),`client_total_down`=VALUES(`client_total_down`),`client_description`=VALUES(`client_description`),`last_calculated`=VALUES(`last_calculated`);\n";
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$job_end WHERE `job_name`='calc_user_limit';\nINSERT INTO `$dbname`.`stats_user` (`uuid`,`count_day`,`count_week`,`count_month`,`idle_day`,`idle_week`,`idle_month`,`active_day`,`active_week`,`active_month`,`total_connections`,`base64hash`,`client_total_up`,`client_total_down`,`client_description`,`last_calculated`) VALUES $allupdateuuid ON DUPLICATE KEY UPDATE `count_day`=VALUES(`count_day`),`count_week`=VALUES(`count_week`),`count_month`=VALUES(`count_month`),`idle_day`=VALUES(`idle_day`),`idle_week`=VALUES(`idle_week`),`idle_month`=VALUES(`idle_month`),`active_day`=VALUES(`active_day`),`active_week`=VALUES(`active_week`),`active_month`=VALUES(`active_month`),`total_connections`=VALUES(`total_connections`),`base64hash`=VALUES(`base64hash`),`client_total_up`=VALUES(`client_total_up`),`client_total_down`=VALUES(`client_total_down`),`client_description`=VALUES(`client_description`),`last_calculated`=VALUES(`last_calculated`);\n";
|
||||
unset($allupdateuuid);
|
||||
} else {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$job_end WHERE `job_name`='calc_user_limit';\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($db_cache['job_check']['calc_user_removed']['timestamp'] < ($nowtime - 1800)) {
|
||||
if (intval($db_cache['job_check']['calc_user_removed']['timestamp']) < ($nowtime - 1800)) {
|
||||
$db_cache['job_check']['calc_user_removed']['timestamp'] = $nowtime;
|
||||
$atime = $nowtime - 3600;
|
||||
$sqlexec .= "UPDATE `$dbname`.`stats_user` AS `s` INNER JOIN `$dbname`.`user` AS `u` ON `s`.`uuid`=`u`.`uuid` SET `s`.`removed`='0' WHERE `s`.`removed`='1' AND `u`.`lastseen`>{$atime};\nUPDATE `$dbname`.`job_check` SET `timestamp`='{$nowtime}' WHERE `job_name`='calc_user_removed';\n";
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"calc_userstats needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"calc_userstats needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
?>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?PHP
|
||||
function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
$cfg['version_latest_available'] = '1.3.21';
|
||||
enter_logfile($cfg,5,"Check Ranksystem database for updates...");
|
||||
$cfg['version_latest_available'] = '1.3.22';
|
||||
enter_logfile(5,"Check Ranksystem database for updates...");
|
||||
|
||||
function check_double_cldbid($mysqlcon,$cfg,$dbname) {
|
||||
$maxcldbid = $mysqlcon->query("SELECT MAX(`cldbid`) AS `cldbid` FROM `$dbname`.`user`")->fetchAll(PDO::FETCH_ASSOC);
|
||||
@@ -17,9 +17,9 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
$updatecldbid = $mysqlcon->query("SELECT `cldbid`,`uuid`,`name`,`lastseen` FROM `$dbname`.`user` WHERE `cldbid` in ({$doublecldbid})")->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach($updatecldbid as $row) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`user` SET `cldbid`='{$maxcldbid}' WHERE `uuid`='{$row['uuid']}'") === false) {
|
||||
enter_logfile($cfg,1," Repair double client-database-ID failed (".$row['uuid']."): ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(1," Repair double client-database-ID failed (".$row['uuid']."): ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
enter_logfile($cfg,4," Repair double client-database-ID for ".$row['name']." (".$row['uuid']."); old ID ".$row['cldbid']."; set virtual ID $maxcldbid");
|
||||
enter_logfile(4," Repair double client-database-ID for ".$row['name']." (".$row['uuid']."); old ID ".$row['cldbid']."; set virtual ID $maxcldbid");
|
||||
}
|
||||
$maxcldbid++;
|
||||
}
|
||||
@@ -29,11 +29,11 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
|
||||
function set_new_version($mysqlcon,$cfg,$dbname) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('version_current_using','{$cfg['version_latest_available']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) {
|
||||
enter_logfile($cfg,1," An error happens due updating the Ranksystem Database:".print_r($mysqlcon->errorInfo(), true));
|
||||
shutdown($mysqlcon,$cfg,1," Check the database connection and properties in other/dbconfig.php and check also the database permissions.");
|
||||
enter_logfile(1," An error happens due updating the Ranksystem Database:".print_r($mysqlcon->errorInfo(), true));
|
||||
shutdown($mysqlcon,1," Check the database connection and properties in other/dbconfig.php and check also the database permissions.");
|
||||
} else {
|
||||
$cfg['version_current_using'] = $cfg['version_latest_available'];
|
||||
enter_logfile($cfg,4," Database successfully updated!");
|
||||
enter_logfile(4," Database successfully updated!");
|
||||
return $cfg;
|
||||
}
|
||||
}
|
||||
@@ -48,58 +48,58 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
rmdir_recursive($folder.$file);
|
||||
} else {
|
||||
if(!unlink($folder.$file)) {
|
||||
enter_logfile($cfg,4,"Unnecessary file, please delete it from your webserver: ".$folder.$file);
|
||||
enter_logfile(4,"Unnecessary file, please delete it from your webserver: ".$folder.$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!rmdir($folder)) {
|
||||
enter_logfile($cfg,4,"Unnecessary folder, please delete it from your webserver: ".$folder);
|
||||
enter_logfile(4,"Unnecessary folder, please delete it from your webserver: ".$folder);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($del_folder as $folder) {
|
||||
if(is_dir(substr(__DIR__,0,-4).$folder)) {
|
||||
rmdir_recursive(substr(__DIR__,0,-4).$folder,$cfg);
|
||||
if(is_dir(dirname(__DIR__).DIRECTORY_SEPARATOR.$folder)) {
|
||||
rmdir_recursive(dirname(__DIR__).DIRECTORY_SEPARATOR.$folder,$cfg);
|
||||
}
|
||||
}
|
||||
foreach($del_files as $file) {
|
||||
if(is_file(substr(__DIR__,0,-4).$file)) {
|
||||
if(!unlink(substr(__DIR__,0,-4).$file)) {
|
||||
enter_logfile($cfg,4,"Unnecessary file, please delete it from your webserver: ".$file);
|
||||
if(is_file(dirname(__DIR__).DIRECTORY_SEPARATOR.$file)) {
|
||||
if(!unlink(dirname(__DIR__).DIRECTORY_SEPARATOR.$file)) {
|
||||
enter_logfile(4,"Unnecessary file, please delete it from your webserver: ".$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function check_writable($cfg,$mysqlcon) {
|
||||
enter_logfile($cfg,5," Check files permissions...");
|
||||
enter_logfile(5," Check files permissions...");
|
||||
$counterr=0;
|
||||
try {
|
||||
$scandir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(substr(__DIR__,0,-4)));
|
||||
$scandir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__DIR__)));
|
||||
$files = array();
|
||||
foreach ($scandir as $object) {
|
||||
if(!strstr($object, '/.') && !strstr($object, '\.')) {
|
||||
if (!$object->isDir()) {
|
||||
if(!is_writable($object->getPathname())) {
|
||||
enter_logfile($cfg,3," File is not writeable ".$object);
|
||||
enter_logfile(3," File is not writeable ".$object);
|
||||
$counterr++;
|
||||
}
|
||||
} else {
|
||||
if(!is_writable($object->getPathname())) {
|
||||
enter_logfile($cfg,3," Folder is not writeable ".$object);
|
||||
enter_logfile(3," Folder is not writeable ".$object);
|
||||
$counterr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
shutdown($mysqlcon,$cfg,1,"File Permissions Error: ".$e->getCode()." ".$e->getMessage());
|
||||
enter_logfile($cfg,3,"File Permissions Error: ".$e->getCode()." ".$e->getMessage());
|
||||
shutdown($mysqlcon,1,"File Permissions Error: ".$e->getCode()." ".$e->getMessage());
|
||||
enter_logfile(3,"File Permissions Error: ".$e->getCode()." ".$e->getMessage());
|
||||
}
|
||||
if($counterr!=0) {
|
||||
shutdown($mysqlcon,$cfg,1,"Wrong file/folder permissions (see messages before!)! Check and correct the owner (chown) and access permissions (chmod)!");
|
||||
shutdown($mysqlcon,1,"Wrong file/folder permissions (see messages before!)! Check and correct the owner (chown) and access permissions (chmod)!");
|
||||
} else {
|
||||
enter_logfile($cfg,5," Check files permissions [done]");
|
||||
enter_logfile(5," Check files permissions [done]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,153 +108,153 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
check_double_cldbid($mysqlcon,$cfg,$dbname);
|
||||
|
||||
if($cfg['version_current_using'] == $cfg['version_latest_available']) {
|
||||
enter_logfile($cfg,5," No newer version detected; Database check finished.");
|
||||
enter_logfile(5," No newer version detected; Database check finished.");
|
||||
} else {
|
||||
enter_logfile($cfg,4," Update the Ranksystem Database to new version...");
|
||||
enter_logfile(4," Update the Ranksystem Database to new version...");
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.0', '<')) {
|
||||
shutdown($mysqlcon,$cfg,1,"Your Ranksystem version is below 1.3.0. Please download the current version from the official page and install a new Ranksystem instead or contact the Ranksystem support.");
|
||||
shutdown($mysqlcon,1,"Your Ranksystem version is below 1.3.0. Please download the current version from the official page and install a new Ranksystem instead or contact the Ranksystem support.");
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.1', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('reset_user_time', '0'),('reset_user_delete', '0'),('reset_group_withdraw', '0'),('reset_webspace_cache', '0'),('reset_usage_graph', '0'),('reset_stop_after', '0');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.1] Added new job_check values.");
|
||||
enter_logfile(4," [1.3.1] Added new job_check values.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.4', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_show_maxclientsline_switch', 0)") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.4] Added new config values.");
|
||||
enter_logfile(4," [1.3.4] Added new config values.");
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`groups` MODIFY COLUMN `sgidname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.4] Adjusted table groups successfully.");
|
||||
enter_logfile(4," [1.3.4] Adjusted table groups successfully.");
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`user` MODIFY COLUMN `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.4] Adjusted table user successfully.");
|
||||
enter_logfile(4," [1.3.4] Adjusted table user successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='".time()."' WHERE `job_name`='last_update';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.4] Stored timestamp of last update successfully.");
|
||||
enter_logfile(4," [1.3.4] Stored timestamp of last update successfully.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.7', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_fresh_installation', '0'),('webinterface_advanced_mode', '1')") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.7] Added new config values.");
|
||||
enter_logfile(4," [1.3.7] Added new config values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`groups`;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.7] Empty table groups successfully.");
|
||||
enter_logfile(4," [1.3.7] Empty table groups successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`groups` ADD COLUMN `sortid` int(10) NOT NULL default '0', ADD COLUMN `type` tinyint(1) NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.7] Adjusted table groups successfully.");
|
||||
enter_logfile(4," [1.3.7] Adjusted table groups successfully.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.8', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_api_keys', '');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Added new config values.");
|
||||
enter_logfile(4," [1.3.8] Added new config values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`user` MODIFY COLUMN `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci, MODIFY COLUMN `lastseen` int(10) UNSIGNED NOT NULL default '0', MODIFY COLUMN `boosttime` int(10) UNSIGNED NOT NULL default '0', MODIFY COLUMN `firstcon` int(10) UNSIGNED NOT NULL default '0', MODIFY COLUMN `grpsince` int(10) UNSIGNED NOT NULL default '0', MODIFY COLUMN `rank` smallint(5) UNSIGNED NOT NULL default '65535', MODIFY COLUMN `nation` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table user successfully (part 1).");
|
||||
enter_logfile(4," [1.3.8] Adjusted table user successfully (part 1).");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`user` MODIFY COLUMN `count` DECIMAL(14,3) NOT NULL default '0', MODIFY COLUMN `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, MODIFY COLUMN `idle` DECIMAL(14,3) NOT NULL default '0', MODIFY COLUMN `platform` varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, MODIFY COLUMN `nation` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, MODIFY COLUMN `version` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table user successfully (part 2).");
|
||||
enter_logfile(4," [1.3.8] Adjusted table user successfully (part 2).");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`user_snapshot` MODIFY COLUMN `timestamp` int(10) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table user_snapshot successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table user_snapshot successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_user` MODIFY COLUMN `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci, MODIFY COLUMN `base64hash` char(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci, MODIFY COLUMN `count_week` mediumint(8) UNSIGNED NOT NULL default '0', MODIFY COLUMN `count_month` mediumint(8) UNSIGNED NOT NULL default '0', MODIFY COLUMN `idle_week` mediumint(8) UNSIGNED NOT NULL default '0', MODIFY COLUMN `idle_month` mediumint(8) UNSIGNED NOT NULL default '0', MODIFY COLUMN `active_week` mediumint(8) UNSIGNED NOT NULL default '0', MODIFY COLUMN `active_month` mediumint(8) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table stats_user (part 1) successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table stats_user (part 1) successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_user` DROP COLUMN `rank`, DROP COLUMN `battles_total`, DROP COLUMN `battles_won`, DROP COLUMN `battles_lost`, DROP COLUMN `achiev_time`, DROP COLUMN `achiev_connects`, DROP COLUMN `achiev_battles`, DROP COLUMN `achiev_time_perc`, DROP COLUMN `achiev_connects_perc`, DROP COLUMN `achiev_battles_perc`;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table stats_user (part 2) successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table stats_user (part 2) successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_user` MODIFY COLUMN `base64hash` char(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table stats_user (part 3) successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table stats_user (part 3) successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`server_usage` MODIFY COLUMN `timestamp` int(10) UNSIGNED NOT NULL default '0', MODIFY COLUMN `clients` smallint(5) UNSIGNED NOT NULL default '0', MODIFY COLUMN `channel` smallint(5) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table server_usage successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table server_usage successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`job_check` MODIFY COLUMN `timestamp` int(10) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table job_check successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table job_check successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`admin_addtime` MODIFY COLUMN `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci, MODIFY COLUMN `timestamp` int(10) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table admin_addtime successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table admin_addtime successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`user_iphash` MODIFY COLUMN `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table user_iphash successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table user_iphash successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_versions` MODIFY COLUMN `count` smallint(5) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table stats_versions successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table stats_versions successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_platforms` MODIFY COLUMN `count` smallint(5) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table stats_platforms successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table stats_platforms successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_nations` MODIFY COLUMN `nation` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci, MODIFY COLUMN `count` smallint(5) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table stats_nations successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table stats_nations successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`groups` ADD COLUMN `ext` char(3) CHARACTER SET utf8 COLLATE utf8_unicode_ci;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table groups (part 1) successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table groups (part 1) successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`groups` MODIFY COLUMN `sgid` int(10) UNSIGNED NOT NULL default '0', MODIFY COLUMN `icondate` int(10) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table groups (part 2) successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table groups (part 2) successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`groups` MODIFY COLUMN `sgidname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table groups (part 3) successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table groups (part 3) successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`csrf_token` MODIFY COLUMN `timestamp` int(10) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table csrf_token successfully (part 1).");
|
||||
enter_logfile(4," [1.3.8] Adjusted table csrf_token successfully (part 1).");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`csrf_token` MODIFY COLUMN `sessionid` varchar(128) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table csrf_token successfully (part 2).");
|
||||
enter_logfile(4," [1.3.8] Adjusted table csrf_token successfully (part 2).");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`addon_assign_groups` MODIFY COLUMN `uuid` char(28) CHARACTER SET utf8 COLLATE utf8_unicode_ci;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Adjusted table addon_assign_groups successfully.");
|
||||
enter_logfile(4," [1.3.8] Adjusted table addon_assign_groups successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`groups`;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Empty table groups successfully.");
|
||||
enter_logfile(4," [1.3.8] Empty table groups successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`user` SET `idle`=0 WHERE `idle`<0; UPDATE `$dbname`.`user` SET `count`=`idle` WHERE `count`<0;") === false) { } else {
|
||||
enter_logfile($cfg,6," [1.3.8] Fix for negative values in table user.");
|
||||
enter_logfile(6," [1.3.8] Fix for negative values in table user.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`user_snapshot` SET `idle`=0 WHERE `idle`<0; UPDATE `$dbname`.`user_snapshot` SET `count`=`idle` WHERE `count`<0;") === false) { } else {
|
||||
enter_logfile($cfg,6," [1.3.8] Fix for negative values in table user_snapshot.");
|
||||
enter_logfile(6," [1.3.8] Fix for negative values in table user_snapshot.");
|
||||
}
|
||||
|
||||
$check_snapshot_convert = $mysqlcon->query("DESC `$dbname`.`user_snapshot`")->fetchAll(PDO::FETCH_ASSOC);
|
||||
if($check_snapshot_convert[0]['Field'] == 'timestamp' && $check_snapshot_convert[0]['Field'] != 'id') {
|
||||
|
||||
if($mysqlcon->exec("DELETE `a` FROM `$dbname`.`user_snapshot` AS `a` CROSS JOIN(SELECT DISTINCT(`timestamp`) FROM `$dbname`.`user_snapshot` ORDER BY `timestamp` DESC LIMIT 1000 OFFSET 121) AS `b` WHERE `a`.`timestamp`=`b`.`timestamp`;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Deleted old values out of the table user_snapshot.");
|
||||
enter_logfile(4," [1.3.8] Deleted old values out of the table user_snapshot.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE `$dbname`.`user_snapshot2` (`id` tinyint(3) UNSIGNED NOT NULL default '0',`cldbid` int(10) UNSIGNED NOT NULL default '0',`count` int(10) UNSIGNED NOT NULL default '0',`idle` int(10) UNSIGNED NOT NULL default '0',PRIMARY KEY (`id`,`cldbid`));") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Created new table user_snapshot2 successfully.");
|
||||
enter_logfile($cfg,4," [1.3.8] Beginn with converting values.. This could take a while! Please do NOT stop the Bot!");
|
||||
enter_logfile(4," [1.3.8] Created new table user_snapshot2 successfully.");
|
||||
enter_logfile(4," [1.3.8] Beginn with converting values.. This could take a while! Please do NOT stop the Bot!");
|
||||
}
|
||||
|
||||
$maxvalues = $mysqlcon->query("SELECT COUNT(*) FROM `$dbname`.`user_snapshot`;")->fetch();
|
||||
@@ -286,7 +286,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
|
||||
$sqlinsertvalues = substr($sqlinsertvalues, 0, -1);
|
||||
if ($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`user_snapshot2` (`id`,`cldbid`,`count`,`idle`) VALUES {$sqlinsertvalues};") === false) {
|
||||
enter_logfile($cfg,1," Insert failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(1," Insert failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
unset($snapshot, $sqlinsertvalues);
|
||||
if (($offset + 50000) > $maxvalues[0]) {
|
||||
@@ -294,39 +294,39 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
} else {
|
||||
$convertedvalus = $offset + 50000;
|
||||
}
|
||||
enter_logfile($cfg,4," [1.3.8] Converted ".$convertedvalus." out of ".$maxvalues[0]." values.");
|
||||
enter_logfile(4," [1.3.8] Converted ".$convertedvalus." out of ".$maxvalues[0]." values.");
|
||||
}
|
||||
|
||||
enter_logfile($cfg,4," [1.3.8] Finished converting values");
|
||||
enter_logfile(4," [1.3.8] Finished converting values");
|
||||
|
||||
$lastsnapshot = $mysqlcon->query("SELECT MAX(`timestamp`) AS `timestamp` FROM `$dbname`.`user_snapshot`")->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if($mysqlcon->exec("DROP TABLE `$dbname`.`user_snapshot`;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Dropped old table user_snapshot successfully.");
|
||||
enter_logfile(4," [1.3.8] Dropped old table user_snapshot successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("RENAME TABLE `$dbname`.`user_snapshot2` TO `$dbname`.`user_snapshot`;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Renamed table user_snapshot2 to user_snapshot successfully.");
|
||||
enter_logfile(4," [1.3.8] Renamed table user_snapshot2 to user_snapshot successfully.");
|
||||
}
|
||||
|
||||
$currentid = count($timestamps);
|
||||
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('last_snapshot_id', '{$currentid}'),('last_snapshot_time', '{$lastsnapshot[0]['timestamp']}');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Added new job_check values (part 1).");
|
||||
enter_logfile(4," [1.3.8] Added new job_check values (part 1).");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('update_groups', '0');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.8] Added new job_check values (part 2).");
|
||||
enter_logfile(4," [1.3.8] Added new job_check values (part 2).");
|
||||
}
|
||||
|
||||
} else {
|
||||
enter_logfile($cfg,4," [1.3.8] Converting user_snapshot already done. Did not started it again.");
|
||||
enter_logfile(4," [1.3.8] Converting user_snapshot already done. Did not started it again.");
|
||||
}
|
||||
|
||||
foreach(scandir(substr(dirname(__FILE__),0,-4).'tsicons/') as $file) {
|
||||
if (in_array($file, array('.','..','check.png','placeholder.png','rs.png','servericon.png','100.png','200.png','300.png','500.png','600.png'))) continue;
|
||||
if(!unlink(substr(dirname(__FILE__),0,-4).'tsicons/'.$file)) {
|
||||
enter_logfile($cfg,4,"Unnecessary file, please delete it from your webserver: tsicons/".$file);
|
||||
enter_logfile(4,"Unnecessary file, please delete it from your webserver: tsicons/".$file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,22 +335,22 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.9', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('get_avatars', '0'),('calc_donut_chars', '0'),('reload_trigger', '0');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.9] Added new job_check values.");
|
||||
enter_logfile(4," [1.3.9] Added new job_check values.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.10', '<')) {
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_user` ADD COLUMN `last_calculated` int(10) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.10] Added new stats_user values.");
|
||||
enter_logfile(4," [1.3.10] Added new stats_user values.");
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_user` MODIFY COLUMN `total_connections` MEDIUMINT(8) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.10] Adjusted table stats_user successfully.");
|
||||
enter_logfile(4," [1.3.10] Adjusted table stats_user successfully.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.11', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('assign_groups_excepted_groupids','');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.11] Adjusted table addons_config successfully.");
|
||||
enter_logfile(4," [1.3.11] Adjusted table addons_config successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE INDEX `snapshot_id` ON `$dbname`.`user_snapshot` (`id`)") === false) { }
|
||||
@@ -363,7 +363,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.12', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_imprint_switch', '0'),('stats_imprint_address', 'Max Mustermann<br>Musterstraße 13<br>05172 Musterhausen<br>Germany'),('stats_imprint_address_url', 'https://site.url/imprint/'), ('stats_imprint_email', 'info@example.com'),('stats_imprint_phone', '+49 171 1234567'),('stats_imprint_notes', NULL),('stats_imprint_privacypolicy', 'Add your own privacy policy here. (editable in the webinterface)'),('stats_imprint_privacypolicy_url', 'https://site.url/privacy/');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.12] Added new imprint values.");
|
||||
enter_logfile(4," [1.3.12] Added new imprint values.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`user_snapshot` SET `idle`=0 WHERE `idle`<0; UPDATE `$dbname`.`user_snapshot` SET `count`=`idle` WHERE `count`<0; UPDATE `$dbname`.`user_snapshot` SET `count`=`idle` WHERE `count`<`idle`;") === false) { }
|
||||
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('database_export', '0'),('update_groups', '0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`);") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.13] Added new job_check values.");
|
||||
enter_logfile(4," [1.3.13] Added new job_check values.");
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -380,54 +380,54 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
} catch (Exception $e) { }
|
||||
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('default_session_sametime', 'Strict'),('default_header_origin', ''),('default_header_xss', '1; mode=block'),('default_header_contenttyp', '1'),('default_header_frame', '') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.13] Added new cfg_params values.");
|
||||
enter_logfile(4," [1.3.13] Added new cfg_params values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`user` SET `nation`='XX' WHERE `nation`='';") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.13] Updated table user.");
|
||||
enter_logfile(4," [1.3.13] Updated table user.");
|
||||
}
|
||||
|
||||
try {
|
||||
if($mysqlcon->exec("DROP INDEX `snapshot_id` ON `$dbname`.`user_snapshot` (`id`)") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.13] Dropped unneeded Index snapshot_id on table user_snapshot.");
|
||||
enter_logfile(4," [1.3.13] Dropped unneeded Index snapshot_id on table user_snapshot.");
|
||||
}
|
||||
if($mysqlcon->exec("DROP INDEX `snapshot_cldbid` ON `$dbname`.`user_snapshot` (`cldbid`)") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.13] Dropped unneeded Index snapshot_cldbid on table user_snapshot.");
|
||||
enter_logfile(4," [1.3.13] Dropped unneeded Index snapshot_cldbid on table user_snapshot.");
|
||||
}
|
||||
} catch (Exception $e) { }
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.14', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_column_default_sort_2', 'rank'),('stats_column_default_order_2', 'asc');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.14] Added new cfg_params values.");
|
||||
enter_logfile(4," [1.3.14] Added new cfg_params values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('assign_groups_name','');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.14] Added new addons_config values.");
|
||||
enter_logfile(4," [1.3.14] Added new addons_config values.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.16', '<')) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('calc_user_removed', '0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`);") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.16] Added new job_check values.");
|
||||
enter_logfile(4," [1.3.16] Added new job_check values.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.18', '<')) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('update_channel', '0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`);") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.18] Added new job_check values.");
|
||||
enter_logfile(4," [1.3.18] Added new job_check values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('default_cmdline_sec_switch', '1');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.18] Added new cfg_params values.");
|
||||
enter_logfile(4," [1.3.18] Added new cfg_params values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE IF NOT EXISTS `$dbname`.`channel` (`cid` int(10) UNSIGNED NOT NULL default '0',`pid` int(10) UNSIGNED NOT NULL default '0',`channel_order` int(10) UNSIGNED NOT NULL default '0',`channel_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,PRIMARY KEY (`cid`));") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.18] Created new table channel successfully.");
|
||||
enter_logfile(4," [1.3.18] Created new table channel successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`addons_config` MODIFY COLUMN `value` varchar(16000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.18] Adjusted table addons_config successfully.");
|
||||
enter_logfile(4," [1.3.18] Adjusted table addons_config successfully.");
|
||||
}
|
||||
|
||||
$channelinfo_desc = $mysqlcon->quote('[CENTER][B][SIZE=15]User Toplist (last week)[/SIZE][/B][/CENTER]
|
||||
@@ -485,9 +485,9 @@ last seen {$CLIENT_LAST_SEEN_10|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
|
||||
[SIZE=6]Updated: {$LAST_UPDATE_TIME}[/SIZE]', ENT_QUOTES);
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('channelinfo_toplist_active','0'),('channelinfo_toplist_desc',{$channelinfo_desc}),('channelinfo_toplist_lastdesc',''),('channelinfo_toplist_delay','600'),('channelinfo_toplist_channelid','0'),('channelinfo_toplist_modus','1'),('channelinfo_toplist_lastupdate','0') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);") === false) {
|
||||
enter_logfile($cfg,2," [1.3.18] Error on updating new addons_config values: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," [1.3.18] Error on updating new addons_config values: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
enter_logfile($cfg,4," [1.3.18] Updated new addons_config values.");
|
||||
enter_logfile(4," [1.3.18] Updated new addons_config values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`admin_addtime`;") === false) { }
|
||||
@@ -496,17 +496,44 @@ last seen {$CLIENT_LAST_SEEN_10|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.19', '<')) {
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`addons_config` MODIFY COLUMN `value` varchar(16000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.19] Adjusted table addons_config successfully.");
|
||||
enter_logfile(4," [1.3.19] Adjusted table addons_config successfully.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.20', '<')) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('clean_user_iphash', '0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`);") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.20] Added new job_check values.");
|
||||
enter_logfile(4," [1.3.20] Added new job_check values.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.21', '<')) {
|
||||
if(version_compare($cfg['version_current_using'], '1.3.22', '<')) {
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_server` MODIFY COLUMN `version_name_1` varchar(254) NOT NULL default '0',MODIFY COLUMN `version_name_2` varchar(254) NOT NULL default '0',MODIFY COLUMN `version_name_3` varchar(254) NOT NULL default '0',MODIFY COLUMN `version_name_4` varchar(254) NOT NULL default '0',MODIFY COLUMN `version_name_5` varchar(254) NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile(4," [1.3.22] Adjusted table stats_server successfully.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('default_style', '0'),('stats_column_online_day_switch', '0'),('stats_column_idle_day_switch', '0'),('stats_column_active_day_switch', '0'),('stats_column_online_week_switch', '0'),('stats_column_idle_week_switch', '0'),('stats_column_active_week_switch', '0'),('stats_column_online_month_switch', '0'),('stats_column_idle_month_switch', '0'),('stats_column_active_month_switch', '0'),('teamspeak_chatcommand_prefix', '!'),('rankup_excepted_remove_group_switch', '0');") === false) { } else {
|
||||
enter_logfile(4," [1.3.22] Added new cfg_params values.");
|
||||
}
|
||||
$cfg['rankup_excepted_remove_group_switch'] = '0';
|
||||
$cfg['teamspeak_chatcommand_prefix'] = '!';
|
||||
|
||||
if(($check_new_columns = $mysqlcon->query("SHOW COLUMNS FROM `$dbname`.`stats_user` WHERE `field`='count_day'")->fetchAll(PDO::FETCH_ASSOC)) === false) { } else {
|
||||
if(!isset($check_new_columns[0]['Field'])) {
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`stats_user` ADD COLUMN `count_day` mediumint(8) UNSIGNED NOT NULL default '0', ADD COLUMN `idle_day` mediumint(8) UNSIGNED NOT NULL default '0', ADD COLUMN `active_day` mediumint(8) UNSIGNED NOT NULL default '0';") === false) { } else {
|
||||
enter_logfile(4," [1.3.22] Adjusted table stats_user successfully.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('news_html', '".time()."'),('news_bb', '".time()."') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`);") === false) { } else {
|
||||
enter_logfile(4," [1.3.22] Added new job_check values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_news_html', '0'),('teamspeak_news_bb', '0') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);") === false) { } else {
|
||||
enter_logfile(4," [1.3.22] Added new cfg_params values (part 2).");
|
||||
$cfg['stats_news_html'] = 'New Feature <a href="https://ts-ranksystem.com#voting" target="_blank">VOTING!</a> for the Ranksystem';
|
||||
$cfg['teamspeak_news_bb'] = 'New Feature [URL=https://ts-ranksystem.com#voting]VOTING![/URL] for the Ranksystem';
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`admin_addtime`;") === false) { }
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`addon_assign_groups`;") === false) { }
|
||||
|
||||
@@ -518,11 +545,14 @@ last seen {$CLIENT_LAST_SEEN_10|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
if($mysqlcon->exec("CREATE INDEX `user_cldbid` ON `$dbname`.`user` (`cldbid` ASC,`uuid`,`rank`)") === false) { }
|
||||
if($mysqlcon->exec("CREATE INDEX `user_online` ON `$dbname`.`user` (`online`,`lastseen`)") === false) { }
|
||||
} catch (Exception $e) { }
|
||||
|
||||
$updatedone = TRUE;
|
||||
}
|
||||
|
||||
$cfg = set_new_version($mysqlcon,$cfg,$dbname);
|
||||
}
|
||||
enter_logfile($cfg,5,"Check Ranksystem database for updates [done]");
|
||||
return $cfg;
|
||||
enter_logfile(5,"Check Ranksystem database for updates [done]");
|
||||
if(isset($updatedone) && $updatedone === TRUE) return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
?>
|
||||
@@ -5,27 +5,27 @@ function clean($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
$sqlexec = '';
|
||||
|
||||
// clean old clients out of the database
|
||||
if($db_cache['job_check']['clean_clients']['timestamp'] < ($nowtime - $cfg['rankup_clean_clients_period'])) {
|
||||
if(intval($db_cache['job_check']['clean_clients']['timestamp']) < ($nowtime - $cfg['rankup_clean_clients_period'])) {
|
||||
$db_cache['job_check']['clean_clients']['timestamp'] = $nowtime;
|
||||
if ($cfg['rankup_clean_clients_switch'] == 1) {
|
||||
enter_logfile($cfg,4,$lang['clean']);
|
||||
enter_logfile(4,$lang['clean']);
|
||||
$start = $countdel = $countts = 0;
|
||||
$break=200;
|
||||
$count_tsuser['count'] = 0;
|
||||
$clientdblist=array();
|
||||
enter_logfile($cfg,5," Get TS3 Clientlist...");
|
||||
enter_logfile(5," Get TS3 Clientlist...");
|
||||
while($getclientdblist=$ts3->clientListDb($start, $break)) {
|
||||
check_shutdown($cfg);
|
||||
check_shutdown();
|
||||
$clientdblist=array_merge($clientdblist, $getclientdblist);
|
||||
$start=$start+$break;
|
||||
$count_tsuser=array_shift($getclientdblist);
|
||||
enter_logfile($cfg,6," Got TS3 Clientlist ".count($clientdblist)." of ".$count_tsuser['count']." Clients.");
|
||||
enter_logfile(6," Got TS3 Clientlist ".count($clientdblist)." of ".$count_tsuser['count']." Clients.");
|
||||
if($count_tsuser['count'] <= $start) {
|
||||
break;
|
||||
}
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
}
|
||||
enter_logfile($cfg,5," Get TS3 Clientlist [DONE]");
|
||||
enter_logfile(5," Get TS3 Clientlist [DONE]");
|
||||
foreach($clientdblist as $uuidts) {
|
||||
$single_uuid = $uuidts['client_unique_identifier']->toString();
|
||||
$uidarrts[$single_uuid]= 1;
|
||||
@@ -40,19 +40,19 @@ function clean($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
$countdel++;
|
||||
}
|
||||
}
|
||||
enter_logfile($cfg,4," ".sprintf($lang['cleants'], $countts, $count_tsuser['count']));
|
||||
enter_logfile($cfg,4," ".sprintf($lang['cleanrs'], count($db_cache['all_user'])));
|
||||
enter_logfile(4," ".sprintf($lang['cleants'], $countts, $count_tsuser['count']));
|
||||
enter_logfile(4," ".sprintf($lang['cleanrs'], count($db_cache['all_user'])));
|
||||
unset($uidarrts,$count_tsuser,$countts);
|
||||
if(isset($deleteuuids)) {
|
||||
$alldeldata = '';
|
||||
$fsfilelist = opendir(substr(__DIR__,0,-4).'avatars/');
|
||||
$fsfilelist = opendir(dirname(__DIR__).DIRECTORY_SEPARATOR.'avatars');
|
||||
while (false !== ($fsfile = readdir($fsfilelist))) {
|
||||
if ($fsfile != '.' && $fsfile != '..') {
|
||||
$fsfilelistarray[$fsfile] = filemtime(substr(__DIR__,0,-4).'avatars/'.$fsfile);
|
||||
$fsfilelistarray[$fsfile] = filemtime(dirname(__DIR__).DIRECTORY_SEPARATOR.'avatars'.DIRECTORY_SEPARATOR.$fsfile);
|
||||
}
|
||||
}
|
||||
unset($fsfilelist,$fsfile);
|
||||
$avatarfilepath = substr(__DIR__,0,-4).'avatars/';
|
||||
$avatarfilepath = dirname(__DIR__).DIRECTORY_SEPARATOR.'avatars'.DIRECTORY_SEPARATOR;
|
||||
$convert = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p');
|
||||
foreach ($deleteuuids as $uuid) {
|
||||
$alldeldata = $alldeldata . "'" . $uuid . "',";
|
||||
@@ -64,9 +64,9 @@ function clean($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
}
|
||||
if (isset($fsfilelistarray[$uuidasbase16.'.png'])) {
|
||||
if(unlink($avatarfilepath.$uuidasbase16.'.png') === false) {
|
||||
enter_logfile($cfg,2," ".sprintf($lang['clean0002'], $uuidasbase16, $uuid).' '.sprintf($lang['errperm'], 'avatars'));
|
||||
enter_logfile(2," ".sprintf($lang['clean0002'], $uuidasbase16, $uuid).' '.sprintf($lang['errperm'], 'avatars'));
|
||||
} else {
|
||||
enter_logfile($cfg,4," ".sprintf($lang['clean0001'], $uuidasbase16, $uuid));
|
||||
enter_logfile(4," ".sprintf($lang['clean0001'], $uuidasbase16, $uuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,30 +75,30 @@ function clean($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
$alldeldata = "(".$alldeldata.")";
|
||||
if ($alldeldata != '') {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='clean_clients';\nUPDATE `$dbname`.`stats_user` AS `t` LEFT JOIN `$dbname`.`user` AS `u` ON `t`.`uuid`=`u`.`uuid` SET `t`.`removed`='1' WHERE `u`.`uuid` IS NULL;\nDELETE FROM `$dbname`.`user` WHERE `uuid` IN $alldeldata;\n";
|
||||
enter_logfile($cfg,4," ".sprintf($lang['cleandel'], $countdel));
|
||||
enter_logfile(4," ".sprintf($lang['cleandel'], $countdel));
|
||||
unset($$alldeldata);
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,4," ".$lang['cleanno']);
|
||||
enter_logfile(4," ".$lang['cleanno']);
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='clean_clients';\n";
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,4,$lang['clean0004']);
|
||||
enter_logfile(4,$lang['clean0004']);
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='clean_clients';\n";
|
||||
}
|
||||
}
|
||||
|
||||
// clean usersnaps older then 1 month + clean old server usage - older then a year
|
||||
if ($db_cache['job_check']['clean_db']['timestamp'] < ($nowtime - 86400)) {
|
||||
if (intval($db_cache['job_check']['clean_db']['timestamp']) < ($nowtime - 86400)) {
|
||||
$db_cache['job_check']['clean_db']['timestamp'] = $nowtime;
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`server_usage` WHERE `timestamp` < (UNIX_TIMESTAMP() - 31536000);\nDELETE `b` FROM `$dbname`.`user` AS `a` RIGHT JOIN `$dbname`.`stats_user` AS `b` ON `a`.`uuid`=`b`.`uuid` WHERE `a`.`uuid` IS NULL;\nUPDATE `$dbname`.`job_check` SET `timestamp`='{$nowtime}' WHERE `job_name`='clean_db';\nDELETE FROM `$dbname`.`csrf_token` WHERE `timestamp` < (UNIX_TIMESTAMP() - 3600);\nDELETE `h` FROM `$dbname`.`user_iphash` AS `h` LEFT JOIN `$dbname`.`user` AS `u` ON `u`.`uuid` = `h`.`uuid` WHERE (`u`.`uuid` IS NULL OR `u`.`online`!=1);\n";
|
||||
enter_logfile($cfg,4,$lang['clean0003']);
|
||||
enter_logfile(4,$lang['clean0003']);
|
||||
}
|
||||
|
||||
// clean user_iphash
|
||||
if ($db_cache['job_check']['clean_user_iphash']['timestamp'] < ($nowtime - 3500)) {
|
||||
if (intval($db_cache['job_check']['clean_user_iphash']['timestamp']) < ($nowtime - 3500)) {
|
||||
if(($sqlhashs = $mysqlcon->query("SELECT * FROM `$dbname`.`user_iphash`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
enter_logfile($cfg,2,"clean user_iphash:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"clean user_iphash:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$rem_uuids = '';
|
||||
@@ -114,7 +114,7 @@ function clean($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='clean_user_iphash';\n";
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"clean needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"clean needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
?>
|
||||
@@ -1,30 +1,30 @@
|
||||
<?PHP
|
||||
function db_ex_imp($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
$starttime = microtime(true);
|
||||
#enter_logfile($cfg,5," started DB Export");
|
||||
#enter_logfile(5," started DB Export");
|
||||
|
||||
if (in_array($db_cache['job_check']['database_export']['timestamp'], ["1","2"])) {
|
||||
if (in_array(intval($db_cache['job_check']['database_export']['timestamp']), [1,2])) {
|
||||
|
||||
enter_logfile($cfg,4,"DB Export job(s) started");
|
||||
enter_logfile(4,"DB Export job(s) started");
|
||||
|
||||
$err = 0;
|
||||
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='2' WHERE `job_name`='database_export';") === false) {
|
||||
$err++;
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['database_export']['timestamp'] = 2;
|
||||
enter_logfile($cfg,4," Started job '".$lang['wihladmex']."'");
|
||||
enter_logfile(4," Started job '".$lang['wihladmex']."'");
|
||||
}
|
||||
|
||||
$datetime = date("Y-m-d_H-i-s", time());
|
||||
$filepath = $cfg['logs_path'].'db_export_'.$datetime;
|
||||
$filepath = $GLOBALS['logpath'].'db_export_'.$datetime;
|
||||
$filename = 'db_export_'.$datetime;
|
||||
$limit_entries = 10000;
|
||||
|
||||
if (($tables = $mysqlcon->query("SHOW TABLES")->fetchALL(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) {
|
||||
$err++;
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
|
||||
$dump = fopen($filepath.".sql", 'a');
|
||||
@@ -37,20 +37,20 @@ function db_ex_imp($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
#if($table == 'user_snapshot') continue;
|
||||
if (($numColumns = $mysqlcon->query("SELECT * FROM `$dbname`.`$table` LIMIT 1")->columnCount()) === false) {
|
||||
$err++;
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$out .= 'DROP TABLE IF EXISTS `' . $table . '`;' . "\n\n";
|
||||
|
||||
if (($create_table = $mysqlcon->query("SHOW CREATE TABLE `$dbname`.`$table`")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
$err++;
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
$out .= $create_table['Create Table'] . ';' . "\n\n";
|
||||
|
||||
if (($maxvalues = $mysqlcon->query("SELECT COUNT(*) FROM `$dbname`.`$table`;")->fetch()) === false) {
|
||||
$err++;
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$dump = fopen($filepath.".sql", 'a');
|
||||
@@ -65,7 +65,7 @@ function db_ex_imp($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
$offset = $i * $limit_entries;
|
||||
if (($sqldata = $mysqlcon->query("SELECT * FROM `$dbname`.`$table` LIMIT {$limit_entries} OFFSET {$offset}")->fetchALL(PDO::FETCH_NUM)) === false) {
|
||||
$err++;
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
if(count($sqldata) != 0) {
|
||||
@@ -97,10 +97,10 @@ function db_ex_imp($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
|
||||
if (($job_status = $mysqlcon->query("SELECT `timestamp` FROM `$dbname`.`job_check` WHERE `job_name`='database_export';")->fetch(PDO::FETCH_ASSOC)) === false) {
|
||||
$err++;
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} elseif($job_status['timestamp'] == 3) {
|
||||
$db_cache['job_check']['database_export']['timestamp'] = 3;
|
||||
enter_logfile($cfg,4,"DB Export job(s) canceled by request");
|
||||
enter_logfile(4,"DB Export job(s) canceled by request");
|
||||
$dump = fopen($filepath.".sql", 'a');
|
||||
fwrite($dump, "\nROLLBACK;\n\n-- Canceled export");
|
||||
fclose($dump);
|
||||
@@ -116,41 +116,41 @@ function db_ex_imp($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($filepath.".sql.zip", ZipArchive::CREATE)!==TRUE) {
|
||||
$err++;
|
||||
enter_logfile($cfg,2," Cannot create $filepath.sql.zip!");
|
||||
enter_logfile(2," Cannot create $filepath.sql.zip!");
|
||||
} else {
|
||||
$zip->addFile($filepath.".sql",$filename.".sql");
|
||||
if(version_compare(phpversion(), '7.2', '>=') && version_compare(phpversion("zip"), '1.2.0', '>=')) {
|
||||
try {
|
||||
$zip->setEncryptionName($filename.".sql", ZipArchive::EM_AES_256, $cfg['teamspeak_query_pass']);
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2," Error due creating secured zip-File: ".$e->getCode().': '.$e->getMessage(). " ..Update PHP to Version 7.2 or above and update libzip to version 1.2.0 or above.");
|
||||
enter_logfile(2," Error due creating secured zip-File: ".$e->getCode().': '.$e->getMessage(). " ..Update PHP to Version 7.2 or above and update libzip to version 1.2.0 or above.");
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
if(!unlink($filepath.".sql")) {
|
||||
$err++;
|
||||
enter_logfile($cfg,2," Cannot remove SQL file $filepath.sql!");
|
||||
enter_logfile(2," Cannot remove SQL file $filepath.sql!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($err == 0) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='4' WHERE `job_name`='database_export';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['database_export']['timestamp'] = 4;
|
||||
enter_logfile($cfg,4," Finished job '".$lang['wihladmex']."'");
|
||||
enter_logfile(4," Finished job '".$lang['wihladmex']."'");
|
||||
}
|
||||
} else {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='3' WHERE `job_name`='database_export';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['database_export']['timestamp'] = 3;
|
||||
}
|
||||
}
|
||||
|
||||
enter_logfile($cfg,4,"DB Export job(s) finished");
|
||||
enter_logfile(4,"DB Export job(s) finished");
|
||||
}
|
||||
enter_logfile($cfg,6,"db_ex_imp needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"db_ex_imp needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
}
|
||||
?>
|
||||
@@ -6,7 +6,7 @@ function event_userenter(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
$sqlexec3 = '';
|
||||
|
||||
if($event['client_type'] == 0) {
|
||||
enter_logfile($cfg,6,"User ".$event['client_nickname']." (uuid: ".$event['client_unique_identifier'].") connected to the server.");
|
||||
enter_logfile(6,"User ".$event['client_nickname']." (uuid: ".$event['client_unique_identifier'].") connected to the server.");
|
||||
try {
|
||||
$host->serverGetSelected()->clientListReset();
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
@@ -23,13 +23,13 @@ function event_userenter(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
}
|
||||
unset($clientlist,$host);
|
||||
if(!isset($ip)) {
|
||||
enter_logfile($cfg,6,"New user ({$event['client_nickname']} [{$event['client_database_id']}]) joined the server, but can't found a valid IP address.");
|
||||
enter_logfile(6,"New user ({$event['client_nickname']} [{$event['client_database_id']}]) joined the server, but can't found a valid IP address.");
|
||||
} else {
|
||||
if($cfg['rankup_hash_ip_addresses_mode'] == 1) {
|
||||
$hash = password_hash($ip, PASSWORD_DEFAULT);
|
||||
$ip = '';
|
||||
} elseif($cfg['rankup_hash_ip_addresses_mode'] == 2) {
|
||||
$salt = md5(dechex(crc32(substr(__DIR__,0,-4))));
|
||||
$salt = md5(dechex(crc32(dirname(__DIR__))));
|
||||
if(version_compare(PHP_VERSION, '7.9.9', '>')) {
|
||||
$hash = crypt($ip, '$2y$10$'.$salt.'$');
|
||||
} else {
|
||||
@@ -39,26 +39,26 @@ function event_userenter(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
} else {
|
||||
$hash = '';
|
||||
}
|
||||
enter_logfile($cfg,6,"Event Userenter: Users IP-hash: ".$hash);
|
||||
enter_logfile(6,"Event Userenter: Users IP-hash: ".$hash);
|
||||
|
||||
if(($sqlhashs = $mysqlcon->query("SELECT * FROM `$dbname`.`user_iphash`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
enter_logfile($cfg,2,"event_userenter 2:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"event_userenter 2:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
$uuid = htmlspecialchars($event['client_unique_identifier'], ENT_QUOTES);
|
||||
if(isset($sqlhashs[$uuid])) {
|
||||
$sqlexec3 .= "UPDATE `$dbname`.`user_iphash` SET `iphash`='$hash',`ip`='$ip' WHERE `uuid`='{$event['client_unique_identifier']}'; ";
|
||||
enter_logfile($cfg,6,"Userenter: UPDATE `$dbname`.`user_iphash` SET `iphash`='$hash',`ip`='$ip' WHERE `uuid`='{$event['client_unique_identifier']}'; ");
|
||||
enter_logfile(6,"Userenter: UPDATE `$dbname`.`user_iphash` SET `iphash`='$hash',`ip`='$ip' WHERE `uuid`='{$event['client_unique_identifier']}'; ");
|
||||
} else {
|
||||
$sqlexec3 .= "INSERT INTO `$dbname`.`user_iphash` (`uuid`,`iphash`,`ip`) VALUES ('{$event['client_unique_identifier']}','$hash','$ip'); ";
|
||||
enter_logfile($cfg,6,"Userenter: INSERT INTO `$dbname`.`user_iphash` (`uuid`,`iphash`,`ip`) VALUES ('{$event['client_unique_identifier']}','$hash','$ip'); ");
|
||||
enter_logfile(6,"Userenter: INSERT INTO `$dbname`.`user_iphash` (`uuid`,`iphash`,`ip`) VALUES ('{$event['client_unique_identifier']}','$hash','$ip'); ");
|
||||
}
|
||||
if($mysqlcon->exec($sqlexec3) === false) {
|
||||
enter_logfile($cfg,2,"event_userenter 3:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"event_userenter 3:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"event_userenter 4:".$e->getCode().': '.$e->getMessage());
|
||||
enter_logfile(2,"event_userenter 4:".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ function get_avatars($ts3,$cfg,$dbname,&$db_cache) {
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
if($db_cache['job_check']['get_avatars']['timestamp'] < ($nowtime - 32)) {
|
||||
if(intval($db_cache['job_check']['get_avatars']['timestamp']) < ($nowtime - 32)) {
|
||||
$db_cache['job_check']['get_avatars']['timestamp'] = $nowtime;
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`={$nowtime} WHERE `job_name`='get_avatars';\n";
|
||||
try {
|
||||
@@ -12,13 +12,13 @@ function get_avatars($ts3,$cfg,$dbname,&$db_cache) {
|
||||
$tsfilelist = $ts3->channelFileList($cid="0", $cpw="", $path="/");
|
||||
} catch (Exception $e) {
|
||||
if ($e->getCode() != 1281) {
|
||||
enter_logfile($cfg,2,"get_avatars 1:".$e->getCode().': '."Error while getting avatarlist: ".$e->getMessage());
|
||||
enter_logfile(2,"get_avatars 1:".$e->getCode().': '."Error while getting avatarlist: ".$e->getMessage());
|
||||
}
|
||||
}
|
||||
$fsfilelist = opendir(substr(__DIR__,0,-4).'avatars/');
|
||||
$fsfilelist = opendir($GLOBALS['avatarpath']);
|
||||
while (false !== ($fsfile = readdir($fsfilelist))) {
|
||||
if ($fsfile != '.' && $fsfile != '..') {
|
||||
$fsfilelistarray[$fsfile] = filemtime(substr(__DIR__,0,-4).'avatars/'.$fsfile);
|
||||
$fsfilelistarray[$fsfile] = filemtime($GLOBALS['avatarpath'].$fsfile);
|
||||
}
|
||||
}
|
||||
unset($fsfilelist);
|
||||
@@ -32,24 +32,24 @@ function get_avatars($ts3,$cfg,$dbname,&$db_cache) {
|
||||
if (!isset($fsfilelistarray[$uuidasbase16.'.png']) || ($tsfile['datetime'] - $cfg['teamspeak_avatar_download_delay']) > $fsfilelistarray[$uuidasbase16.'.png']) {
|
||||
if (substr($tsfile['name'],0,7) == 'avatar_') {
|
||||
try {
|
||||
check_shutdown($cfg); usleep($cfg['teamspeak_query_command_delay']);
|
||||
check_shutdown(); usleep($cfg['teamspeak_query_command_delay']);
|
||||
$avatar = $ts3->transferInitDownload($clientftfid="5",$cid="0",$name=$fullfilename,$cpw="", $seekpos=0);
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . $avatar["host"] . ":" . $avatar["port"]);
|
||||
$tsfile = $transfer->download($avatar["ftkey"], $avatar["size"]);
|
||||
$avatarfilepath = substr(__DIR__,0,-4).'avatars/'.$uuidasbase16.'.png';
|
||||
$avatarfilepath = $GLOBALS['avatarpath'].$uuidasbase16.'.png';
|
||||
$downloadedavatars++;
|
||||
enter_logfile($cfg,5,"Download avatar: ".$fullfilename);
|
||||
enter_logfile(5,"Download avatar: ".$fullfilename);
|
||||
if(file_put_contents($avatarfilepath, $tsfile) === false) {
|
||||
enter_logfile($cfg,2,"Error while writing out the avatar. Please check the permission for the folder 'avatars'");
|
||||
enter_logfile(2,"Error while writing out the avatar. Please check the permission for the folder '".$GLOBALS['avatarpath']."'");
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($cfg,2,"get_avatars 2:".$e->getCode().': '."Error while downloading avatar: ".$e->getMessage());
|
||||
enter_logfile(2,"get_avatars 2:".$e->getCode().': '."Error while downloading avatar: ".$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if((microtime(true) - $starttime) > 5) {
|
||||
enter_logfile($cfg,6,"get_avatars needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"get_avatars needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ function get_avatars($ts3,$cfg,$dbname,&$db_cache) {
|
||||
}
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"get_avatars needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"get_avatars needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
?>
|
||||
@@ -2,7 +2,7 @@
|
||||
function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host) {
|
||||
|
||||
global $lang,$cfg,$mysqlcon,$dbname,$phpcommand,$ts3,$whoami;
|
||||
enter_logfile($cfg,6,"whoami: ".print_r($host->whoami(),true));
|
||||
enter_logfile(6,"whoami: ".print_r($host->whoami(),true));
|
||||
if($event["targetmode"] == 1) {
|
||||
$targetid = $event["invokerid"];
|
||||
} elseif($event["targetmode"] == 2) {
|
||||
@@ -11,7 +11,7 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
$targetid = NULL;
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"event: ".print_r($event,true));
|
||||
enter_logfile(6,"event: ".print_r($event,true));
|
||||
|
||||
if($host->whoami()["client_id"] != $event["invokerid"] && substr($event["msg"],0,1) === "!") {
|
||||
$uuid = $event["invokeruid"];
|
||||
@@ -22,15 +22,15 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
}
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"Client ".$event["invokername"]." (".$event["invokeruid"].") sent textmessage: ".$event["msg"]);
|
||||
enter_logfile(6,"Client ".$event["invokername"]." (".$event["invokeruid"].") sent textmessage: ".$event["msg"]);
|
||||
|
||||
if((strstr($event["msg"], '!nextup') || strstr($event["msg"], '!next')) && $cfg['rankup_next_message_mode'] != 0) {
|
||||
if(($user = $mysqlcon->query("SELECT `count`,`nextup`,`idle`,`except`,`name`,`rank`,`grpsince`,`grpid` FROM `$dbname`.`user` WHERE `uuid`='$uuid'")->fetch()) === false) {
|
||||
enter_logfile($cfg,2,"handle_messages 1:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"handle_messages 1:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
if(($sqlhisgroup = $mysqlcon->query("SELECT `sgid`,`sgidname` FROM `$dbname`.`groups`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
enter_logfile($cfg,2,"handle_messages 2:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"handle_messages 2:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
ksort($cfg['rankup_definition']);
|
||||
@@ -70,7 +70,7 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
return;
|
||||
}
|
||||
|
||||
if(strstr($event["msg"], '!version')) {
|
||||
if(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'version')) {
|
||||
if(version_compare($cfg['version_latest_available'], $cfg['version_current_using'], '>') && $cfg['version_latest_available'] != '') {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], sprintf($lang['upmsg'], $cfg['version_current_using'], $cfg['version_latest_available'], 'https://ts-ranksystem.com/#changelog'), $event["targetmode"], $targetid);
|
||||
} else {
|
||||
@@ -79,96 +79,103 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
return;
|
||||
}
|
||||
|
||||
if(strstr($event["msg"], '!help') || strstr($event["msg"], '!info') || strstr($event["msg"], '!commands') || strstr($event["msg"], '!cmd')) {
|
||||
if(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'help') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'info') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'commands') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'cmd')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0002'], $event["targetmode"], $targetid);
|
||||
return;
|
||||
}
|
||||
|
||||
if((strstr($event["msg"], '!shutdown') || strstr($event["msg"], '!quit') || strstr($event["msg"], '!stop')) && $admin == 1) {
|
||||
enter_logfile($cfg,5,sprintf($lang['msg0004'], $event["invokername"], $event["invokeruid"]));
|
||||
$path = substr(__DIR__, 0, -4);
|
||||
if(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'news')) {
|
||||
if(isset($cfg['teamspeak_news_bb']) && $cfg['teamspeak_news_bb'] != '') {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], "Latest News:\n".$cfg['teamspeak_news_bb'], $event["targetmode"], $targetid);
|
||||
} else {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], "No News available yet.", $event["targetmode"], $targetid);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if((strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'shutdown') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'quit') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'stop')) && $admin == 1) {
|
||||
enter_logfile(5,sprintf($lang['msg0004'], $event["invokername"], $event["invokeruid"]));
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0005'], $event["targetmode"], $targetid);
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
exec("start ".$phpcommand." ".$path."worker.php stop");
|
||||
exec("start ".$phpcommand." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php stop");
|
||||
} else {
|
||||
exec($phpcommand." ".$path."worker.php stop > /dev/null &");
|
||||
exec($phpcommand." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php stop > /dev/null &");
|
||||
}
|
||||
file_put_contents($cfg['logs_path'].'autostart_deactivated',"");
|
||||
file_put_contents($GLOBALS['autostart'],"");
|
||||
shutdown($mysql,$cfg,4,"Stop command received!");
|
||||
} elseif (strstr($event["msg"], '!shutdown') || strstr($event["msg"], '!quit') || strstr($event["msg"], '!stop')) {
|
||||
} elseif (strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'shutdown') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'quit') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'stop')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0003'], $event["targetmode"], $targetid);
|
||||
return;
|
||||
}
|
||||
|
||||
if((strstr($event["msg"], '!restart') || strstr($event["msg"], '!reboot')) && $admin == 1) {
|
||||
enter_logfile($cfg,5,sprintf($lang['msg0007'], $event["invokername"], $event["invokeruid"], "restart"));
|
||||
$path = substr(__DIR__, 0, -4);
|
||||
if((strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'restart') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'reboot')) && $admin == 1) {
|
||||
enter_logfile(5,sprintf($lang['msg0007'], $event["invokername"], $event["invokeruid"], "restart"));
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0006'], $event["targetmode"], $targetid);
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
exec("start ".$phpcommand." ".$path."worker.php restart");
|
||||
exec("start ".$phpcommand." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php restart");
|
||||
} else {
|
||||
exec($phpcommand." ".$path."worker.php restart > /dev/null 2>/dev/null &");
|
||||
exec($phpcommand." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php restart > /dev/null 2>/dev/null &");
|
||||
}
|
||||
return;
|
||||
} elseif (strstr($event["msg"], '!restart') || strstr($event["msg"], '!reboot')) {
|
||||
} elseif (strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'restart') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'reboot')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0003'], $event["targetmode"], $targetid);
|
||||
return;
|
||||
}
|
||||
|
||||
if((strstr($event["msg"], '!checkupdate') || strstr($event["msg"], '!update')) && $admin == 1) {
|
||||
if((strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'checkupdate') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'update')) && $admin == 1) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='0' WHERE `job_name` IN ('check_update','get_version','calc_server_stats','calc_donut_chars')") === false) {
|
||||
enter_logfile($cfg,4,"handle_messages 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(4,"handle_messages 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0008'], $event["targetmode"], $targetid);
|
||||
return;
|
||||
} elseif(strstr($event["msg"], '!checkupdate') || strstr($event["msg"], '!update')) {
|
||||
} elseif(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'checkupdate') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'update')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0003'], $event["targetmode"], $targetid);
|
||||
return;
|
||||
}
|
||||
|
||||
if((strstr($event["msg"], '!clean')) && $admin == 1) {
|
||||
enter_logfile($cfg,5,sprintf($lang['msg0007'], $event["invokername"], $event["invokeruid"], "clean"));
|
||||
if((strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'clean')) && $admin == 1) {
|
||||
enter_logfile(5,sprintf($lang['msg0007'], $event["invokername"], $event["invokeruid"], "clean"));
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='0' WHERE `job_name` IN ('clean_db','clean_clients')") === false) {
|
||||
enter_logfile($cfg,4,"handle_messages 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(4,"handle_messages 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0009'] ." ". $lang['msg0010'], $event["targetmode"], $targetid);
|
||||
return;
|
||||
} elseif(strstr($event["msg"], '!clean')) {
|
||||
} elseif(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'clean')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0003'], $event["targetmode"], $targetid);
|
||||
return;
|
||||
}
|
||||
|
||||
if((strstr($event["msg"], '!reloadgroups') || strstr($event["msg"], '!reloadicons')) && $admin == 1) {
|
||||
if((strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'reloadgroups') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'reloadicons')) && $admin == 1) {
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`groups`") === false) {
|
||||
enter_logfile($cfg,4,"handle_messages 14:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(4,"handle_messages 14:".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger';") === false) {
|
||||
enter_logfile($cfg,4,"handle_messages 15:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(4,"handle_messages 15:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0011'] ." ". $lang['msg0010'], $event["targetmode"], $targetid);
|
||||
return;
|
||||
} elseif(strstr($event["msg"], '!reloadgroups')) {
|
||||
} elseif(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'reloadgroups')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0003'], $event["targetmode"], $targetid);
|
||||
return;
|
||||
}
|
||||
|
||||
if(strstr($event["msg"], '!online') || strstr($event["msg"], '!uptime')) {
|
||||
if(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'online') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'uptime')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], sprintf("Bot is online since %s, now %s.", (DateTime::createFromFormat('U', $cfg['temp_last_botstart'])->setTimeZone(new DateTimeZone($cfg['logs_timezone']))->format("Y-m-d H:i:s")), (new DateTime("@0"))->diff(new DateTime("@".(time()-$cfg['temp_last_botstart'])))->format($cfg['default_date_format'])), $event["targetmode"], $targetid);
|
||||
return;
|
||||
}
|
||||
|
||||
if(strstr($event["msg"], '!runtime') || strstr($event["msg"], '!runtimes')) {
|
||||
if(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'runtime') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'runtimes')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], sprintf("Last 10 runtimes (in seconds):\n%s\n\nØ %s sec. (Σ %s)", str_replace(";","\n",$cfg['temp_last_laptime']), round(($cfg['temp_whole_laptime'] / $cfg['temp_count_laptime']),5), $cfg['temp_count_laptime']), $event["targetmode"], $targetid);
|
||||
return;
|
||||
}
|
||||
|
||||
if(strstr($event["msg"], '!memory')) {
|
||||
if(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'memory')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], sprintf("Allocated memory of PHP for the Ranksystem Bot..\ncurrent using: %s KiB\npeak using: %s KiB", round((memory_get_usage()/1024),2), round((memory_get_peak_usage()/1024),2)), $event["targetmode"], $targetid);
|
||||
return;
|
||||
}
|
||||
|
||||
if((strstr($event["msg"], '!logs') || strstr($event["msg"], '!log')) && $admin == 1) {
|
||||
if((strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'logs') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'log')) && $admin == 1) {
|
||||
$parameter = explode(' ', $event["msg"]);
|
||||
if(isset($parameter[1]) && $parameter[1] > 0 && $parameter[1] < 1000) {
|
||||
$number_lines = $parameter[1];
|
||||
@@ -178,8 +185,8 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
$filters = explode(',', 'CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG,NONE');
|
||||
$filter2 = $lastfilter = '';
|
||||
$lines=array();
|
||||
if(file_exists($cfg['logs_path']."ranksystem.log")) {
|
||||
$fp = fopen($cfg['logs_path']."ranksystem.log", "r");
|
||||
if(file_exists($GLOBALS['logfile'])) {
|
||||
$fp = fopen($GLOBALS['logfile'], "r");
|
||||
$buffer=array();
|
||||
while($line = fgets($fp, 4096)) {
|
||||
array_push($buffer, $line);
|
||||
@@ -220,7 +227,7 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
|
||||
}
|
||||
$targetid = $event["invokerid"];
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $message, 1, $targetid, NULL, NULL, NULL, $nolog=1);
|
||||
} elseif(strstr($event["msg"], '!logs') || strstr($event["msg"], '!log')) {
|
||||
} elseif(strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'logs') || strstr($event["msg"], $cfg['teamspeak_chatcommand_prefix'].'log')) {
|
||||
sendmessage($host, $cfg, $event["invokeruid"], $lang['msg0003'], $event["targetmode"], $targetid);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,28 +2,28 @@
|
||||
function reset_rs($ts3,$mysqlcon,$lang,$cfg,$dbname,$phpcommand,&$db_cache) {
|
||||
$starttime = microtime(true);
|
||||
|
||||
if (in_array($db_cache['job_check']['reset_user_time']['timestamp'], ["1","2"], true) || in_array($db_cache['job_check']['reset_user_delete']['timestamp'], ["1","2"], true) || in_array($db_cache['job_check']['reset_group_withdraw']['timestamp'], ["1","2"], true) || in_array($db_cache['job_check']['reset_webspace_cache']['timestamp'], ["1","2"], true) || in_array($db_cache['job_check']['reset_usage_graph']['timestamp'], ["1","2"], true)) {
|
||||
if (in_array(intval($db_cache['job_check']['reset_user_time']['timestamp']), [1,2], true) || in_array(intval($db_cache['job_check']['reset_user_delete']['timestamp']), [1,2], true) || in_array(intval($db_cache['job_check']['reset_group_withdraw']['timestamp']), [1,2], true) || in_array(intval($db_cache['job_check']['reset_webspace_cache']['timestamp']), [1,2], true) || in_array(intval($db_cache['job_check']['reset_usage_graph']['timestamp']), [1,2], true)) {
|
||||
|
||||
enter_logfile($cfg,4,"Reset job(s) started");
|
||||
enter_logfile(4,"Reset job(s) started");
|
||||
$err_cnt = 0;
|
||||
|
||||
if (in_array($db_cache['job_check']['reset_group_withdraw']['timestamp'], ["1","2"], true)) {
|
||||
if (in_array(intval($db_cache['job_check']['reset_group_withdraw']['timestamp']), [1,2], true)) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='2' WHERE `job_name`='reset_group_withdraw';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err_cnt++;
|
||||
} else {
|
||||
$db_cache['job_check']['reset_group_withdraw']['timestamp'] = 2;
|
||||
enter_logfile($cfg,4," Started job '".$lang['wihladm32']."'");
|
||||
enter_logfile(4," Started job '".$lang['wihladm32']."'");
|
||||
}
|
||||
|
||||
krsort($cfg['rankup_definition']);
|
||||
|
||||
if (($all_clients = $mysqlcon->query("SELECT `cldbid`,`uuid`,`name` FROM `$dbname`.`user`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)) === false) {
|
||||
shutdown($mysqlcon,$cfg,1,"Select on DB failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
shutdown($mysqlcon,1,"Select on DB failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
|
||||
foreach ($cfg['rankup_definition'] as $rank) {
|
||||
enter_logfile($cfg,5," Getting TS3 servergrouplist for ".$db_cache['groups'][$rank['group']]['sgidname']." (ID: ".$rank['group'].")");
|
||||
enter_logfile(5," Getting TS3 servergrouplist for ".$db_cache['groups'][$rank['group']]['sgidname']." (ID: ".$rank['group'].")");
|
||||
try {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$tsclientlist = $ts3->servergroupclientlist($rank['group']);
|
||||
@@ -33,28 +33,28 @@ function reset_rs($ts3,$mysqlcon,$lang,$cfg,$dbname,$phpcommand,&$db_cache) {
|
||||
try {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$ts3->serverGroupClientDel($rank['group'], $tsclient['cldbid']);
|
||||
enter_logfile($cfg,5," ".sprintf($lang['sgrprm'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group'], $all_clients[$tsclient['cldbid']]['name'], $all_clients[$tsclient['cldbid']]['uuid'], $tsclient['cldbid']));
|
||||
enter_logfile(5," ".sprintf($lang['sgrprm'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group'], $all_clients[$tsclient['cldbid']]['name'], $all_clients[$tsclient['cldbid']]['uuid'], $tsclient['cldbid']));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2," TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $all_clients[$tsclient['cldbid']]['name'], $all_clients[$tsclient['cldbid']]['uuid'], $tsclient['cldbid'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group']));
|
||||
enter_logfile(2," TS3 error: ".$e->getCode().': '.$e->getMessage()." ; ".sprintf($lang['sgrprerr'], $all_clients[$tsclient['cldbid']]['name'], $all_clients[$tsclient['cldbid']]['uuid'], $tsclient['cldbid'], $db_cache['groups'][$rank['group']]['sgidname'], $rank['group']));
|
||||
$err_cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2," TS3 error: ".$e->getCode().': '.$e->getMessage()." due getting servergroupclientlist for group ".$groupid);
|
||||
enter_logfile(2," TS3 error: ".$e->getCode().': '.$e->getMessage()." due getting servergroupclientlist for group ".$groupid);
|
||||
$err_cnt++;
|
||||
}
|
||||
}
|
||||
if ($err_cnt == 0) {
|
||||
if ($mysqlcon->exec("UPDATE `$dbname`.`user` SET `grpid`=0; UPDATE `$dbname`.`job_check` SET `timestamp`='4' WHERE `job_name`='reset_group_withdraw';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_group_withdraw']['timestamp'] = 4;
|
||||
enter_logfile($cfg,4," Finished job '".$lang['wihladm32']."'");
|
||||
enter_logfile(4," Finished job '".$lang['wihladm32']."'");
|
||||
}
|
||||
} else {
|
||||
if ($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='3' WHERE `job_name`='reset_group_withdraw';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_group_withdraw']['timestamp'] = 3;
|
||||
}
|
||||
@@ -62,54 +62,54 @@ function reset_rs($ts3,$mysqlcon,$lang,$cfg,$dbname,$phpcommand,&$db_cache) {
|
||||
}
|
||||
|
||||
|
||||
if ($err_cnt == 0 && in_array($db_cache['job_check']['reset_user_time']['timestamp'], ["1","2"], true)) {
|
||||
if ($err_cnt == 0 && in_array(intval($db_cache['job_check']['reset_user_time']['timestamp']), [1,2], true)) {
|
||||
$err = 0;
|
||||
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='2' WHERE `job_name`='reset_user_time';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
$db_cache['job_check']['reset_user_time']['timestamp'] = 2;
|
||||
enter_logfile($cfg,4," Started job '".$lang['wihladm31']."' (".$lang['wisupidle'].": ".$lang['wihladm311'].")");
|
||||
enter_logfile(4," Started job '".$lang['wihladm31']."' (".$lang['wisupidle'].": ".$lang['wihladm311'].")");
|
||||
}
|
||||
|
||||
// zero times
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`stats_server` SET `total_online_time`='0', `total_online_month`='0', `total_online_week`='0', `total_active_time`='0', `total_inactive_time`='0';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Reset Server statistics summary (table: stats_server)");
|
||||
enter_logfile(4," Reset Server statistics summary (table: stats_server)");
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`stats_user` SET `count_week`='0', `count_month`='0', `idle_week`='0', `idle_month`='0', `total_connections`='0', `active_week`='0', `active_month`='0';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Reset My statistics (table: stats_user)");
|
||||
enter_logfile(4," Reset My statistics (table: stats_user)");
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`user` SET `count`='0', `grpid`='0', `nextup`='0', `idle`='0', `boosttime`='0', `rank`='0', `grpsince`='0';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Reset List Rankup / user statistics (table: user)");
|
||||
enter_logfile(4," Reset List Rankup / user statistics (table: user)");
|
||||
}
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`user_snapshot`;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Cleaned Top users / user statistic snapshots (table: user_snapshot)");
|
||||
enter_logfile(4," Cleaned Top users / user statistic snapshots (table: user_snapshot)");
|
||||
}
|
||||
|
||||
|
||||
if ($err == 0) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='4' WHERE `job_name`='reset_user_time';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_user_time']['timestamp'] = 4;
|
||||
enter_logfile($cfg,4," Finished job '".$lang['wihladm31']."' (".$lang['wisupidle'].": ".$lang['wihladm311'].")");
|
||||
enter_logfile(4," Finished job '".$lang['wihladm31']."' (".$lang['wisupidle'].": ".$lang['wihladm311'].")");
|
||||
}
|
||||
} else {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='3' WHERE `job_name`='reset_user_time';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_user_time']['timestamp'] = 3;
|
||||
}
|
||||
@@ -117,100 +117,100 @@ function reset_rs($ts3,$mysqlcon,$lang,$cfg,$dbname,$phpcommand,&$db_cache) {
|
||||
}
|
||||
|
||||
|
||||
if ($err_cnt == 0 && in_array($db_cache['job_check']['reset_user_delete']['timestamp'], ["1","2"], true)) {
|
||||
if ($err_cnt == 0 && in_array(intval($db_cache['job_check']['reset_user_delete']['timestamp']), [1,2], true)) {
|
||||
$err = 0;
|
||||
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='2' WHERE `job_name`='reset_user_delete';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
$db_cache['job_check']['reset_user_delete']['timestamp'] = 2;
|
||||
enter_logfile($cfg,4," Started job '".$lang['wihladm31']."' (".$lang['wisupidle'].": ".$lang['wihladm312'].")");
|
||||
enter_logfile(4," Started job '".$lang['wihladm31']."' (".$lang['wisupidle'].": ".$lang['wihladm312'].")");
|
||||
}
|
||||
|
||||
// remove clients
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`stats_nations`;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Cleaned donut chart nations (table: stats_nations)");
|
||||
enter_logfile(4," Cleaned donut chart nations (table: stats_nations)");
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`stats_platforms` SET `count`=0;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Cleaned donut chart platforms (table: stats_platforms)");
|
||||
enter_logfile(4," Cleaned donut chart platforms (table: stats_platforms)");
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`stats_server` SET `total_user`='0', `total_online_time`='0', `total_online_month`='0', `total_online_week`='0', `total_active_time`='0', `total_inactive_time`='0', `country_nation_name_1`='', `country_nation_name_2`='', `country_nation_name_3`='', `country_nation_name_4`='', `country_nation_name_5`='', `country_nation_1`='0', `country_nation_2`='0', `country_nation_3`='0', `country_nation_4`='0', `country_nation_5`='0', `country_nation_other`='0', `platform_1`='0', `platform_2`='0', `platform_3`='0', `platform_4`='0', `platform_5`='0', `platform_other`='0', `version_name_1`='', `version_name_2`='', `version_name_3`='', `version_name_4`='', `version_name_5`='', `version_1`='0', `version_2`='0', `version_3`='0', `version_4`='0', `version_5`='0', `version_other`='0';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Reset Server statistics summary (table: stats_server)");
|
||||
enter_logfile(4," Reset Server statistics summary (table: stats_server)");
|
||||
}
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`stats_user`;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Cleaned My statistics (table: stats_user)");
|
||||
enter_logfile(4," Cleaned My statistics (table: stats_user)");
|
||||
}
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`stats_versions`;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Cleaned donut chart versions (table: stats_versions)");
|
||||
enter_logfile(4," Cleaned donut chart versions (table: stats_versions)");
|
||||
}
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`user`;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Cleaned List Rankup / user statistics (table: user)");
|
||||
enter_logfile(4," Cleaned List Rankup / user statistics (table: user)");
|
||||
}
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`user_iphash`;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Cleaned user ip-hash values (table: user_iphash)");
|
||||
enter_logfile(4," Cleaned user ip-hash values (table: user_iphash)");
|
||||
}
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`user_snapshot`;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
$err++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Cleaned Top users / user statistic snapshots (table: user_snapshot)");
|
||||
enter_logfile(4," Cleaned Top users / user statistic snapshots (table: user_snapshot)");
|
||||
}
|
||||
|
||||
|
||||
if ($err == 0) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='4' WHERE `job_name`='reset_user_delete';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_user_delete']['timestamp'] = 4;
|
||||
enter_logfile($cfg,4," Finished job '".$lang['wihladm31']."' (".$lang['wisupidle'].": ".$lang['wihladm312'].")");
|
||||
enter_logfile(4," Finished job '".$lang['wihladm31']."' (".$lang['wisupidle'].": ".$lang['wihladm312'].")");
|
||||
}
|
||||
} else {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='3' WHERE `job_name`='reset_user_delete';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_user_delete']['timestamp'] = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($db_cache['job_check']['reset_webspace_cache']['timestamp'], ["1","2"], true)) {
|
||||
if (in_array(intval($db_cache['job_check']['reset_webspace_cache']['timestamp']), [1,2], true)) {
|
||||
if ($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='2' WHERE `job_name`='reset_webspace_cache';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_webspace_cache']['timestamp'] = 2;
|
||||
enter_logfile($cfg,4," Started job '".$lang['wihladm33']."'");
|
||||
enter_logfile(4," Started job '".$lang['wihladm33']."'");
|
||||
if ($mysqlcon->exec("DELETE FROM `$dbname`.`groups`;") === false) {
|
||||
enter_logfile($cfg,4," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(4," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`=1 WHERE `job_name`='reload_trigger';") === false) {
|
||||
enter_logfile($cfg,4," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(4," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$del_folder = array('avatars/','tsicons/');
|
||||
$del_folder = array('avatars'.DIRECTORY_SEPARATOR,'tsicons'.DIRECTORY_SEPARATOR);
|
||||
$err_cnt = 0;
|
||||
|
||||
if (!function_exists('rm_file_reset')) {
|
||||
@@ -218,9 +218,9 @@ function reset_rs($ts3,$mysqlcon,$lang,$cfg,$dbname,$phpcommand,&$db_cache) {
|
||||
foreach(scandir($folder) as $file) {
|
||||
if (in_array($file, array('.','..','check.png','placeholder.png','rs.png','servericon.png','100.png','200.png','300.png','500.png','600.png')) || is_dir($folder.$file)) continue;
|
||||
if(unlink($folder.$file)) {
|
||||
enter_logfile($cfg,4," File ".$folder.$file." successfully deleted.");
|
||||
enter_logfile(4," File ".$folder.$file." successfully deleted.");
|
||||
} else {
|
||||
enter_logfile($cfg,2," File ".$folder.$file." couldn't be deleted. Please check the file permissions.");
|
||||
enter_logfile(2," File ".$folder.$file." couldn't be deleted. Please check the file permissions.");
|
||||
$err_cnt++;
|
||||
}
|
||||
}
|
||||
@@ -228,21 +228,21 @@ function reset_rs($ts3,$mysqlcon,$lang,$cfg,$dbname,$phpcommand,&$db_cache) {
|
||||
}
|
||||
|
||||
foreach ($del_folder as $folder) {
|
||||
if(is_dir(substr(__DIR__,0,-4).$folder)) {
|
||||
rm_file_reset(substr(__DIR__,0,-4).$folder,$cfg);
|
||||
if(is_dir(dirname(__DIR__).DIRECTORY_SEPARATOR.$folder)) {
|
||||
rm_file_reset(dirname(__DIR__).DIRECTORY_SEPARATOR.$folder,$cfg);
|
||||
}
|
||||
}
|
||||
|
||||
if ($err_cnt == 0) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='4' WHERE `job_name`='reset_webspace_cache';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_webspace_cache']['timestamp'] = 4;
|
||||
enter_logfile($cfg,4," Finished job '".$lang['wihladm33']."'");
|
||||
enter_logfile(4," Finished job '".$lang['wihladm33']."'");
|
||||
}
|
||||
} else {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='3' WHERE `job_name`='reset_webspace_cache';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_webspace_cache']['timestamp'] = 3;
|
||||
}
|
||||
@@ -250,45 +250,44 @@ function reset_rs($ts3,$mysqlcon,$lang,$cfg,$dbname,$phpcommand,&$db_cache) {
|
||||
}
|
||||
|
||||
|
||||
if (in_array($db_cache['job_check']['reset_usage_graph']['timestamp'], ["1","2"], true)) {
|
||||
if (in_array(intval($db_cache['job_check']['reset_usage_graph']['timestamp']), [1,2], true)) {
|
||||
if ($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='2' WHERE `job_name`='reset_usage_graph';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_usage_graph']['timestamp'] = 2;
|
||||
enter_logfile($cfg,4," Started job '".$lang['wihladm34']."'");
|
||||
enter_logfile(4," Started job '".$lang['wihladm34']."'");
|
||||
}
|
||||
if ($mysqlcon->exec("DELETE FROM `$dbname`.`server_usage`;") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='3' WHERE `job_name`='reset_usage_graph';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_usage_graph']['timestamp'] = 3;
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,4," Cleaned server usage graph (table: server_usage)");
|
||||
enter_logfile(4," Cleaned server usage graph (table: server_usage)");
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='4' WHERE `job_name`='reset_usage_graph';") === false) {
|
||||
enter_logfile($cfg,2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2," Executing SQL commands failed: ".print_r($mysqlcon->errorInfo(), true));
|
||||
} else {
|
||||
$db_cache['job_check']['reset_usage_graph']['timestamp'] = 4;
|
||||
enter_logfile($cfg,4," Finished job '".$lang['wihladm34']."'");
|
||||
enter_logfile(4," Finished job '".$lang['wihladm34']."'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enter_logfile($cfg,4,"Reset job(s) finished");
|
||||
enter_logfile(4,"Reset job(s) finished");
|
||||
|
||||
if($db_cache['job_check']['reset_stop_after']['timestamp'] == "1") {
|
||||
$path = substr(__DIR__, 0, -4);
|
||||
if(intval($db_cache['job_check']['reset_stop_after']['timestamp']) == 1) {
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
pclose(popen("start /B cmd /C ".$phpcommand." ".$path."worker.php stop >NUL 2>NUL", "r"));
|
||||
file_put_contents($path.'logs\autostart_deactivated',"");
|
||||
pclose(popen("start /B cmd /C ".$phpcommand." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php stop >NUL 2>NUL", "r"));
|
||||
file_put_contents($GLOBALS['autostart'],"");
|
||||
} else {
|
||||
exec($phpcommand." ".$path."worker.php stop > /dev/null &");
|
||||
file_put_contents($path.'logs/autostart_deactivated',"");
|
||||
exec($phpcommand." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php stop > /dev/null &");
|
||||
file_put_contents($GLOBALS['autostart'],"");
|
||||
}
|
||||
shutdown($mysqlcon,$cfg,4,"Stop requested after Reset job. Wait for manually start.");
|
||||
shutdown($mysqlcon,4,"Stop requested after Reset job. Wait for manually start.");
|
||||
}
|
||||
}
|
||||
enter_logfile($cfg,6,"reset_rs needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"reset_rs needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
}
|
||||
?>
|
||||
@@ -10,11 +10,11 @@ function server_usage($mysqlcon,$cfg,$dbname,$serverinfo,&$db_cache) {
|
||||
$db_cache['max_timestamp_server_usage'][$nowtime] = '';
|
||||
|
||||
//Calc time next rankup
|
||||
enter_logfile($cfg,6,"Calc next rankup for offline user");
|
||||
enter_logfile(6,"Calc next rankup for offline user");
|
||||
$upnextuptime = $nowtime - 1800;
|
||||
$server_used_slots = $serverinfo['virtualserver_clientsonline'] - $serverinfo['virtualserver_queryclientsonline'];
|
||||
if(($uuidsoff = $mysqlcon->query("SELECT `uuid`,`idle`,`count` FROM `$dbname`.`user` WHERE `online`<>1 AND `lastseen`>$upnextuptime")->fetchAll(PDO::FETCH_ASSOC)) === false) {
|
||||
enter_logfile($cfg,2,"calc_serverstats 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
enter_logfile(2,"calc_serverstats 13:".print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
if(count($uuidsoff) != 0) {
|
||||
foreach($uuidsoff as $uuid) {
|
||||
@@ -60,9 +60,9 @@ function server_usage($mysqlcon,$cfg,$dbname,$serverinfo,&$db_cache) {
|
||||
} else {
|
||||
$sqlexec .= "INSERT INTO `$dbname`.`server_usage` (`timestamp`,`clients`,`channel`) VALUES ($nowtime,$server_used_slots,{$serverinfo['virtualserver_channelsonline']});\n";
|
||||
}
|
||||
enter_logfile($cfg,6,"Calc next rankup for offline user [DONE]");
|
||||
enter_logfile(6,"Calc next rankup for offline user [DONE]");
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"server_usage needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"server_usage needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ function update_channel($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
if($db_cache['job_check']['update_channel']['timestamp'] < ($nowtime - 7)) {
|
||||
if(intval($db_cache['job_check']['update_channel']['timestamp']) < ($nowtime - 7)) {
|
||||
$db_cache['job_check']['update_channel']['timestamp'] = $nowtime;
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`={$nowtime} WHERE `job_name`='update_channel';\n";
|
||||
|
||||
@@ -20,10 +20,10 @@ function update_channel($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache
|
||||
$db_cache['channel'][$channel['cid']]['pid'] == $channel['pid'] &&
|
||||
$db_cache['channel'][$channel['cid']]['channel_order'] == $channel['channel_order'] &&
|
||||
$db_cache['channel'][$channel['cid']]['channel_name'] == $chname) {
|
||||
enter_logfile($cfg,7,"Continue channel ".$chname." (CID: ".$channel['cid'].")");
|
||||
enter_logfile(7,"Continue channel ".$chname." (CID: ".$channel['cid'].")");
|
||||
continue;
|
||||
} else {
|
||||
enter_logfile($cfg,6,"Update/Insert channel ".$chname." (CID: ".$channel['cid'].")");
|
||||
enter_logfile(6,"Update/Insert channel ".$chname." (CID: ".$channel['cid'].")");
|
||||
$updatechannel[] = array(
|
||||
"cid" => $channel['cid'],
|
||||
"pid" => $channel['pid'],
|
||||
@@ -46,7 +46,7 @@ function update_channel($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache
|
||||
unset($updatechannel, $sqlinsertvalues);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.$lang['errgrplist'].$e->getMessage());
|
||||
enter_logfile(2,$lang['errorts3'].$e->getCode().': '.$lang['errgrplist'].$e->getMessage());
|
||||
}
|
||||
|
||||
if(isset($db_cache['channel'])) {
|
||||
@@ -62,10 +62,10 @@ function update_channel($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache
|
||||
if(isset($delchannel) && $delchannel != NULL) {
|
||||
$delchannel = substr($delchannel, 0, -1);
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`channel` WHERE `cid` IN ($delchannel);\n";
|
||||
enter_logfile($cfg,6,"DELETE FROM `$dbname`.`channel` WHERE `cid` IN ($delchannel);");
|
||||
enter_logfile(6,"DELETE FROM `$dbname`.`channel` WHERE `cid` IN ($delchannel);");
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6,"update_channel needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"update_channel needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
if($db_cache['job_check']['update_groups']['timestamp'] < ($nowtime - 6)) {
|
||||
if(!isset($db_cache['job_check']['update_groups']['timestamp']) || intval($db_cache['job_check']['update_groups']['timestamp']) < ($nowtime - 6)) {
|
||||
$db_cache['job_check']['update_groups']['timestamp'] = $nowtime;
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`={$nowtime} WHERE `job_name`='update_groups';\n";
|
||||
try {
|
||||
@@ -22,10 +22,10 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
unset($iconlist);
|
||||
} catch (Exception $e) {
|
||||
if ($e->getCode() != 1281) {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.$lang['errgrplist'].$e->getMessage());
|
||||
enter_logfile(2,$lang['errorts3'].$e->getCode().': '.$lang['errgrplist'].$e->getMessage());
|
||||
} else {
|
||||
$iconarr["xxxxx"] = 0;
|
||||
enter_logfile($cfg,6,$lang['errorts3'].$e->getCode().': '.$lang['errgrplist'].$e->getMessage());
|
||||
enter_logfile(6,$lang['errorts3'].$e->getCode().': '.$lang['errgrplist'].$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,28 +41,28 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
$extension = '';
|
||||
if (!isset($db_cache['groups']['0']) || $db_cache['groups']['0']['iconid'] != $sIconId || (isset($iconarr["i".$sIconId]) && $iconarr["i".$sIconId] > $db_cache['groups']['0']['icondate'])) {
|
||||
if(isset($db_cache['groups']['0']) && isset($iconarr["i".$sIconId])) {
|
||||
enter_logfile($cfg,6,"Servericon TSiconid:".$serverinfo['virtualserver_icon_id']."; powed TSiconid:".$sIconId."; DBiconid:".$db_cache['groups']['0']['iconid']."; TSicondate:".$iconarr["i".$sIconId]."; DBicondate:".$db_cache['groups']['0']['icondate'].";");
|
||||
enter_logfile(6,"Servericon TSiconid:".$serverinfo['virtualserver_icon_id']."; powed TSiconid:".$sIconId."; DBiconid:".$db_cache['groups']['0']['iconid']."; TSicondate:".$iconarr["i".$sIconId]."; DBicondate:".$db_cache['groups']['0']['icondate'].";");
|
||||
} else {
|
||||
enter_logfile($cfg,6,"Servericon TSiconid:".$serverinfo['virtualserver_icon_id']."; powed TSiconid:".$sIconId."; DBiconid: empty; TSicondate: empty; DBicondate: empty;");
|
||||
enter_logfile(6,"Servericon TSiconid:".$serverinfo['virtualserver_icon_id']."; powed TSiconid:".$sIconId."; DBiconid: empty; TSicondate: empty; DBicondate: empty;");
|
||||
}
|
||||
if($sIconId > 600) {
|
||||
try {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
enter_logfile($cfg,5,$lang['upgrp0002']);
|
||||
enter_logfile(5,$lang['upgrp0002']);
|
||||
$sIconFile = $ts3->iconDownload();
|
||||
$extension = mime2extension(TeamSpeak3_Helper_Convert::imageMimeType($sIconFile));
|
||||
if(file_put_contents(substr(dirname(__FILE__),0,-4) . "tsicons/servericon." . $extension, $sIconFile) === false) {
|
||||
enter_logfile($cfg,2,$lang['upgrp0003'].' '.sprintf($lang['errperm'], 'tsicons'));
|
||||
enter_logfile(2,$lang['upgrp0003'].' '.sprintf($lang['errperm'], 'tsicons'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().'; '.$lang['upgrp0004'].$e->getMessage());
|
||||
enter_logfile(2,$lang['errorts3'].$e->getCode().'; '.$lang['upgrp0004'].$e->getMessage());
|
||||
}
|
||||
} elseif($sIconId == 0) {
|
||||
foreach (glob(substr(dirname(__FILE__),0,-4) . "tsicons/servericon.*") as $file) {
|
||||
if(unlink($file) === false) {
|
||||
enter_logfile($cfg,2,$lang['upgrp0005'].' '.sprintf($lang['errperm'], 'tsicons'));
|
||||
enter_logfile(2,$lang['upgrp0005'].' '.sprintf($lang['errperm'], 'tsicons'));
|
||||
} else {
|
||||
enter_logfile($cfg,5,$lang['upgrp0006']);
|
||||
enter_logfile(5,$lang['upgrp0006']);
|
||||
}
|
||||
}
|
||||
$iconarr["i".$sIconId] = $sIconId = 0;
|
||||
@@ -101,16 +101,16 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
if($iconid > 600) {
|
||||
if (!isset($db_cache['groups'][$sgid]) || $db_cache['groups'][$sgid]['iconid'] != $iconid || isset($iconarr["i".$iconid]) && $iconarr["i".$iconid] > $db_cache['groups'][$sgid]['icondate']) {
|
||||
try {
|
||||
check_shutdown($cfg); usleep($cfg['teamspeak_query_command_delay']);
|
||||
enter_logfile($cfg,5,sprintf($lang['upgrp0011'], $sgname, $sgid));
|
||||
check_shutdown(); usleep($cfg['teamspeak_query_command_delay']);
|
||||
enter_logfile(5,sprintf($lang['upgrp0011'], $sgname, $sgid));
|
||||
$iconfile = $servergroup->iconDownload();
|
||||
$extension = mime2extension(TeamSpeak3_Helper_Convert::imageMimeType($iconfile));
|
||||
if(file_put_contents(substr(dirname(__FILE__),0,-4) . "tsicons/" . $iconid . "." . $extension, $iconfile) === false) {
|
||||
enter_logfile($cfg,2,sprintf($lang['upgrp0007'], $sgname, $sgid).' '.sprintf($lang['errperm'], 'tsicons'));
|
||||
enter_logfile(2,sprintf($lang['upgrp0007'], $sgname, $sgid).' '.sprintf($lang['errperm'], 'tsicons'));
|
||||
}
|
||||
$iconcount++;
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.sprintf($lang['upgrp0008'], $sgname, $sgid).$e->getMessage());
|
||||
enter_logfile(2,$lang['errorts3'].$e->getCode().': '.sprintf($lang['upgrp0008'], $sgname, $sgid).$e->getMessage());
|
||||
}
|
||||
} else {
|
||||
$extension = $db_cache['groups'][$sgid]['ext'];
|
||||
@@ -118,9 +118,9 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
} elseif($iconid == 0) {
|
||||
foreach (glob(substr(dirname(__FILE__),0,-4) . "tsicons/" . $iconid . ".*") as $file) {
|
||||
if(unlink($file) === false) {
|
||||
enter_logfile($cfg,2,sprintf($lang['upgrp0009'], $sgname, $sgid).' '.sprintf($lang['errperm'], 'tsicons'));
|
||||
enter_logfile(2,sprintf($lang['upgrp0009'], $sgname, $sgid).' '.sprintf($lang['errperm'], 'tsicons'));
|
||||
} else {
|
||||
enter_logfile($cfg,5,sprintf($lang['upgrp0010'], $sgname, $sgid));
|
||||
enter_logfile(5,sprintf($lang['upgrp0010'], $sgname, $sgid));
|
||||
}
|
||||
}
|
||||
$iconarr["i".$iconid] = 0;
|
||||
@@ -133,10 +133,10 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
}
|
||||
|
||||
if(isset($db_cache['groups'][$servergroup['sgid']]) && $db_cache['groups'][$servergroup['sgid']]['sgidname'] == $sgname && $db_cache['groups'][$servergroup['sgid']]['iconid'] == $iconid && $db_cache['groups'][$servergroup['sgid']]['icondate'] == $iconarr["i".$iconid] && $db_cache['groups'][$servergroup['sgid']]['sortid'] == $servergroup['sortid']) {
|
||||
enter_logfile($cfg,7,"Continue server group ".$sgname." (CID: ".$servergroup['sgid'].")");
|
||||
enter_logfile(7,"Continue server group ".$sgname." (CID: ".$servergroup['sgid'].")");
|
||||
continue;
|
||||
} else {
|
||||
enter_logfile($cfg,6,"Update/Insert server group ".$sgname." (CID: ".$servergroup['sgid'].")");
|
||||
enter_logfile(6,"Update/Insert server group ".$sgname." (CID: ".$servergroup['sgid'].")");
|
||||
$updategroups[] = array(
|
||||
"sgid" => $servergroup['sgid'],
|
||||
"sgidname" => $sgname,
|
||||
@@ -177,14 +177,14 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
foreach($cfg['rankup_definition'] as $rank) {
|
||||
if(in_array($sgid, $rank)) {
|
||||
if(in_array($sgid, $cfg['rankup_definition'])) {
|
||||
enter_logfile($cfg,2,sprintf($lang['upgrp0001'], $sgid, $lang['wigrptime']));
|
||||
enter_logfile(2,sprintf($lang['upgrp0001'], $sgid, $lang['wigrptime']));
|
||||
if(isset($cfg['webinterface_admin_client_unique_id_list']) && $cfg['webinterface_admin_client_unique_id_list'] != NULL) {
|
||||
foreach ($cfg['webinterface_admin_client_unique_id_list'] as $clientid) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upgrp0001'], $sgid, $lang['wigrptime']));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
enter_logfile(6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,27 +192,27 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
}
|
||||
}
|
||||
if(isset($cfg['rankup_boost_definition'][$sgid])) {
|
||||
enter_logfile($cfg,2,sprintf($lang['upgrp0001'], $sgid, $lang['wiboost']));
|
||||
enter_logfile(2,sprintf($lang['upgrp0001'], $sgid, $lang['wiboost']));
|
||||
if(isset($cfg['webinterface_admin_client_unique_id_list']) && $cfg['webinterface_admin_client_unique_id_list'] != NULL) {
|
||||
foreach ($cfg['webinterface_admin_client_unique_id_list'] as $clientid) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upgrp0001'], $sgid, $lang['wigrptime']));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
enter_logfile(6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($cfg['rankup_excepted_group_id_list'][$sgid])) {
|
||||
enter_logfile($cfg,2,sprintf($lang['upgrp0001'], $sgid, $lang['wiexgrp']));
|
||||
enter_logfile(2,sprintf($lang['upgrp0001'], $sgid, $lang['wiexgrp']));
|
||||
if(isset($cfg['webinterface_admin_client_unique_id_list']) && $cfg['webinterface_admin_client_unique_id_list'] != NULL) {
|
||||
foreach ($cfg['webinterface_admin_client_unique_id_list'] as $clientid) {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
try {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upgrp0001'], $sgid, $lang['wigrptime']));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
enter_logfile(6," ".sprintf($lang['upusrerr'], $clientid));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,11 +225,11 @@ function update_groups($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,
|
||||
$delsgroupids = substr($delsgroupids, 0, -1);
|
||||
$sqlexec .= "DELETE FROM `$dbname`.`groups` WHERE `sgid` IN ($delsgroupids);\n";
|
||||
}
|
||||
enter_logfile($cfg,6,"update_groups needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
enter_logfile(6,"update_groups needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
|
||||
return($sqlexec);
|
||||
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.$lang['errgrplist'].$e->getMessage());
|
||||
enter_logfile(2,$lang['errorts3'].$e->getCode().': '.$lang['errgrplist'].$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
<?PHP
|
||||
function update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand,$norotate=NULL) {
|
||||
function update_rs($mysqlcon,$lang,$cfg,$dbname,$norotate=NULL) {
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
$norotate = true;
|
||||
enter_logfile($cfg,4," Start updating the Ranksystem...",$norotate);
|
||||
enter_logfile($cfg,4," Backup the database due cloning tables...",$norotate);
|
||||
enter_logfile(4," Start updating the Ranksystem...",$norotate);
|
||||
enter_logfile(4," Backup the database due cloning tables...",$norotate);
|
||||
$countbackuperr = 0;
|
||||
|
||||
$tables = array('addons_config','cfg_params','groups','job_check','server_usage','stats_server','stats_user','user','user_snapshot');
|
||||
$tables = array('addon_assign_groups','addons_config','admin_addtime','cfg_params','channel','csrf_token','groups','job_check','server_usage','stats_nations','stats_platforms','stats_server','stats_user','stats_versions','user','user_iphash','user_snapshot');
|
||||
|
||||
foreach ($tables as $table) {
|
||||
try {
|
||||
if($mysqlcon->query("SELECT 1 FROM `$dbname`.`bak_$table` LIMIT 1") !== false) {
|
||||
if($mysqlcon->exec("DROP TABLE `$dbname`.`bak_$table`") === false) {
|
||||
enter_logfile($cfg,1," Error due deleting old backup table bak_".$table.".",$norotate);
|
||||
enter_logfile(1," Error due deleting old backup table bak_".$table.".",$norotate);
|
||||
$countbackuperr++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Old backup table bak_".$table." successfully removed.",$norotate);
|
||||
enter_logfile(4," Old backup table bak_".$table." successfully removed.",$norotate);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) { }
|
||||
@@ -24,47 +24,47 @@ function update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand,$norotate=NULL) {
|
||||
|
||||
foreach ($tables as $table) {
|
||||
if($mysqlcon->exec("CREATE TABLE `$dbname`.`bak_$table` LIKE `$dbname`.`$table`") === false) {
|
||||
enter_logfile($cfg,1," Error due creating table bak_".$table.".",$norotate);
|
||||
enter_logfile(1," Error due creating table bak_".$table.".",$norotate);
|
||||
$countbackuperr++;
|
||||
} else {
|
||||
if($mysqlcon->exec("INSERT `$dbname`.`bak_$table` SELECT * FROM `$dbname`.`$table`") === false) {
|
||||
enter_logfile($cfg,1," Error due inserting data from table ".$table.".",$norotate);
|
||||
enter_logfile(1," Error due inserting data from table ".$table.".",$norotate);
|
||||
$countbackuperr++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Table ".$table." successfully cloned.",$norotate);
|
||||
enter_logfile(4," Table ".$table." successfully cloned.",$norotate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($countbackuperr != 0) {
|
||||
enter_logfile($cfg,4," Backup failed. Please check your database permissions.",$norotate);
|
||||
enter_logfile($cfg,4," Update failed. Go on with normal work on old version.",$norotate);
|
||||
enter_logfile(4," Backup failed. Please check your database permissions.",$norotate);
|
||||
enter_logfile(4," Update failed. Go on with normal work on old version.",$norotate);
|
||||
return;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Database-tables successfully backuped.",$norotate);
|
||||
enter_logfile(4," Database-tables successfully backuped.",$norotate);
|
||||
}
|
||||
|
||||
if(!is_file(substr(__DIR__,0,-4).'update/ranksystem_'.$cfg['version_latest_available'].'.zip')) {
|
||||
enter_logfile($cfg,4," Downloading new update...",$norotate);
|
||||
if(!is_file(dirname(__DIR__).DIRECTORY_SEPARATOR.'update/ranksystem_'.$cfg['version_latest_available'].'.zip')) {
|
||||
enter_logfile(4," Downloading new update...",$norotate);
|
||||
$newUpdate = file_get_contents('https://ts-n.net/downloads/ranksystem_'.$cfg['version_latest_available'].'.zip');
|
||||
if(!is_dir(substr(__DIR__,0,-4).'update/')) {
|
||||
mkdir (substr(__DIR__,0,-4).'update/');
|
||||
if(!is_dir(dirname(__DIR__).DIRECTORY_SEPARATOR.'update/')) {
|
||||
mkdir (dirname(__DIR__).DIRECTORY_SEPARATOR.'update/');
|
||||
}
|
||||
$dlHandler = fopen(substr(__DIR__,0,-4).'update/ranksystem_'.$cfg['version_latest_available'].'.zip', 'w');
|
||||
$dlHandler = fopen(dirname(__DIR__).DIRECTORY_SEPARATOR.'update/ranksystem_'.$cfg['version_latest_available'].'.zip', 'w');
|
||||
if(!fwrite($dlHandler,$newUpdate)) {
|
||||
enter_logfile($cfg,1," Could not save new update. Please check the permissions for folder 'update'.",$norotate);
|
||||
enter_logfile($cfg,4," Update failed. Go on with normal work on old version.",$norotate);
|
||||
enter_logfile(1," Could not save new update. Please check the permissions for folder 'update'.",$norotate);
|
||||
enter_logfile(4," Update failed. Go on with normal work on old version.",$norotate);
|
||||
return;
|
||||
}
|
||||
if(!is_file(substr(__DIR__,0,-4).'update/ranksystem_'.$cfg['version_latest_available'].'.zip')) {
|
||||
enter_logfile($cfg,4," Something gone wrong with downloading/saving the new update file.",$norotate);
|
||||
enter_logfile($cfg,4," Update failed. Go on with normal work on old version.",$norotate);
|
||||
if(!is_file(dirname(__DIR__).DIRECTORY_SEPARATOR.'update/ranksystem_'.$cfg['version_latest_available'].'.zip')) {
|
||||
enter_logfile(4," Something gone wrong with downloading/saving the new update file.",$norotate);
|
||||
enter_logfile(4," Update failed. Go on with normal work on old version.",$norotate);
|
||||
return;
|
||||
}
|
||||
fclose($dlHandler);
|
||||
enter_logfile($cfg,4," New update successfully saved.",$norotate);
|
||||
enter_logfile(4," New update successfully saved.",$norotate);
|
||||
} else {
|
||||
enter_logfile($cfg,5," New update file (update/ranksystem_".$cfg['version_latest_available'].".zip) already here...",$norotate);
|
||||
enter_logfile(5," New update file (update/ranksystem_".$cfg['version_latest_available'].".zip) already here...",$norotate);
|
||||
}
|
||||
|
||||
$countwrongfiles = 0;
|
||||
@@ -72,63 +72,63 @@ function update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand,$norotate=NULL) {
|
||||
|
||||
$zip = new ZipArchive;
|
||||
|
||||
if($zip->open(substr(__DIR__,0,-4).'update/ranksystem_'.$cfg['version_latest_available'].'.zip')) {
|
||||
if($zip->open(dirname(__DIR__).DIRECTORY_SEPARATOR.'update/ranksystem_'.$cfg['version_latest_available'].'.zip')) {
|
||||
for ($i = 0; $i < $zip->numFiles; $i++) {
|
||||
$thisFileName = $zip->getNameIndex($i);
|
||||
$thisFileDir = dirname($thisFileName);
|
||||
enter_logfile($cfg,6," Parent directory: ".$thisFileDir,$norotate);
|
||||
enter_logfile($cfg,6," File/Dir: ".$thisFileName,$norotate);
|
||||
enter_logfile(6," Parent directory: ".$thisFileDir,$norotate);
|
||||
enter_logfile(6," File/Dir: ".$thisFileName,$norotate);
|
||||
|
||||
if(substr($thisFileName,-1,1) == '/' || substr($thisFileName,-1,1) == '\\') {
|
||||
enter_logfile($cfg,6," Check folder is existing: ".$thisFileName,$norotate);
|
||||
if(!is_dir(substr(__DIR__,0,-4).substr($thisFileName,0,-1))) {
|
||||
enter_logfile($cfg,5," Create folder: ".substr(__DIR__,0,-4).substr($thisFileName,0,-1),$norotate);
|
||||
if(mkdir((substr(__DIR__,0,-4).substr($thisFileName,0,-1)), 0740, true)) {
|
||||
enter_logfile($cfg,4," Created new folder ".substr(__DIR__,0,-4).substr($thisFileName,0,-1),$norotate);
|
||||
enter_logfile(6," Check folder is existing: ".$thisFileName,$norotate);
|
||||
if(!is_dir(dirname(__DIR__).DIRECTORY_SEPARATOR.substr($thisFileName,0,-1))) {
|
||||
enter_logfile(5," Create folder: ".dirname(__DIR__).DIRECTORY_SEPARATOR.substr($thisFileName,0,-1),$norotate);
|
||||
if(mkdir((dirname(__DIR__).DIRECTORY_SEPARATOR.substr($thisFileName,0,-1)), 0750, true)) {
|
||||
enter_logfile(4," Created new folder ".dirname(__DIR__).DIRECTORY_SEPARATOR.substr($thisFileName,0,-1),$norotate);
|
||||
} else {
|
||||
enter_logfile($cfg,2," Error by creating folder ".substr(__DIR__,0,-4).substr($thisFileName,0,-1).". Please check the permissions on the folder one level above.",$norotate);
|
||||
enter_logfile(2," Error by creating folder ".dirname(__DIR__).DIRECTORY_SEPARATOR.substr($thisFileName,0,-1).". Please check the permissions on the folder one level above.",$norotate);
|
||||
$countwrongfiles++;
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,6," Folder still existing.",$norotate);
|
||||
enter_logfile(6," Folder still existing.",$norotate);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!is_dir(substr(__DIR__,0,-4).'/'.$thisFileDir)) {
|
||||
enter_logfile($cfg,6," Check parent folder is existing: ".$thisFileDir,$norotate);
|
||||
if(mkdir(substr(__DIR__,0,-4).$thisFileDir, 0740, true)) {
|
||||
enter_logfile($cfg,4," Created new folder ".$thisFileDir,$norotate);
|
||||
if(!is_dir(dirname(__DIR__).DIRECTORY_SEPARATOR.$thisFileDir)) {
|
||||
enter_logfile(6," Check parent folder is existing: ".$thisFileDir,$norotate);
|
||||
if(mkdir(dirname(__DIR__).DIRECTORY_SEPARATOR.$thisFileDir, 0750, true)) {
|
||||
enter_logfile(4," Created new folder ".$thisFileDir,$norotate);
|
||||
} else {
|
||||
enter_logfile($cfg,2," Error by creating folder ".$thisFileDir.". Please check the permissions on your folder ".substr(__DIR__,0,-4),$norotate);
|
||||
enter_logfile(2," Error by creating folder ".$thisFileDir.". Please check the permissions on your folder ".dirname(__DIR__),$norotate);
|
||||
$countwrongfiles++;
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,6," Parent folder still existing.",$norotate);
|
||||
enter_logfile(6," Parent folder still existing.",$norotate);
|
||||
}
|
||||
|
||||
enter_logfile($cfg,6," Check file: ".substr(__DIR__,0,-4).$thisFileName,$norotate);
|
||||
if(!is_dir(substr(__DIR__,0,-4).$thisFileName)) {
|
||||
enter_logfile(6," Check file: ".dirname(__DIR__).DIRECTORY_SEPARATOR.$thisFileName,$norotate);
|
||||
if(!is_dir(dirname(__DIR__).DIRECTORY_SEPARATOR.$thisFileName)) {
|
||||
$contents = $zip->getFromName($thisFileName);
|
||||
$updateThis = '';
|
||||
if($thisFileName == 'other/dbconfig.php' || $thisFileName == 'install.php' || $thisFileName == 'other/phpcommand.php' || $thisFileName == 'logs/autostart_deactivated') {
|
||||
enter_logfile($cfg,5," Did not touch ".$thisFileName,$norotate);
|
||||
enter_logfile(5," Did not touch ".$thisFileName,$norotate);
|
||||
} else {
|
||||
if(($updateThis = fopen(substr(__DIR__,0,-4).'/'.$thisFileName, 'w')) === false) {
|
||||
enter_logfile($cfg,2," Failed to open file ".$thisFileName,$norotate);
|
||||
if(($updateThis = fopen(dirname(__DIR__).DIRECTORY_SEPARATOR.$thisFileName, 'w')) === false) {
|
||||
enter_logfile(2," Failed to open file ".$thisFileName,$norotate);
|
||||
$countwrongfiles++;
|
||||
} elseif(!fwrite($updateThis, $contents)) {
|
||||
enter_logfile($cfg,2," Failed to write file ".$thisFileName,$norotate);
|
||||
enter_logfile(2," Failed to write file ".$thisFileName,$norotate);
|
||||
$countwrongfiles++;
|
||||
} else {
|
||||
enter_logfile($cfg,4," Replaced file ".$thisFileName,$norotate);
|
||||
enter_logfile(4," Replaced file ".$thisFileName,$norotate);
|
||||
$countchangedfiles++;
|
||||
}
|
||||
fclose($updateThis);
|
||||
unset($contents);
|
||||
}
|
||||
} else {
|
||||
enter_logfile($cfg,2," Unkown thing happened.. Is the parent directory existing? ".$thisFileDir." # ".$thisFileName,$norotate);
|
||||
enter_logfile(2," Unknown thing happened.. Is the parent directory existing? ".$thisFileDir." # ".$thisFileName,$norotate);
|
||||
$countwrongfiles++;
|
||||
}
|
||||
}
|
||||
@@ -137,39 +137,37 @@ function update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand,$norotate=NULL) {
|
||||
unset($zip);
|
||||
sleep(1);
|
||||
} else {
|
||||
enter_logfile($cfg,2," Error with downloaded Zip file happened. Is the file inside the folder 'update' valid and readable?",$norotate);
|
||||
enter_logfile(2," Error with downloaded Zip file happened. Is the file inside the folder 'update' valid and readable?",$norotate);
|
||||
$countwrongfiles++;
|
||||
}
|
||||
|
||||
if(!unlink(substr(__DIR__,0,-4).'update/ranksystem_'.$cfg['version_latest_available'].'.zip')) {
|
||||
enter_logfile($cfg,3," Could not clean update folder. Please remove the unneeded file ".substr(__DIR__,0,-4)."update/ranksystem_".$cfg['version_latest_available'].".zip",$norotate);
|
||||
if(!unlink(dirname(__DIR__).DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'ranksystem_'.$cfg['version_latest_available'].'.zip')) {
|
||||
enter_logfile(3," Could not clean update folder. Please remove the unneeded file ".dirname(__DIR__).DIRECTORY_SEPARATOR."update".DIRECTORY_SEPARATOR."ranksystem_".$cfg['version_latest_available'].".zip",$norotate);
|
||||
} else {
|
||||
enter_logfile($cfg,5," Cleaned update folder.",$norotate);
|
||||
enter_logfile(5," Cleaned update folder.",$norotate);
|
||||
}
|
||||
|
||||
if($countwrongfiles == 0 && $countchangedfiles != 0) {
|
||||
$sqlexec .= "UPDATE `$dbname`.`cfg_params` SET `value`='{$cfg['version_latest_available']}' WHERE `param`='version_latest_available';\n";
|
||||
|
||||
$path = substr(__DIR__, 0, -4);
|
||||
|
||||
if (file_exists($cfg['logs_path'].'pid')) {
|
||||
unlink($cfg['logs_path'].'pid');
|
||||
if (file_exists($GLOBALS['pidfile'])) {
|
||||
unlink($GLOBALS['pidfile']);
|
||||
}
|
||||
|
||||
enter_logfile($cfg,4," Files updated successfully.",$norotate);
|
||||
enter_logfile(4," Files updated successfully.",$norotate);
|
||||
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
pclose(popen("start /B cmd /C ".$phpcommand." ".$path."worker.php start 1500000 >NUL 2>NUL", "r"));
|
||||
pclose(popen("start /B cmd /C ".$GLOBALS['phpcommand']." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php start 1500000 >NUL 2>NUL", "r"));
|
||||
} else {
|
||||
exec($phpcommand." ".$path."worker.php start 2500000 > /dev/null 2>&1 &");
|
||||
exec($GLOBALS['phpcommand']." ".dirname(__DIR__).DIRECTORY_SEPARATOR."worker.php start 2500000 > /dev/null 2>&1 &");
|
||||
}
|
||||
|
||||
shutdown($mysqlcon,$cfg,4,"Update done. Wait for restart via cron/task.",FALSE);
|
||||
shutdown($mysqlcon,4,"Update done. Wait for restart via cron/task.",FALSE);
|
||||
|
||||
} else {
|
||||
enter_logfile($cfg,1," Files updated with at least one error. Please check the log!",$norotate);
|
||||
enter_logfile($cfg,2,"Update of the Ranksystem failed!",$norotate);
|
||||
enter_logfile($cfg,4,"Continue with normal work on old version.",$norotate);
|
||||
enter_logfile(1," Files updated with at least one error. Please check the log!",$norotate);
|
||||
enter_logfile(2,"Update of the Ranksystem failed!",$norotate);
|
||||
enter_logfile(4,"Continue with normal work on old version.",$norotate);
|
||||
}
|
||||
|
||||
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='get_version';\n";
|
||||
|
||||
Reference in New Issue
Block a user