release 1.3.19
This commit is contained in:
145
jobs/addon_channelinfo_toplist.php
Normal file
145
jobs/addon_channelinfo_toplist.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?PHP
|
||||
function addon_channelinfo_toplist(&$addons_config,$ts3,$mysqlcon,$cfg,$dbname,$lang,&$db_cache) {
|
||||
$sqlexec = '';
|
||||
$nowtime = time();
|
||||
|
||||
$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');
|
||||
|
||||
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'])) {
|
||||
|
||||
switch($addons_config['channelinfo_toplist_modus']['value']) {
|
||||
case 1: $filter = "ORDER BY (`count_week`-`idle_week`)"; break;
|
||||
case 2: $filter = "ORDER BY `count_week`"; break;
|
||||
case 3: $filter = "ORDER BY (`count_month`-`idle_month`)"; break;
|
||||
case 4: $filter = "ORDER BY `count_month`"; break;
|
||||
case 5: $filter = "ORDER BY (`count`-`idle`)"; break;
|
||||
case 6: $filter = "ORDER BY `count`"; break;
|
||||
default: $filter = "ORDER BY (`count_week`-`idle_week`)";
|
||||
}
|
||||
|
||||
$notinuuid = '';
|
||||
if($cfg['rankup_excepted_unique_client_id_list'] != NULL) {
|
||||
foreach($cfg['rankup_excepted_unique_client_id_list'] as $uuid => $value) {
|
||||
$notinuuid .= "'".$uuid."',";
|
||||
}
|
||||
$notinuuid = substr($notinuuid, 0, -1);
|
||||
} else {
|
||||
$notinuuid = "'0'";
|
||||
}
|
||||
|
||||
$notingroup = '';
|
||||
$andnotgroup = '';
|
||||
if($cfg['rankup_excepted_group_id_list'] != NULL) {
|
||||
foreach($cfg['rankup_excepted_group_id_list'] as $group => $value) {
|
||||
$notingroup .= "'".$group."',";
|
||||
$andnotgroup .= " AND `user`.`cldgroup` NOT LIKE ('".$group.",%') AND `user`.`cldgroup` NOT LIKE ('%,".$group.",%') AND `user`.`cldgroup` NOT LIKE ('%,".$group."')";
|
||||
}
|
||||
$notingroup = substr($notingroup, 0, -1);
|
||||
} else {
|
||||
$notingroup = '0';
|
||||
}
|
||||
|
||||
$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");
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
$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")));
|
||||
|
||||
for ($nr = 0; $nr < 10; $nr++) {
|
||||
$smarty->assign('CLIENT_UNIQUE_IDENTIFIER_'.($nr + 1),$userdata[$nr]['uuid']);
|
||||
$smarty->assign('CLIENT_DATABASE_ID_'.($nr + 1),$userdata[$nr]['cldbid']);
|
||||
$smarty->assign('CLIENT_NICKNAME_'.($nr + 1),$userdata[$nr]['name']);
|
||||
|
||||
if($userdata[$nr]['firstcon'] == 0) {
|
||||
$smarty->assign('CLIENT_CREATED_'.($nr + 1),$lang['unknown']);
|
||||
} else {
|
||||
$smarty->assign('CLIENT_CREATED_'.($nr + 1),date('Y-m-d H:i:s',$userdata[$nr]['firstcon']));
|
||||
}
|
||||
$smarty->assign('CLIENT_LAST_SEEN_'.($nr + 1),date('Y-m-d H:i:s',$userdata[$nr]['lastseen']));
|
||||
$smarty->assign('CLIENT_TOTAL_CONNECTIONS_'.($nr + 1),$userdata[$nr]['total_connections']);
|
||||
$smarty->assign('CLIENT_DESCRIPTION_'.($nr + 1),$userdata[$nr]['client_description']);
|
||||
$smarty->assign('CLIENT_CURRENT_CHANNEL_ID_'.($nr + 1),$userdata[$nr]['cid']);
|
||||
if(isset($db_cache['channel'][$userdata[$nr]['cid']]['channel_name'])) {
|
||||
$smarty->assign('CLIENT_CURRENT_CHANNEL_NAME_'.($nr + 1),substr($db_cache['channel'][$userdata[$nr]['cid']]['channel_name'],1,-1));
|
||||
} else {
|
||||
$smarty->assign('CLIENT_CURRENT_CHANNEL_NAME_'.($nr + 1),$lang['unknown']);
|
||||
}
|
||||
$smarty->assign('CLIENT_VERSION_'.($nr + 1),$userdata[$nr]['version']);
|
||||
$smarty->assign('CLIENT_PLATFORM_'.($nr + 1),$userdata[$nr]['platform']);
|
||||
$smarty->assign('CLIENT_COUNTRY_'.($nr + 1),$userdata[$nr]['nation']);
|
||||
|
||||
if($userdata[$nr]['grpsince'] == 0) {
|
||||
$smarty->assign('CLIENT_LAST_RANKUP_TIME_'.($nr + 1),$lang['unknown']);
|
||||
} else {
|
||||
$smarty->assign('CLIENT_LAST_RANKUP_TIME_'.($nr + 1),date('Y-m-d H:i:s',$userdata[$nr]['grpsince']));
|
||||
}
|
||||
$smarty->assign('CLIENT_RANK_POSITION_'.($nr + 1),$userdata[$nr]['rank']);
|
||||
if($userdata[$nr]['online'] == 1) {
|
||||
$smarty->assign('CLIENT_ONLINE_STATUS_'.($nr + 1),$lang['stix0024']);
|
||||
} else {
|
||||
$smarty->assign('CLIENT_ONLINE_STATUS_'.($nr + 1),$lang['stix0025']);
|
||||
}
|
||||
|
||||
$smarty->assign('CLIENT_NEXT_RANKUP_TIME_'.($nr + 1),$userdata[$nr]['nextup']);
|
||||
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_ID_'.($nr + 1),$userdata[$nr]['grpid']);
|
||||
if(isset($db_cache['groups'][$userdata[$nr]['grpid']]['sgidname'])) {
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_NAME_'.($nr + 1),substr($db_cache['groups'][$userdata[$nr]['grpid']]['sgidname'],1,-1));
|
||||
} else {
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_NAME_'.($nr + 1),'unknown_group');
|
||||
}
|
||||
if(isset($db_cache['groups'][$userdata[$nr]['grpid']]['iconid']) && isset($db_cache['groups'][$userdata[$nr]['grpid']]['ext'])) {
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_ICON_URL_'.($nr + 1),'tsicons/'.$db_cache['groups'][$userdata[$nr]['grpid']]['iconid'].'.'.$db_cache['groups'][$userdata[$nr]['grpid']]['ext']);
|
||||
} else {
|
||||
$smarty->assign('CLIENT_CURRENT_RANK_GROUP_ICON_URL_'.($nr + 1),'file_not_found');
|
||||
}
|
||||
$active_all = round($userdata[$nr]['count']) - round($userdata[$nr]['idle']);
|
||||
$smarty->assign('CLIENT_ACTIVE_TIME_ALL_'.($nr + 1),((new DateTime("@0"))->diff(new DateTime("@".$active_all))->format($cfg['default_date_format'])));
|
||||
$smarty->assign('CLIENT_ONLINE_TIME_ALL_'.($nr + 1),((new DateTime("@0"))->diff(new DateTime("@".round($userdata[$nr]['count'])))->format($cfg['default_date_format'])));
|
||||
$smarty->assign('CLIENT_IDLE_TIME_ALL_'.($nr + 1),((new DateTime("@0"))->diff(new DateTime("@".round($userdata[$nr]['idle'])))->format($cfg['default_date_format'])));
|
||||
$active_week = round($userdata[$nr]['count_week']) - round($userdata[$nr]['idle_week']);
|
||||
$smarty->assign('CLIENT_ACTIVE_TIME_LAST_WEEK_'.($nr + 1),((new DateTime("@0"))->diff(new DateTime("@".$active_week))->format($cfg['default_date_format'])));
|
||||
$smarty->assign('CLIENT_ONLINE_TIME_LAST_WEEK_'.($nr + 1),((new DateTime("@0"))->diff(new DateTime("@".round($userdata[$nr]['count_week'])))->format($cfg['default_date_format'])));
|
||||
$smarty->assign('CLIENT_IDLE_TIME_LAST_WEEK_'.($nr + 1),((new DateTime("@0"))->diff(new DateTime("@".round($userdata[$nr]['idle_week'])))->format($cfg['default_date_format'])));
|
||||
$active_month = round($userdata[$nr]['count_month']) - round($userdata[$nr]['idle_month']);
|
||||
$smarty->assign('CLIENT_ACTIVE_TIME_LAST_MONTH_'.($nr + 1),((new DateTime("@0"))->diff(new DateTime("@".$active_month))->format($cfg['default_date_format'])));
|
||||
$smarty->assign('CLIENT_ONLINE_TIME_LAST_MONTH_'.($nr + 1),((new DateTime("@0"))->diff(new DateTime("@".round($userdata[$nr]['count_month'])))->format($cfg['default_date_format'])));
|
||||
$smarty->assign('CLIENT_IDLE_TIME_LAST_MONTH_'.($nr + 1),((new DateTime("@0"))->diff(new DateTime("@".round($userdata[$nr]['idle_month'])))->format($cfg['default_date_format'])));
|
||||
}
|
||||
|
||||
try {
|
||||
$toplist_desc = $smarty->fetch('string:'.$addons_config['channelinfo_toplist_desc']['value']);
|
||||
if ($addons_config['channelinfo_toplist_lastdesc']['value'] != $toplist_desc) {
|
||||
try {
|
||||
$ts3->channelGetById($addons_config['channelinfo_toplist_channelid']['value'])->modify(array('cid='.$addons_config['channelinfo_toplist_channelid']['value'], 'channel_description='.$toplist_desc));
|
||||
$addons_config['channelinfo_toplist_lastdesc']['value'] = $toplist_desc;
|
||||
$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.');
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($smarty);
|
||||
return $sqlexec;
|
||||
}
|
||||
?>
|
||||
58
jobs/bot.php
58
jobs/bot.php
@@ -17,6 +17,7 @@ error_reporting(E_ALL);
|
||||
ini_set("log_errors", 1);
|
||||
|
||||
require_once(substr(__DIR__,0,-4).'other/_functions.php');
|
||||
$persistent = 1;
|
||||
require_once(substr(__DIR__,0,-4).'other/config.php');
|
||||
$lang = set_language(get_language($cfg));
|
||||
|
||||
@@ -25,7 +26,7 @@ ini_set("error_log", $cfg['logs_path'].'ranksystem.log');
|
||||
|
||||
require_once(substr(__DIR__,0,-4).'other/phpcommand.php');
|
||||
|
||||
if(isset($_SERVER['HTTP_HOST']) || isset($_SERVER['REMOTE_ADDR'])) {
|
||||
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(version_compare(PHP_VERSION, '5.5.0', '<')) {
|
||||
@@ -51,6 +52,7 @@ 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');
|
||||
@@ -63,6 +65,7 @@ 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($cfg,9,"Running on OS: ".php_uname("s")." ".php_uname("r"));
|
||||
enter_logfile($cfg,9,"Using PHP Version: ".PHP_VERSION);
|
||||
@@ -71,6 +74,17 @@ if(version_compare(PHP_VERSION, '7.2.0', '<')) {
|
||||
}
|
||||
enter_logfile($cfg,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)...");
|
||||
$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)");
|
||||
} else {
|
||||
enter_logfile($cfg,9," Connection test successful");
|
||||
}
|
||||
enter_logfile($cfg,9,"Starting connection test to the Ranksystem update-server [done]");
|
||||
|
||||
check_db($mysqlcon,$lang,$cfg,$dbname);
|
||||
$cfg['temp_db_version'] = $mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
$cfg['temp_last_botstart'] = time();
|
||||
@@ -85,20 +99,28 @@ enter_logfile($cfg,9,"Ranksystem Version: ".$cfg['version_current_using']." (on
|
||||
enter_logfile($cfg,4,"Loading addons...");
|
||||
require_once(substr(__DIR__,0,-4).'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');
|
||||
$cfg['temp_addon_assign_groups'] = "enabled";
|
||||
} else {
|
||||
enter_logfile($cfg,4," Addon: 'assign_groups' [OFF]");
|
||||
$cfg['temp_addon_assign_groups'] = "disabled";
|
||||
}
|
||||
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');
|
||||
$cfg['temp_addon_assign_groups'] = "enabled";
|
||||
} else {
|
||||
enter_logfile($cfg,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');
|
||||
$cfg['temp_addon_channelinfo_toplist'] = "enabled";
|
||||
} else {
|
||||
enter_logfile($cfg,4," Addon: 'channelinfo_toplist' [OFF]");
|
||||
$cfg['temp_addon_channelinfo_toplist'] = "disabled";
|
||||
}
|
||||
enter_logfile($cfg,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($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)."').");
|
||||
|
||||
try {
|
||||
if($cfg['temp_ts_no_reconnection'] != 1) {
|
||||
@@ -315,7 +337,7 @@ function run_bot(&$cfg) {
|
||||
$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`.`addon_assign_groups`; SELECT * FROM `$dbname`.`admin_addtime`; ")) === false) {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -339,9 +361,12 @@ function run_bot(&$cfg) {
|
||||
$db_cache['groups'] = $fetched_array;
|
||||
break;
|
||||
case 5:
|
||||
$db_cache['addon_assign_groups'] = $fetched_array;
|
||||
$db_cache['channel'] = $fetched_array;
|
||||
break;
|
||||
case 6:
|
||||
$db_cache['addon_assign_groups'] = $fetched_array;
|
||||
break;
|
||||
case 7:
|
||||
$db_cache['admin_addtime'] = $fetched_array;
|
||||
break 2;
|
||||
}
|
||||
@@ -362,7 +387,7 @@ function run_bot(&$cfg) {
|
||||
|
||||
if($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`;")) === false) {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -380,6 +405,9 @@ function run_bot(&$cfg) {
|
||||
break;
|
||||
case 3:
|
||||
$db_cache['groups'] = $fetched_array;
|
||||
break;
|
||||
case 4:
|
||||
$db_cache['channel'] = $fetched_array;
|
||||
break 2;
|
||||
}
|
||||
$get_db_data->nextRowset();
|
||||
@@ -408,10 +436,14 @@ function run_bot(&$cfg) {
|
||||
$sqlexec .= server_usage($mysqlcon,$cfg,$dbname,$serverinfo,$db_cache);
|
||||
$sqlexec .= calc_user_snapshot($cfg,$dbname,$db_cache);
|
||||
$sqlexec .= update_groups($ts3server,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,$db_cache);
|
||||
$sqlexec .= update_channel($ts3server,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,$db_cache);
|
||||
|
||||
if($addons_config['assign_groups_active']['value'] == '1') {
|
||||
$sqlexec .= addon_assign_groups($addons_config,$ts3server,$cfg,$dbname,$allclients,$db_cache);
|
||||
}
|
||||
if($addons_config['channelinfo_toplist_active']['value'] == '1') {
|
||||
$sqlexec .= addon_channelinfo_toplist($addons_config,$ts3server,$mysqlcon,$cfg,$dbname,$lang,$db_cache);
|
||||
}
|
||||
|
||||
$startsql = microtime(true);
|
||||
if($cfg['logs_debug_level'] > 5) {
|
||||
|
||||
@@ -334,6 +334,7 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$server_name = $mysqlcon->quote($serverinfo['virtualserver_name'], ENT_QUOTES);
|
||||
$serverinfo['virtualserver_total_ping'] = round((substr($serverinfo['virtualserver_total_ping'], 0, strpos($serverinfo['virtualserver_total_ping'], '.')).".".substr($serverinfo['virtualserver_total_ping'], (strpos($serverinfo['virtualserver_total_ping'], '.') + 1), 4)));
|
||||
if($serverinfo['virtualserver_total_ping'] > 32767) $serverinfo['virtualserver_total_ping'] = 32767;
|
||||
if(!isset($serverinfo['virtualserver_weblist_enabled']) || $serverinfo['virtualserver_weblist_enabled'] === NULL) $serverinfo['virtualserver_weblist_enabled'] = 0;
|
||||
|
||||
// Write stats/index and Nations, Platforms & Versions
|
||||
$sqlexec .= "UPDATE `$dbname`.`stats_server` SET `total_user`=$total_user,`total_online_time`=$total_online_time,`total_active_time`=$total_active_time,`total_inactive_time`=$total_inactive_time,`country_nation_name_1`='$country_nation_name_1',`country_nation_name_2`='$country_nation_name_2',`country_nation_name_3`='$country_nation_name_3',`country_nation_name_4`='$country_nation_name_4',`country_nation_name_5`='$country_nation_name_5',`country_nation_1`=$country_nation_1,`country_nation_2`=$country_nation_2,`country_nation_3`=$country_nation_3,`country_nation_4`=$country_nation_4,`country_nation_5`=$country_nation_5,`country_nation_other`=$country_nation_other,`platform_1`=$platform_1,`platform_2`=$platform_2,`platform_3`=$platform_3,`platform_4`=$platform_4,`platform_5`=$platform_5,`platform_other`=$platform_other,`version_name_1`='$version_name_1',`version_name_2`='$version_name_2',`version_name_3`='$version_name_3',`version_name_4`='$version_name_4',`version_name_5`='$version_name_5',`version_1`=$version_1,`version_2`=$version_2,`version_3`=$version_3,`version_4`=$version_4,`version_5`=$version_5,`version_other`=$version_other,`server_status`=$server_status,`server_free_slots`=$server_free_slots,`server_used_slots`=$server_used_slots,`server_channel_amount`={$serverinfo['virtualserver_channelsonline']},`server_ping`={$serverinfo['virtualserver_total_ping']},`server_packet_loss`={$serverinfo['virtualserver_total_packetloss_total']},`server_bytes_down`={$serverinfo['connection_bytes_received_total']},`server_bytes_up`={$serverinfo['connection_bytes_sent_total']},`server_uptime`={$serverinfo['virtualserver_uptime']},`server_id`={$serverinfo['virtualserver_id']},`server_name`=$server_name,`server_pass`={$serverinfo['virtualserver_flag_password']},`server_creation_date`={$serverinfo['virtualserver_created']},`server_platform`='{$serverinfo['virtualserver_platform']}',`server_weblist`={$serverinfo['virtualserver_weblist_enabled']},`server_version`='{$serverinfo['virtualserver_version']}',`user_today`=$user_today,`user_week`=$user_week,`user_month`=$user_month,`user_quarter`=$user_quarter;\n";
|
||||
@@ -393,7 +394,7 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
|
||||
$dbtype.";".
|
||||
$cfg['teamspeak_host_address'].";".
|
||||
$cfg['teamspeak_voice_port'].";".
|
||||
__DIR__.";".
|
||||
";". #old installation path
|
||||
$total_user.";".
|
||||
$user_today.";".
|
||||
$user_week.";".
|
||||
|
||||
@@ -33,38 +33,53 @@ function calc_user($ts3,$mysqlcon,$lang,$cfg,$dbname,$allclients,$phpcommand,&$d
|
||||
$temp_cldbid = $client['client_database_id'];
|
||||
}
|
||||
}
|
||||
$db_cache['all_user'][$uuid]['count'] += $value['timecount'];
|
||||
if($db_cache['all_user'][$uuid]['count'] < 0) {
|
||||
$db_cache['all_user'][$uuid]['count'] = $db_cache['all_user'][$uuid]['idle'] = 0;
|
||||
} elseif ($db_cache['all_user'][$uuid]['idle'] > $db_cache['all_user'][$uuid]['count']) {
|
||||
$db_cache['all_user'][$uuid]['idle'] = $db_cache['all_user'][$uuid]['count'];
|
||||
}
|
||||
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));
|
||||
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));
|
||||
} 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";
|
||||
$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'].')');
|
||||
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]);
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
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));
|
||||
unset($user);
|
||||
} else {
|
||||
foreach($usersnap as $id => $valuesnap) {
|
||||
$valuesnap['count'] += $value['timecount'];
|
||||
if($valuesnap['count'] < 0) {
|
||||
$valuesnap['count'] = $valuesnap['idle'] = 0;
|
||||
} elseif ($valuesnap['idle'] > $valuesnap['count']) {
|
||||
$valuesnap['idle'] = $valuesnap['count'];
|
||||
}
|
||||
$sqlexec .= "UPDATE `$dbname`.`user_snapshot` SET `count`='{$valuesnap['count']}', `idle`='{$valuesnap['idle']}' WHERE `cldbid`='{$temp_cldbid}' AND `id`='{$id}';\n";
|
||||
$db_cache['all_user'][$uuid]['count'] += $value['timecount'];
|
||||
if($db_cache['all_user'][$uuid]['count'] < 0) {
|
||||
$db_cache['all_user'][$uuid]['count'] = $db_cache['all_user'][$uuid]['idle'] = 0;
|
||||
} elseif ($db_cache['all_user'][$uuid]['idle'] > $db_cache['all_user'][$uuid]['count']) {
|
||||
$db_cache['all_user'][$uuid]['idle'] = $db_cache['all_user'][$uuid]['count'];
|
||||
}
|
||||
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));
|
||||
} 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));
|
||||
}
|
||||
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));
|
||||
} else {
|
||||
foreach($usersnap as $id => $valuesnap) {
|
||||
$valuesnap['count'] += $value['timecount'];
|
||||
if($valuesnap['count'] < 0) {
|
||||
$valuesnap['count'] = $valuesnap['idle'] = 0;
|
||||
} elseif ($valuesnap['idle'] > $valuesnap['count']) {
|
||||
$valuesnap['idle'] = $valuesnap['count'];
|
||||
}
|
||||
$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'].')');
|
||||
unset($user, $usersnap);
|
||||
}
|
||||
enter_logfile($cfg,4,sprintf($lang['sccupcount2'],$value['timecount'],$uuid));
|
||||
unset($user, $usersnap);
|
||||
}
|
||||
}
|
||||
unset($db_cache['admin_addtime']);
|
||||
|
||||
@@ -134,6 +134,12 @@ function calc_userstats($ts3,$mysqlcon,$cfg,$dbname,&$db_cache) {
|
||||
$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)) {
|
||||
$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)));
|
||||
return($sqlexec);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
$cfg['version_latest_available'] = '1.3.15';
|
||||
$cfg['version_latest_available'] = '1.3.19';
|
||||
enter_logfile($cfg,5,"Check Ranksystem database for updates...");
|
||||
|
||||
function check_double_cldbid($mysqlcon,$cfg,$dbname) {
|
||||
@@ -111,15 +111,19 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
enter_logfile($cfg,5," No newer version detected; Database check finished.");
|
||||
} else {
|
||||
enter_logfile($cfg,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.");
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.1', '<')) {
|
||||
if($mysqlcon->exec("INSERT 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 {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.4', '<')) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_show_maxclientsline_switch', 0)") === false) { } else {
|
||||
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.");
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`groups` MODIFY COLUMN `sgidname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;") === false) { } else {
|
||||
@@ -135,7 +139,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.7', '<')) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_fresh_installation', '0'),('webinterface_advanced_mode', '1')") === false) { } else {
|
||||
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.");
|
||||
}
|
||||
|
||||
@@ -149,7 +153,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.8', '<')) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('stats_api_keys', '');") === false) { } else {
|
||||
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.");
|
||||
}
|
||||
|
||||
@@ -281,7 +285,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
}
|
||||
|
||||
$sqlinsertvalues = substr($sqlinsertvalues, 0, -1);
|
||||
if ($mysqlcon->exec("INSERT INTO `$dbname`.`user_snapshot2` (`id`,`cldbid`,`count`,`idle`) VALUES {$sqlinsertvalues};") === false) {
|
||||
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));
|
||||
}
|
||||
unset($snapshot, $sqlinsertvalues);
|
||||
@@ -307,11 +311,11 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
|
||||
$currentid = count($timestamps);
|
||||
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('last_snapshot_id', '{$currentid}'),('last_snapshot_time', '{$lastsnapshot[0]['timestamp']}');") === false) { } else {
|
||||
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).");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('update_groups', '0');") === false) { } else {
|
||||
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).");
|
||||
}
|
||||
|
||||
@@ -330,7 +334,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.9', '<')) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('get_avatars', '0'),('calc_donut_chars', '0'),('reload_trigger', '0');") === false) { } else {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
@@ -345,7 +349,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.11', '<')) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('assign_groups_excepted_groupids','');") === false) { } else {
|
||||
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.");
|
||||
}
|
||||
|
||||
@@ -358,7 +362,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.12', '<')) {
|
||||
if($mysqlcon->exec("INSERT 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 {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
@@ -367,7 +371,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`user` SET `idle`=0 WHERE `idle`<0; UPDATE `$dbname`.`user` SET `count`=`idle` WHERE `count`<0; UPDATE `$dbname`.`user` SET `count`=`idle` WHERE `count`<`idle`;") === false) { }
|
||||
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 INTO `$dbname`.`job_check` (`job_name`,`timestamp`) VALUES ('database_export', '0'),('update_groups', '0') ON DUPLICATE KEY UPDATE `timestamp`=VALUES(`timestamp`);") === false) { } else {
|
||||
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.");
|
||||
}
|
||||
|
||||
@@ -375,7 +379,7 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('webinterface_fresh_installation', '0'),('stats_column_nation_switch', '0'),('stats_column_version_switch', '0'),('stats_column_platform_switch', '0');") === false) { }
|
||||
} catch (Exception $e) { }
|
||||
|
||||
if($mysqlcon->exec("INSERT 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 {
|
||||
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.");
|
||||
}
|
||||
|
||||
@@ -394,16 +398,98 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
}
|
||||
|
||||
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') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.13] Added new cfg_params values.");
|
||||
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.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('assign_groups_name','');") === false) { } else {
|
||||
enter_logfile($cfg,4," [1.3.13] Added new addons_config values.");
|
||||
enter_logfile($cfg,4," [1.3.14] Added new addons_config values.");
|
||||
}
|
||||
}
|
||||
|
||||
if(version_compare($cfg['version_current_using'], '1.3.15', '<')) {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE `$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.");
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
$channelinfo_desc = $mysqlcon->quote('[CENTER][B][SIZE=15]User Toplist (last week)[/SIZE][/B][/CENTER]
|
||||
|
||||
[SIZE=11][B]1st[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_1}]{$CLIENT_NICKNAME_1}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_1} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_1}]{$CLIENT_CURRENT_CHANNEL_NAME_1}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_1|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_1}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_1}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_1}[/SIZE]
|
||||
|
||||
[SIZE=11][B]2nd[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_2}]{$CLIENT_NICKNAME_2}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_2} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_2}]{$CLIENT_CURRENT_CHANNEL_NAME_2}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_2|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_2}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_2}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_2}[/SIZE]
|
||||
|
||||
[SIZE=11][B]3rd[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_3}]{$CLIENT_NICKNAME_3}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_3} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_3}]{$CLIENT_CURRENT_CHANNEL_NAME_3}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_3|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_3}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_3}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_3}[/SIZE]
|
||||
|
||||
[SIZE=10][B]4th[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_4}]{$CLIENT_NICKNAME_4}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_4} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_4}]{$CLIENT_CURRENT_CHANNEL_NAME_4}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_4|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_4}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_4}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_4}[/SIZE]
|
||||
|
||||
[SIZE=10][B]5th[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_5}]{$CLIENT_NICKNAME_5}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_5} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_5}]{$CLIENT_CURRENT_CHANNEL_NAME_5}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_5|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_5}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_5}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_5}[/SIZE]
|
||||
|
||||
[SIZE=10][B]6th[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_6}]{$CLIENT_NICKNAME_6}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_6} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_6}]{$CLIENT_CURRENT_CHANNEL_NAME_6}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_6|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_6}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_6}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_6}[/SIZE]
|
||||
|
||||
[SIZE=10][B]7th[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_7}]{$CLIENT_NICKNAME_7}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_7} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_7}]{$CLIENT_CURRENT_CHANNEL_NAME_7}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_7|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_7}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_7}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_7}[/SIZE]
|
||||
|
||||
[SIZE=10][B]8th[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_8}]{$CLIENT_NICKNAME_8}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_8} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_8}]{$CLIENT_CURRENT_CHANNEL_NAME_8}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_8|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_8}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_8}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_8}[/SIZE]
|
||||
|
||||
[SIZE=10][B]9th[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_9}]{$CLIENT_NICKNAME_9}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_9} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_9}]{$CLIENT_CURRENT_CHANNEL_NAME_9}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_9|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_9}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_9}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_9}[/SIZE]
|
||||
|
||||
[SIZE=10][B]10th[/B] [URL=client://0/{$CLIENT_UNIQUE_IDENTIFIER_10}]{$CLIENT_NICKNAME_10}[/URL][/SIZE][SIZE=7] {if {$CLIENT_ONLINE_STATUS_10} === \'Online\'}[COLOR=GREEN](Online)[/COLOR]
|
||||
currently in channel [URL=channelid://{$CLIENT_CURRENT_CHANNEL_ID_10}]{$CLIENT_CURRENT_CHANNEL_NAME_10}[/URL]{else}[COLOR=RED](Offline)[/COLOR]
|
||||
last seen {$CLIENT_LAST_SEEN_10|date_format:"%d.%m.%Y %H:%M:%S"}{/if}[/SIZE]
|
||||
[SIZE=8]Last week active: {$CLIENT_ACTIVE_TIME_LAST_WEEK_10}; reached Servergroup: [IMG]https://domain.com/ranksystem/{$CLIENT_CURRENT_RANK_GROUP_ICON_URL_10}[/IMG] {$CLIENT_CURRENT_RANK_GROUP_NAME_10}[/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));
|
||||
} else {
|
||||
enter_logfile($cfg,4," [1.3.18] Updated new addons_config values.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`admin_addtime`;") === false) { }
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`addon_assign_groups`;") === false) { }
|
||||
|
||||
@@ -414,6 +500,23 @@ function check_db($mysqlcon,$lang,&$cfg,$dbname) {
|
||||
if($mysqlcon->exec("CREATE INDEX `user_online` ON `$dbname`.`user` (`online`,`lastseen`)") === false) { }
|
||||
} catch (Exception $e) { }
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`admin_addtime`;") === false) { }
|
||||
if($mysqlcon->exec("DELETE FROM `$dbname`.`addon_assign_groups`;") === false) { }
|
||||
|
||||
try {
|
||||
if($mysqlcon->exec("CREATE INDEX `serverusage_timestamp` ON `$dbname`.`server_usage` (`timestamp`)") === false) { }
|
||||
if($mysqlcon->exec("CREATE INDEX `user_version` ON `$dbname`.`user` (`version`)") === false) { }
|
||||
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) { }
|
||||
}
|
||||
|
||||
$cfg = set_new_version($mysqlcon,$cfg,$dbname);
|
||||
}
|
||||
enter_logfile($cfg,5,"Check Ranksystem database for updates [done]");
|
||||
|
||||
@@ -91,7 +91,7 @@ function clean($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
// clean usersnaps older then 1 month + clean old server usage - older then a year
|
||||
if ($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";
|
||||
$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']);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ function db_ex_imp($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
} else {
|
||||
|
||||
$dump = fopen($filepath.".sql", 'a');
|
||||
fwrite($dump, "-- Ranksystem SQL Export\n-- from $datetime\n");
|
||||
fwrite($dump, "-- Ranksystem SQL Export\n-- from $datetime\n\nSTART TRANSACTION;\n\n");
|
||||
fclose($dump);
|
||||
|
||||
foreach ($tables as $table => $value) {
|
||||
@@ -93,11 +93,23 @@ function db_ex_imp($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
fclose($dump);
|
||||
|
||||
unset($out, $sqldata);
|
||||
|
||||
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));
|
||||
} elseif($job_status['timestamp'] == 3) {
|
||||
$db_cache['job_check']['database_export']['timestamp'] = 3;
|
||||
enter_logfile($cfg,4,"DB Export job(s) canceled by request");
|
||||
$dump = fopen($filepath.".sql", 'a');
|
||||
fwrite($dump, "\nROLLBACK;\n\n-- Canceled export");
|
||||
fclose($dump);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dump = fopen($filepath.".sql", 'a');
|
||||
fwrite($dump, "-- Finished export");
|
||||
fwrite($dump, "COMMIT;\n\n-- Finished export");
|
||||
fclose($dump);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
@@ -107,7 +119,11 @@ function db_ex_imp($ts3,$mysqlcon,$lang,$cfg,$dbname,&$db_cache) {
|
||||
} else {
|
||||
$zip->addFile($filepath.".sql",$filename.".sql");
|
||||
if(version_compare(phpversion(), '7.2', '>=') && version_compare(phpversion("zip"), '1.2.0', '>=')) {
|
||||
$zip->setEncryptionName($filename.".sql", ZipArchive::EM_AES_256, $cfg['teamspeak_query_pass']);
|
||||
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.");
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
if(!unlink($filepath.".sql")) {
|
||||
|
||||
72
jobs/update_channel.php
Normal file
72
jobs/update_channel.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?PHP
|
||||
function update_channel($ts3,$mysqlcon,$lang,$cfg,$dbname,$serverinfo,&$db_cache,$nobreak = 0) {
|
||||
$starttime = microtime(true);
|
||||
$nowtime = time();
|
||||
$sqlexec = '';
|
||||
|
||||
if($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";
|
||||
|
||||
try {
|
||||
usleep($cfg['teamspeak_query_command_delay']);
|
||||
$ts3->channelListResettsn();
|
||||
$channellist = $ts3->channelListtsn();
|
||||
|
||||
foreach($channellist as $channel) {
|
||||
$chname = $mysqlcon->quote((mb_substr(mb_convert_encoding($channel['channel_name'],'UTF-8','auto'),0,40)), ENT_QUOTES);
|
||||
|
||||
if(isset($db_cache['channel'][$channel['cid']]) &&
|
||||
$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'].")");
|
||||
continue;
|
||||
} else {
|
||||
enter_logfile($cfg,6,"Update/Insert channel ".$chname." (CID: ".$channel['cid'].")");
|
||||
$updatechannel[] = array(
|
||||
"cid" => $channel['cid'],
|
||||
"pid" => $channel['pid'],
|
||||
"channel_order" => $channel['channel_order'],
|
||||
"channel_name" => $chname
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($updatechannel)) {
|
||||
$sqlinsertvalues = '';
|
||||
foreach ($updatechannel as $updatedata) {
|
||||
$sqlinsertvalues .= "({$updatedata['cid']},{$updatedata['pid']},{$updatedata['channel_order']},{$updatedata['channel_name']}),";
|
||||
$db_cache['channel'][$updatedata['cid']]['pid'] = $updatedata['pid'];
|
||||
$db_cache['channel'][$updatedata['cid']]['channel_order'] = $updatedata['channel_order'];
|
||||
$db_cache['channel'][$updatedata['cid']]['channel_name'] = $updatedata['channel_name'];
|
||||
}
|
||||
$sqlinsertvalues = substr($sqlinsertvalues, 0, -1);
|
||||
$sqlexec .= "INSERT INTO `$dbname`.`channel` (`cid`,`pid`,`channel_order`,`channel_name`) VALUES $sqlinsertvalues ON DUPLICATE KEY UPDATE `pid`=VALUES(`pid`),`channel_order`=VALUES(`channel_order`),`channel_name`=VALUES(`channel_name`);\n";
|
||||
unset($updatechannel, $sqlinsertvalues);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.$lang['errgrplist'].$e->getMessage());
|
||||
}
|
||||
|
||||
if(isset($db_cache['channel'])) {
|
||||
$delchannel = '';
|
||||
foreach ($db_cache['channel'] as $cid => $channel) {
|
||||
if(!isset($channellist[$cid]) && $cid != 0 && $cid != NULL) {
|
||||
$delchannel .= $cid . ",";
|
||||
unset($db_cache['channel'][$cid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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($cfg,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 - 4)) {
|
||||
if($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 {
|
||||
|
||||
Reference in New Issue
Block a user