Skip to content

Commit

Permalink
release 1.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Newcomer1989 committed Feb 15, 2020
1 parent 49bf90f commit f7dcb8f
Show file tree
Hide file tree
Showing 56 changed files with 2,846 additions and 1,436 deletions.
178 changes: 178 additions & 0 deletions api/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<?PHP
header("Content-Type: application/json; charset=UTF-8");

require_once('../other/dbconfig.php');

$dbname = $db['dbname'];
$dbtype = $db['type'];
if($db['type'] != "type") {
$dbserver = $db['type'].':host='.$db['host'].';dbname='.$dbname.';charset=utf8mb4';
$dboptions = array();
try {
$mysqlcon = new PDO($dbserver, $db['user'], $db['pass'], $dboptions);
} catch (PDOException $e) {
echo 'Database Connection failed: <b>'.$e->getMessage().'</b>';
exit;
}
}

if (isset($_GET['groups'])) {
$sgidname = $all = '----------_none_selected_----------';
$sgid = -1;
if(isset($_GET['all'])) {
$all = 1;
}
if(isset($_GET['sgid'])) {
$sgid = htmlspecialchars_decode($_GET['sgid']);
}
if(isset($_GET['sgidname'])) {
$sgidname = htmlspecialchars_decode($_GET['sgidname']);
}

if($sgid == -1 && $sgidname == '----------_none_selected_----------' && $all == '----------_none_selected_----------') {
$json = array(
"usage" => array(
"all" => array(
"desc" => "Get details about all TeamSpeak servergroups",
"usage" => "Use \$_GET parameter 'all' without any value",
"example" => "/api/?groups&all"
),
"sgid" => array(
"desc" => "Get details about TeamSpeak servergroups by the servergroup TS-database-ID",
"usage" => "Use \$_GET parameter 'sgid' and add as value the servergroup TS-database-ID",
"example" => "/api/?groups&sgid=123"
),
"sgidname" => array(
"desc" => "Get details about TeamSpeak servergroups by servergroup name or a part of it",
"usage" => "Use \$_GET parameter 'sgidname' and add as value a name or a part of it",
"example" => "/api/?groups&sgidname=Level01"
)
)
);
} else {
if ($all == 1) {
$dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`groups`");
} else {
$dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`groups` WHERE (`sgidname` LIKE :sgidname OR `sgid` LIKE :sgid)");
}
$dbdata->bindValue(':sgidname', '%'.$sgidname.'%', PDO::PARAM_STR);
$dbdata->bindValue(':sgid', (int) $sgid, PDO::PARAM_INT);
$dbdata->execute();
$json = $dbdata->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE);
foreach ($json as $sgid => $sqlpart) {
if ($sqlpart['icondate'] != 0 && $sqlpart['sgidname'] == 'ServerIcon') {
$json[$sgid]['iconpath'] = './tsicons/servericon.png';
} elseif ($sqlpart['icondate'] != 0) {
$json[$sgid]['iconpath'] = './tsicons/'.$sgid.'.png';
}
}
}
} elseif (isset($_GET['rankconfig'])) {
$dbdata = $mysqlcon->prepare("SELECT * FROM `$dbname`.`cfg_params` WHERE `param` in ('rankup_definition', 'rankup_time_assess_mode')");
$dbdata->execute();
$sql = $dbdata->fetchAll(PDO::FETCH_KEY_PAIR);
$json = array();
if ($sql['rankup_time_assess_mode'] == 1) {
$modedesc = "active time";
} else {
$modedesc = "online time";
}
$json['rankup_time_assess_mode'] = array (
"mode" => $sql['rankup_time_assess_mode'],
"mode_desc" => $modedesc
);
$count = 0;
krsort($sql['rankup_definition']);
foreach (explode(',', $sql['rankup_definition']) as $entry) {
list($key, $value) = explode('=>', $entry);
$addnewvalue1[$count] = array(
"grpid" => $value,
"seconds" => $key
);
$count++;
$json['rankup_definition'] = $addnewvalue1;
}
} elseif (isset($_GET['server'])) {
$dbdata = $mysqlcon->prepare("SELECT 0 as `row`, `$dbname`.`stats_server`.* FROM `$dbname`.`stats_server`");
$dbdata->execute();
$json = $dbdata->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE);
} elseif (isset($_GET['user'])) {
$uuid = $name = '----------_none_selected_----------';
$part = $cldbid = 0;
if(isset($_GET['uuid'])) {
$uuid = htmlspecialchars_decode($_GET['uuid']);
}
if(isset($_GET['cldbid'])) {
$cldbid = htmlspecialchars_decode($_GET['cldbid']);
}
if(isset($_GET['name'])) {
$name = htmlspecialchars_decode($_GET['name']);
}
if(isset($_GET['part'])) {
$part = (htmlspecialchars_decode($_GET['part']) - 1) * 10;
}

if($uuid == '----------_none_selected_----------' && $name == '----------_none_selected_----------' && $cldbid == 0) {
$json = array(
"usage" => array(
"uuid" => array(
"desc" => "Get details about TeamSpeak user by unique client ID",
"usage" => "Use \$_GET parameter 'uuid' and add as value one unique client ID or a part of it",
"example" => "/api/?user&uuid=xrTKhT/HDl4ea0WoFDQH2zOpmKg="
),
"cldbid" => array(
"desc" => "Get details about TeamSpeak user by client TS-database ID",
"usage" => "Use \$_GET parameter 'cldbid' and add as value a single client TS-database ID",
"example" => "/api/?user&cldbid=7775"
),
"name" => array(
"desc" => "Get details about TeamSpeak user by client nickname",
"usage" => "Use \$_GET parameter 'name' and add as value a name or a part of it",
"example" => "/api/?user&name=Newcomer1989"
),
"part" => array(
"desc" => "Define, which part of the result you want to get. This is needed, when more then 10 clients are inside the result. At default you will get the first 10 clients. To get the next 10 clients, you will need to answer for part 2.",
"usage" => "Use \$_GET parameter 'part' and add as value a number above 1",
"example" => "/api/?user&name=TeamSpeakUser&part=2"
)
)
);
} else {
$dbdata = $mysqlcon->prepare("SELECT `uuid`,`cldbid`,`rank`,`count`,`name`,`idle`,`cldgroup`,`online`,`nextup`,`lastseen`,`grpid`,`except`,`grpsince` FROM `$dbname`.`user` WHERE (`uuid` LIKE :uuid OR `cldbid` LIKE :cldbid OR `name` LIKE :name) LIMIT :start, :limit");
$dbdata->bindValue(':uuid', '%'.$uuid.'%', PDO::PARAM_STR);
$dbdata->bindValue(':cldbid', (int) $cldbid, PDO::PARAM_INT);
$dbdata->bindValue(':name', '%'.$name.'%', PDO::PARAM_STR);
$dbdata->bindValue(':start', (int) $part, PDO::PARAM_INT);
$dbdata->bindValue(':limit', (int) 10, PDO::PARAM_INT);
$dbdata->execute();
$json = $dbdata->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE);
}
} else {
$json = array(
"usage" => array(
"groups" => array(
"desc" => "Get details about the TeamSpeak servergroups",
"usage" => "Use \$_GET parameter 'groups'",
"example" => "/api/?groups"
),
"rankconfig" => array(
"desc" => "Get the rankup definition, which contains the assignment of (needed) time to servergroup",
"usage" => "Use \$_GET parameter 'rankconfig'",
"example" => "/api/?rankconfig"
),
"server" => array(
"desc" => "Get details about the TeamSpeak server",
"usage" => "Use \$_GET parameter 'server'",
"example" => "/api/?server"
),
"user" => array(
"desc" => "Get details about the TeamSpeak user",
"usage" => "Use \$_GET parameter 'user'",
"example" => "/api/?user"
)
)
);
}

