Skip to content

Commit f7d7aed

Browse files
committed
release 1.3.22
1 parent b96e32b commit f7d7aed

100 files changed

Lines changed: 5709 additions & 1434 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/index.php

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
require_once('../other/config.php');
44

55
start_session($cfg);
6+
$lang = set_language(get_language());
67

78
error_reporting(E_ALL);
89
ini_set("log_errors", 1);
910
set_error_handler("php_error_handling");
10-
ini_set("error_log", $cfg['logs_path'].'ranksystem.log');
11+
ini_set("error_log", $GLOBALS['logfile']);
1112

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

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

51-
if (isset($_GET['groups'])) {
52+
if (isset($_GET['bot'])) {
53+
if(!isset($_GET['check']) && !isset($_GET['restart']) && !isset($_GET['start']) && !isset($_GET['stop'])) {
54+
$json = array(
55+
"usage" => array(
56+
"_desc" => array(
57+
"0" => "You are able to use bot commands with this function (start, stop, ..).",
58+
"1" => "Use the Parameter, which are described below!",
59+
"2" => "",
60+
"3" => "Return values are:",
61+
"4" => "- 'rc'",
62+
"5" => "- 'msg'",
63+
"6" => "- 'ranksystemlog'",
64+
"7" => "",
65+
"8" => "# RC",
66+
"9" => "The return Code of the transaction (i.e. start process):",
67+
"10" => "0 - EXIT_SUCCESS",
68+
"11" => "1 - EXIT_FAILURE",
69+
"12" => "",
70+
"13" => "# MSG",
71+
"14" => "An additional message of the process. In case of EXIT_FAILURE, you will receive here an error message.",
72+
"15" => "",
73+
"16" => "# RANKSYSTEMLOG",
74+
"17" => "A short log extract of the last rows of the Ranksystem logfile to get more information about the Bot itself.",
75+
),
76+
"check" => array(
77+
"desc" => "Check the Ranksystem Bot is running. If not, it will be started with this.",
78+
"usage" => "Use \$_GET parameter 'check' without any value",
79+
"example" => "/api/?bot&check"
80+
),
81+
"restart" => array(
82+
"desc" => "Restarts the Ranksystem Bot.",
83+
"usage" => "Use \$_GET parameter 'restart' without any value",
84+
"example" => "/api/?bot&restart"
85+
),
86+
"start" => array(
87+
"desc" => "Starts the Ranksystem Bot.",
88+
"usage" => "Use \$_GET parameter 'start' without any value",
89+
"example" => "/api/?bot&start"
90+
),
91+
"stop" => array(
92+
"desc" => "Stops the Ranksystem Bot",
93+
"usage" => "Use \$_GET parameter 'stop' without any value",
94+
"example" => "/api/?bot&stop"
95+
)
96+
)
97+
);
98+
} else {
99+
$check_permission = 0;
100+
foreach($cfg['stats_api_keys'] as $apikey => $desc) {
101+
if (hash_equals($apikey, $_GET['apikey']) && $desc['perm_bot'] == 1) {
102+
$check_permission = 1;
103+
break;
104+
}
105+
}
106+
if ($check_permission == 1) {
107+
if(isset($_GET['check'])) {
108+
$result = bot_check();
109+
} elseif(isset($_GET['restart'])) {
110+
$result = bot_restart();
111+
} elseif(isset($_GET['start'])) {
112+
$result = bot_start();
113+
} elseif(isset($_GET['stop'])) {
114+
$result = bot_stop();
115+
}
116+
if(isset($result['log']) && $result['log'] != NULL) {
117+
$ranksystemlog = $result['log'];
118+
} else {
119+
$ranksystemlog = "NULL";
120+
}
121+
$json = array(
122+
"rc" => $result['rc'],
123+
"msg" => $result['msg'],
124+
"ranksystemlog" => $ranksystemlog
125+
);
126+
} else {
127+
$json = array(
128+
"Error" => array(
129+
"invalid" => array(
130+
"permissions" => "API Key is not permitted to start/stop the Ranksystem Bot"
131+
)
132+
)
133+
);
134+
echo json_encode($json);
135+
exit;
136+
}
137+
}
138+
} elseif (isset($_GET['groups'])) {
52139
$sgidname = $all = '----------_none_selected_----------';
53140
$sgid = -1;
54141
if(isset($_GET['all'])) $all = 1;
@@ -463,6 +550,11 @@
463550
} else {
464551
$json = array(
465552
"usage" => array(
553+
"bot" => array(
554+
"desc" => "Use this to trigger Bot commands as starting or stopping the Ranksystem Bot.",
555+
"usage" => "Use \$_GET parameter 'bot'",
556+
"example" => "/api/?bot"
557+
),
466558
"groups" => array(
467559
"desc" => "Get details about the TeamSpeak servergroups",
468560
"usage" => "Use \$_GET parameter 'groups'",

install.php

Lines changed: 331 additions & 37 deletions
Large diffs are not rendered by default.

jobs/addon_assign_groups.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ function addon_assign_groups($addons_config,$ts3,$cfg,$dbname,$allclients,&$db_c
2020
try {
2121
usleep($cfg['teamspeak_query_command_delay']);
2222
$ts3->serverGroupClientDel($group, $cldbid);
23-
enter_logfile($cfg,6,"Removed servergroup $group from user $nickname (UID: $uid), requested by Add-on 'Assign Servergroups'");
23+
enter_logfile(6,"Removed servergroup $group from user $nickname (UID: $uid), requested by Add-on 'Assign Servergroups'");
2424
}
2525
catch (Exception $e) {
26-
enter_logfile($cfg,2,"addon_assign_groups:".$e->getCode().': '."Error while removing group: ".$e->getMessage());
26+
enter_logfile(2,"addon_assign_groups:".$e->getCode().': '."Error while removing group: ".$e->getMessage());
2727
}
2828
} else {
2929
try {
3030
usleep($cfg['teamspeak_query_command_delay']);
3131
$ts3->serverGroupClientAdd($group, $cldbid);
32-
enter_logfile($cfg,6,"Added servergroup $group from user $nickname (UID: $uid), requested by Add-on 'Assign Servergroups'");
32+
enter_logfile(6,"Added servergroup $group from user $nickname (UID: $uid), requested by Add-on 'Assign Servergroups'");
3333
} catch (Exception $e) {
34-
enter_logfile($cfg,2,"addon_assign_groups:".$e->getCode().': '."Error while adding group: ".$e->getMessage());
34+
enter_logfile(2,"addon_assign_groups:".$e->getCode().': '."Error while adding group: ".$e->getMessage());
3535
}
3636
}
3737
}

jobs/addon_channelinfo_toplist.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ function addon_channelinfo_toplist(&$addons_config,$ts3,$mysqlcon,$cfg,$dbname,$
55

66
$smarty = new Smarty();
77

8-
$smarty->setTemplateDir($cfg['logs_path'].'smarty/templates');
9-
$smarty->setCompileDir($cfg['logs_path'].'smarty/templates_c');
10-
$smarty->setCacheDir($cfg['logs_path'].'smarty/cache');
11-
$smarty->setConfigDir($cfg['logs_path'].'smarty/configs');
8+
$smarty->setTemplateDir($GLOBALS['logpath'].'smarty/templates');
9+
$smarty->setCompileDir($GLOBALS['logpath'].'smarty/templates_c');
10+
$smarty->setCacheDir($GLOBALS['logpath'].'smarty/cache');
11+
$smarty->setConfigDir($GLOBALS['logpath'].'smarty/configs');
1212

1313
if(isset($addons_config['channelinfo_toplist_active']['value']) && $addons_config['channelinfo_toplist_active']['value'] == '1') {
1414
if($addons_config['channelinfo_toplist_lastupdate']['value'] < ($nowtime - $addons_config['channelinfo_toplist_delay']['value'])) {
@@ -46,10 +46,10 @@ function addon_channelinfo_toplist(&$addons_config,$ts3,$mysqlcon,$cfg,$dbname,$
4646
}
4747

4848
$filter = " AND `user`.`uuid` NOT IN ($notinuuid) AND `user`.`cldgroup` NOT IN ($notingroup) $andnotgroup ".$filter;
49-
#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");
49+
#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");
5050

5151
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) {
52-
enter_logfile($cfg,2,'addon_channelinfo1: '.print_r($mysqlcon->errorInfo(), true));
52+
enter_logfile(2,'addon_channelinfo1: '.print_r($mysqlcon->errorInfo(), true));
5353
}
5454

5555
$smarty->assign('LAST_UPDATE_TIME',(DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($cfg['logs_timezone']))->format("Y-m-d H:i:s")));
@@ -125,16 +125,16 @@ function addon_channelinfo_toplist(&$addons_config,$ts3,$mysqlcon,$cfg,$dbname,$
125125
$addons_config['channelinfo_toplist_lastupdate']['value'] = $nowtime;
126126
$toplist_desc = $mysqlcon->quote($toplist_desc, ENT_QUOTES);
127127
$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";
128-
enter_logfile($cfg,5,' Addon: \'channelinfo_toplist\' writing new channelinfo toplist to channel description.');
128+
enter_logfile(5,' Addon: \'channelinfo_toplist\' writing new channelinfo toplist to channel description.');
129129
} catch (Exception $e) {
130-
enter_logfile($cfg,2,'addon_channelinfo2: ['.$e->getCode().']: '.$e->getMessage());
130+
enter_logfile(2,'addon_channelinfo2: ['.$e->getCode().']: '.$e->getMessage());
131131
}
132132
}
133133
} catch (Exception $e) {
134134
$errmsg = str_replace('"', '\'', $e->getMessage());
135135
$addons_config['channelinfo_toplist_lastupdate']['value'] = $nowtime;
136136
$sqlexec .= "INSERT IGNORE INTO `$dbname`.`addons_config` (`param`,`value`) VALUES ('channelinfo_toplist_lastupdate','{$nowtime}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);\n";
137-
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);
137+
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);
138138
}
139139
}
140140
}

0 commit comments

Comments
 (0)