Skip to content

Commit

Permalink
release 1.3.22
Browse files Browse the repository at this point in the history
  • Loading branch information
Newcomer1989 committed Feb 1, 2023
1 parent b96e32b commit f7d7aed
Show file tree
Hide file tree
Showing 100 changed files with 5,709 additions and 1,434 deletions.
96 changes: 94 additions & 2 deletions api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
require_once('../other/config.php');

start_session($cfg);
$lang = set_language(get_language());

error_reporting(E_ALL);
ini_set("log_errors", 1);
set_error_handler("php_error_handling");
ini_set("error_log", $cfg['logs_path'].'ranksystem.log');
ini_set("error_log", $GLOBALS['logfile']);

header("Content-Type: application/json; charset=UTF-8");

Expand Down Expand Up @@ -48,7 +49,93 @@
$order = (isset($_GET['order']) && strtolower($_GET['order']) == 'desc') ? 'DESC' : 'ASC';
$part = (isset($_GET['part']) && is_numeric($_GET['part']) && $_GET['part'] > 0) ? (($_GET['part'] - 1) * $limit) : 0;

if (isset($_GET['groups'])) {
if (isset($_GET['bot'])) {
if(!isset($_GET['check']) && !isset($_GET['restart']) && !isset($_GET['start']) && !isset($_GET['stop'])) {
$json = array(
"usage" => array(
"_desc" => array(
"0" => "You are able to use bot commands with this function (start, stop, ..).",
"1" => "Use the Parameter, which are described below!",
"2" => "",
"3" => "Return values are:",
"4" => "- 'rc'",
"5" => "- 'msg'",
"6" => "- 'ranksystemlog'",
"7" => "",
"8" => "# RC",
"9" => "The return Code of the transaction (i.e. start process):",
"10" => "0 - EXIT_SUCCESS",
"11" => "1 - EXIT_FAILURE",
"12" => "",
"13" => "# MSG",
"14" => "An additional message of the process. In case of EXIT_FAILURE, you will receive here an error message.",
"15" => "",
"16" => "# RANKSYSTEMLOG",
"17" => "A short log extract of the last rows of the Ranksystem logfile to get more information about the Bot itself.",
),
"check" => array(
"desc" => "Check the Ranksystem Bot is running. If not, it will be started with this.",
"usage" => "Use \$_GET parameter 'check' without any value",
"example" => "/api/?bot&check"
),
"restart" => array(
"desc" => "Restarts the Ranksystem Bot.",
"usage" => "Use \$_GET parameter 'restart' without any value",
"example" => "/api/?bot&restart"
),
"start" => array(
"desc" => "Starts the Ranksystem Bot.",
"usage" => "Use \$_GET parameter 'start' without any value",
"example" => "/api/?bot&start"
),
"stop" => array(
"desc" => "Stops the Ranksystem Bot",
"usage" => "Use \$_GET parameter 'stop' without any value",
"example" => "/api/?bot&stop"
)
)
);
} else {
$check_permission = 0;
foreach($cfg['stats_api_keys'] as $apikey => $desc) {
if (hash_equals($apikey, $_GET['apikey']) && $desc['perm_bot'] == 1) {
$check_permission = 1;
break;
}
}
if ($check_permission == 1) {
if(isset($_GET['check'])) {
$result = bot_check();
} elseif(isset($_GET['restart'])) {
$result = bot_restart();
} elseif(isset($_GET['start'])) {
$result = bot_start();
} elseif(isset($_GET['stop'])) {
$result = bot_stop();
}
if(isset($result['log']) && $result['log'] != NULL) {
$ranksystemlog = $result['log'];
} else {
$ranksystemlog = "NULL";
}
$json = array(
"rc" => $result['rc'],
"msg" => $result['msg'],
"ranksystemlog" => $ranksystemlog
);
} else {
$json = array(
"Error" => array(
"invalid" => array(
"permissions" => "API Key is not permitted to start/stop the Ranksystem Bot"
)
)
);
echo json_encode($json);
exit;
}
}
} elseif (isset($_GET['groups'])) {
$sgidname = $all = '----------_none_selected_----------';
$sgid = -1;
if(isset($_GET['all'])) $all = 1;
Expand Down Expand Up @@ -463,6 +550,11 @@
} else {
$json = array(
"usage" => array(
"bot" => array(
"desc" => "Use this to trigger Bot commands as starting or stopping the Ranksystem Bot.",
"usage" => "Use \$_GET parameter 'bot'",
"example" => "/api/?bot"
),
"groups" => array(
"desc" => "Get details about the TeamSpeak servergroups",
"usage" => "Use \$_GET parameter 'groups'",
Expand Down
368 changes: 331 additions & 37 deletions install.php

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions jobs/addon_assign_groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions jobs/addon_channelinfo_toplist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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")));
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
Loading

0 comments on commit f7d7aed

Please sign in to comment.