echo json_encode($json);
?>
8 changes: 4 additions & 4 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.4';
$rsversion = '1.3.7';
?>
<!DOCTYPE html>
<html>
Expand Down Expand Up @@ -100,7 +100,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
}
}

if($mysqlcon->exec("CREATE TABLE `$dbname`.`groups` (`sgid` int(10) NOT NULL default '0' PRIMARY KEY,`sgidname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`iconid` bigint(10) NOT NULL default '0',`icondate` bigint(11) NOT NULL default '0')") === false) {
if($mysqlcon->exec("CREATE TABLE `$dbname`.`groups` (`sgid` int(10) NOT NULL default '0' PRIMARY KEY,`sgidname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`iconid` bigint(10) NOT NULL default '0',`icondate` bigint(11) NOT NULL default '0',`sortid` int(10) NOT NULL default '0',`type` tinyint(1) NOT NULL default '0')") === false) {
$err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'<br>'; $err_lvl = 2;
$count++;
}
Expand Down Expand Up @@ -223,7 +223,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
unset($err_msg);
if ($_POST['dbtype'] == 'mysql') {
if(!in_array('pdo_mysql', get_loaded_extensions())) {
unset($err_msg); $err_msg .= "<br>".$lang['insterr9']; $err_lvl = 3;
unset($err_msg); $err_msg = sprintf($lang['insterr2'],'PHP MySQL','//php.net/manual/en/ref.pdo-mysql.php'); $err_lvl = 3;
} else {
$dboptions = array();
}
Expand Down Expand Up @@ -289,7 +289,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=>47,31536060=>50'), ('rankup_excepted_channel_id_list', ''), ('rankup_excepted_group_id_list', '2,6'), ('rankup_excepted_mode', '0'), ('rankup_excepted_unique_client_id_list', 'xrTKhT/HDL4ea0WoFDQH2zOpmKg='), ('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_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_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=>47,31536060=>50'), ('rankup_excepted_channel_id_list', ''), ('rankup_excepted_group_id_list', '2,6'), ('rankup_excepted_mode', '0'), ('rankup_excepted_unique_client_id_list', 'xrTKhT/HDL4ea0WoFDQH2zOpmKg='), ('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_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) {
$err_msg = $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 2;
} else {
$err_msg = $lang['isntwiusr'].'<br><br>';
Expand Down
18 changes: 10 additions & 8 deletions jobs/bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,9 @@ function sendmessage($ts3, $cfg, $uuid, $msg, $erromsg=NULL, $errcode=NULL, $suc
}
}

$sqlexec = '';

function run_bot() {
global $cfg, $mysqlcon, $dbname, $dbtype, $lang, $phpcommand, $addons_config, $sqlexec, $max_execution_time, $memory_limit;
global $cfg, $mysqlcon, $dbname, $dbtype, $lang, $phpcommand, $addons_config, $max_execution_time, $memory_limit;

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 {
Expand Down Expand Up @@ -380,6 +378,12 @@ function run_bot() {
}
}

if($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));
}
}

