Skip to content

Commit

Permalink
release 1.3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Newcomer1989 committed Sep 22, 2020
1 parent 3ab2007 commit 3a33371
Show file tree
Hide file tree
Showing 54 changed files with 842 additions and 1,192 deletions.
4 changes: 2 additions & 2 deletions install.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?PHP
require_once('other/config.php');
$rsversion = '1.3.11';
$rsversion = '1.3.12';
?>
<!DOCTYPE html>
<html>
Expand Down Expand Up @@ -293,7 +293,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
$nextupinfomsg3 = $mysqlcon->quote("You are excepted from the Ranksystem. If you wish to rank contact an admin on the TS3 server.");
$servernews = $mysqlcon->quote("<strong>Message</strong><br>This is an example Message.<br>Change this Message inside the webinterface.");
$rankupmsg = $mysqlcon->quote('Hey, you reached a higher rank, since you already connected for %1$s days, %2$s hours and %3$s minutes to our TS3 server.[B]Keep it up![/B] ;-) ');
if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('default_date_format', $dateformat), ('default_language', 'en'), ('logs_path', '{$logpath}'), ('logs_timezone', 'Europe/Berlin'), ('logs_debug_level', '5'), ('logs_rotation_size', '5'), ('rankup_boost_definition', ''), ('rankup_clean_clients_period', '86400'), ('rankup_clean_clients_switch', '1'), ('rankup_client_database_id_change_switch', '0'), ('rankup_definition', '31536000=>7'), ('rankup_excepted_channel_id_list', ''), ('rankup_excepted_group_id_list', ''), ('rankup_excepted_mode', '0'), ('rankup_excepted_unique_client_id_list', ''), ('rankup_hash_ip_addresses_mode', '2'), ('rankup_ignore_idle_time', '600'), ('rankup_message_to_user', $rankupmsg), ('rankup_message_to_user_switch', '1'), ('rankup_next_message_1', $nextupinfomsg1), ('rankup_next_message_2', $nextupinfomsg2), ('rankup_next_message_3', $nextupinfomsg3), ('rankup_next_message_mode', '1'), ('rankup_time_assess_mode', '0'), ('stats_api_keys', ''), ('stats_column_active_time_switch', '0'), ('stats_column_current_group_since_switch', '1'), ('stats_column_current_server_group_switch', '1'), ('stats_column_client_db_id_switch', '0'), ('stats_column_client_name_switch', '1'), ('stats_column_idle_time_switch', '1'), ('stats_column_last_seen_switch', '1'), ('stats_column_next_rankup_switch', '1'), ('stats_column_next_server_group_switch', '1'), ('stats_column_online_time_switch', '1'), ('stats_column_rank_switch', '1'), ('stats_column_unique_id_switch', '0'), ('stats_column_default_sort', 'rank'), ('stats_column_default_order', 'asc'), ('stats_server_news', $servernews), ('stats_show_clients_in_highest_rank_switch', '1'), ('stats_show_excepted_clients_switch', '1'), ('stats_show_maxclientsline_switch', 0), ('stats_show_site_navigation_switch', '1'), ('stats_time_bronze','50'), ('stats_time_silver','100'), ('stats_time_gold','250'), ('stats_time_legend','500'), ('stats_connects_bronze','50'), ('stats_connects_silver','100'), ('stats_connects_gold','250'), ('stats_connects_legend','500'), ('teamspeak_avatar_download_delay', '0'), ('teamspeak_default_channel_id', '0'), ('teamspeak_host_address', '127.0.0.1'), ('teamspeak_query_command_delay', '0'), ('teamspeak_query_encrypt_switch', '0'), ('teamspeak_query_nickname', 'Ranksystem'), ('teamspeak_query_pass', ''), ('teamspeak_query_port', '10011'), ('teamspeak_query_user', 'serveradmin'), ('teamspeak_verification_channel_id', '0'), ('teamspeak_voice_port', '9987'), ('version_current_using', '{$rsversion}'), ('version_latest_available', '{$rsversion}'), ('version_update_channel', 'stable'), ('webinterface_access_count', '0'), ('webinterface_access_last', '0'), ('webinterface_admin_client_unique_id_list', ''), ('webinterface_advanced_mode', '0'), ('webinterface_fresh_installation', '1'), ('webinterface_pass', '{$pass}'), ('webinterface_user', '{$user}');") === false) {
if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('default_date_format', $dateformat), ('default_language', 'en'), ('logs_path', '{$logpath}'), ('logs_timezone', 'Europe/Berlin'), ('logs_debug_level', '5'), ('logs_rotation_size', '5'), ('rankup_boost_definition', ''), ('rankup_clean_clients_period', '86400'), ('rankup_clean_clients_switch', '1'), ('rankup_client_database_id_change_switch', '0'), ('rankup_definition', '31536000=>7'), ('rankup_excepted_channel_id_list', ''), ('rankup_excepted_group_id_list', ''), ('rankup_excepted_mode', '0'), ('rankup_excepted_unique_client_id_list', ''), ('rankup_hash_ip_addresses_mode', '2'), ('rankup_ignore_idle_time', '600'), ('rankup_message_to_user', $rankupmsg), ('rankup_message_to_user_switch', '1'), ('rankup_next_message_1', $nextupinfomsg1), ('rankup_next_message_2', $nextupinfomsg2), ('rankup_next_message_3', $nextupinfomsg3), ('rankup_next_message_mode', '1'), ('rankup_time_assess_mode', '0'), ('stats_api_keys', ''), ('stats_column_active_time_switch', '0'), ('stats_column_current_group_since_switch', '1'), ('stats_column_current_server_group_switch', '1'), ('stats_column_client_db_id_switch', '0'), ('stats_column_client_name_switch', '1'), ('stats_column_idle_time_switch', '1'), ('stats_column_last_seen_switch', '1'), ('stats_column_next_rankup_switch', '1'), ('stats_column_next_server_group_switch', '1'), ('stats_column_online_time_switch', '1'), ('stats_column_rank_switch', '1'), ('stats_column_unique_id_switch', '0'), ('stats_column_default_sort', 'rank'), ('stats_column_default_order', 'asc'), ('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', '[email protected]'), ('stats_imprint_notes', NULL), ('stats_imprint_phone', '+49 171 1234567'), ('stats_imprint_privacypolicy', 'Add your own privacy policy here. (editable in the webinterface)'), ('stats_imprint_privacypolicy_url', 'https://site.url/privacy/'), ('stats_server_news', $servernews), ('stats_show_clients_in_highest_rank_switch', '1'), ('stats_show_excepted_clients_switch', '1'), ('stats_show_maxclientsline_switch', 0), ('stats_show_site_navigation_switch', '1'), ('stats_time_bronze','50'), ('stats_time_silver','100'), ('stats_time_gold','250'), ('stats_time_legend','500'), ('stats_connects_bronze','50'), ('stats_connects_silver','100'), ('stats_connects_gold','250'), ('stats_connects_legend','500'), ('teamspeak_avatar_download_delay', '0'), ('teamspeak_default_channel_id', '0'), ('teamspeak_host_address', '127.0.0.1'), ('teamspeak_query_command_delay', '0'), ('teamspeak_query_encrypt_switch', '0'), ('teamspeak_query_nickname', 'Ranksystem'), ('teamspeak_query_pass', ''), ('teamspeak_query_port', '10011'), ('teamspeak_query_user', 'serveradmin'), ('teamspeak_verification_channel_id', '0'), ('teamspeak_voice_port', '9987'), ('version_current_using', '{$rsversion}'), ('version_latest_available', '{$rsversion}'), ('version_update_channel', 'stable'), ('webinterface_access_count', '0'), ('webinterface_access_last', '0'), ('webinterface_admin_client_unique_id_list', ''), ('webinterface_advanced_mode', '0'), ('webinterface_fresh_installation', '1'), ('webinterface_pass', '{$pass}'), ('webinterface_user', '{$user}');") === false) {
$err_msg = $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 2;
} else {
$err_msg = $lang['isntwiusr'].'<br><br>';
Expand Down
58 changes: 38 additions & 20 deletions jobs/bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,32 +133,51 @@ function check_shutdown($cfg) {
}
enter_logfile($cfg,4,"Loading addons [done]");

function sendmessage($ts3, $cfg, $uuid, $msg, $erromsg=NULL, $errcode=NULL, $successmsg=NULL, $nolog=NULL) {
function sendmessage($ts3, $cfg, $uuid, $targetmode, $targetid=NULL, $msg, $erromsg=NULL, $loglevel=NULL, $successmsg=NULL, $nolog=NULL) {
try {
if(strlen($msg) > 1024) {
$fragarr = explode("##*##", wordwrap($msg, 1022, "##*##", TRUE), 1022);
foreach($fragarr as $frag) {
usleep($cfg['teamspeak_query_command_delay']);
$ts3->serverGetSelected()->clientGetByUid($uuid)->message("\n".$frag);
if($nolog==NULL) {
enter_logfile($cfg,6,"sendmessage to uuid $uuid (fragment): ".$frag);
if ($targetmode==2 && $targetid!=NULL) {
$ts3->serverGetSelected()->channelGetById($targetid)->message("\n".$frag);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage fragment to channel (ID: $targetid): ".$frag);
} elseif ($targetmode==3) {
$ts3->serverGetSelected()->message("\n".$frag);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage fragment to server: ".$frag);
} elseif ($targetmode==1 && $targetid!=NULL) {
$ts3->serverGetSelected()->clientGetById($targetid)->message("\n".$frag);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage fragment to connectionID $targetid (uuid $uuid): ".$frag);
} else {
$ts3->serverGetSelected()->clientGetByUid($uuid)->message("\n".$frag);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage fragment to uuid $uuid (connectionID $targetid): ".$frag);
}
}
} else {
usleep($cfg['teamspeak_query_command_delay']);
$ts3->serverGetSelected()->clientGetByUid($uuid)->message($msg);
if($nolog==NULL) {
enter_logfile($cfg,6,"sendmessage to uuid $uuid: ".$msg);
if ($targetmode==2 && $targetid!=NULL) {
$ts3->serverGetSelected()->channelGetById($targetid)->message($msg);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage to channel (ID: $targetid): ".$msg);
} elseif ($targetmode==3) {
$ts3->serverGetSelected()->message($msg);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage to server: ".$msg);
} elseif ($targetmode==1 && $targetid!=NULL) {
$ts3->serverGetSelected()->clientGetById($targetid)->message($msg);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage to connectionID $targetid (uuid $uuid): ".$msg);
} else {
$ts3->serverGetSelected()->clientGetByUid($uuid)->message($msg);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage to uuid $uuid (connectionID $targetid): ".$msg);
}

}
if($successmsg!=NULL) {
enter_logfile($cfg,5,$successmsg);
}
} catch (Exception $e) {
if($errcode!=NULL) {
enter_logfile($cfg,$errcode,$erromsg." TS3: ".$e->getCode().': '.$e->getMessage());
if($loglevel!=NULL) {
enter_logfile($cfg,$loglevel,$erromsg." TS3: ".$e->getCode().': '.$e->getMessage());
} else {
enter_logfile($cfg,3,"sendmessage: ".$e->getCode().': '.$e->getMessage());
enter_logfile($cfg,3,"sendmessage: ".$e->getCode().': '.$e->getMessage().", targetmode: $targetmode, targetid: $targetid");
}
}
}
Expand Down Expand Up @@ -297,7 +316,6 @@ function run_bot() {
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);
$cfg['rankup_definition_flipped'] = array_flip($cfg['rankup_definition']);
krsort($cfg['rankup_definition']);

if(($groupslist = $mysqlcon->query("SELECT * FROM `$dbname`.`groups`")->fetchAll(PDO::FETCH_UNIQUE|PDO::FETCH_ASSOC)) === false) {
Expand All @@ -307,8 +325,8 @@ function run_bot() {
$checkgroups = 0;
if(isset($groupslist) && $groupslist != NULL) {
if(isset($cfg['rankup_definition']) && $cfg['rankup_definition'] != NULL) {
foreach($cfg['rankup_definition'] as $time => $groupid) {
if(!isset($groupslist[$groupid]) && $groupid != NULL) {
foreach($cfg['rankup_definition'] as $rank) {
if(!isset($groupslist[$rank['group']]) && $rank['group'] != NULL) {
$checkgroups++;
}
}
Expand Down Expand Up @@ -351,9 +369,9 @@ function run_bot() {

if(isset($groupslist) && $groupslist != NULL) {
if(isset($cfg['rankup_definition']) && $cfg['rankup_definition'] != NULL) {
foreach($cfg['rankup_definition'] as $time => $groupid) {
if(!isset($groupslist[$groupid]) && $groupid != NULL) {
enter_logfile($cfg,1,' '.sprintf($lang['upgrp0001'], $groupid, $lang['wigrptime']));
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']));
$errcnf++;
}
}
Expand Down Expand Up @@ -385,8 +403,8 @@ function run_bot() {
} 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 $clientid) {
sendmessage($ts3server, $cfg, $clientid, sprintf($lang['upmsg2'], $cfg['version_current_using'], 'https://ts-ranksystem.com/#changelog'), sprintf($lang['upusrerr'], $clientid), 6, sprintf($lang['upusrinf'], $clientid));
foreach(array_flip($cfg['webinterface_admin_client_unique_id_list']) as $clientuuid) {
sendmessage($ts3server, $cfg, $clientuuid, NULL, sprintf($lang['upmsg2'], $cfg['version_current_using'], 'https://ts-ranksystem.com/#changelog'), sprintf($lang['upusrerr'], $clientuuid), 6, sprintf($lang['upusrinf'], $clientuuid));
}
}
}
Expand Down Expand Up @@ -541,8 +559,8 @@ function run_bot() {

if($looptime < 1) {
$loopsleep = (1 - $looptime);
if($cfg['teamspeak_query_encrypt_switch'] == 1) {
// no wait for data to become available on the stream on SSH due issues with non-blocking mode
if($cfg['teamspeak_query_encrypt_switch'] == 1 || version_compare($ts3version['version'],'1.4.0','>=') && version_compare($ts3version['version'],'2.9.9','<=')) {
// no wait for data to become available on the stream on SSH due issues with non-blocking mode or TeaSpeak
usleep(round($loopsleep * 1000000));
} else {
$ts3server->getAdapter()->waittsn($loopsleep, 50000); // 50ms delay for CPU reason
Expand Down
1 change: 1 addition & 0 deletions jobs/calc_serverstats.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_

if ($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.");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ts-n.net/ranksystem/'.$cfg['version_update_channel']);
curl_setopt($ch, CURLOPT_REFERER, 'TSN Ranksystem');
Expand Down
Loading

0 comments on commit 3a33371

Please sign in to comment.