unset($groupslist,$errcnf,$checkgroups,$lastupdate,$updcld,$loglevel,$whoami,$ts3host,$max_execution_time,$memory_limit,$memory_limit);
enter_logfile($cfg,9,"Config check [done]");

Expand All @@ -388,6 +392,7 @@ function run_bot() {
usleep(3000000);

while(1) {
$sqlexec = '';
$starttime = microtime(true);
$weekago = time() - 604800;
$monthago = time() - 2592000;
Expand Down Expand Up @@ -491,7 +496,6 @@ function run_bot() {
reset_rs($ts3server,$mysqlcon,$lang,$cfg,$dbname,$select_arr);

unset($sqlexec,$select_arr,$sqldump);
$sqlexec = '';

$looptime = microtime(true) - $starttime;
$cfg['temp_whole_laptime'] = $cfg['temp_whole_laptime'] + $looptime;
Expand All @@ -512,8 +516,7 @@ function run_bot() {
}
} catch (Exception $e) {
enter_logfile($cfg,2,$lang['errorts3'].$e->getCode().': '.$e->getMessage());
$offline_status = array(110,257,258,1024,1026,1031,1032,1033,1034,1280,1793);
if(in_array($e->getCode(), $offline_status)) {
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));
}
Expand Down Expand Up @@ -546,7 +549,6 @@ function run_bot() {
} else {
shutdown($mysqlcon,$cfg,1,"Critical TS3 error on core function!");
}
unset($offline_status,$wait_reconnect,$z);
}
}

Expand Down
Loading

0 comments on commit f7dcb8f

Please sign in to comment.