forked from xman8830/BannerTS3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.php
69 lines (66 loc) · 2.65 KB
/
debug.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
require_once __DIR__ . "/config.php";
require_once __DIR__ . "/picture_template.php";
$ip = getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED') ?: getenv('REMOTE_ADDR');
$adminonline = 0;
$nick = $config['img']['found_nick'];
if ($config['settings'] == 'auto') {
require_once __DIR__ . "/class/ts3admin.class.php";
$files = array_diff(scandir('cache'), array('..', '.', 'fulls', 'thumbs'));
if (!empty($config['cache_name']) or $config['cache_name'] != '') {
if (!in_array($config['cache_name'] ,$files)) {
if(touch('./cache/'.$config['cache_name'])) {
if(chmod('./cache/'.$config['cache_name'], 0777)) {
$cache = 'success';
} else {
alert ('The folder and the cache file were created, no access rights were granted');
exit;
}
} else {
alert ('Not created <b>cache</b>');
exit;
}
} else {
$srv = '';
if (!file_exists('cache/'.$config['cache_name']) || filemtime('cache/'.$config['cache_name']) + 1 * 30 < time()) {
$query = new ts3admin($config['ts3']['host'], $config['ts3']['query_port'], 2);
$query->connect();
$query->login($config['ts3']['login'],$config['ts3']['password']);
$query->selectServer($config['ts3']['login_port']);
$srv = [];
$srv['server'] = $query->getElement('data', $query->serverInfo());
$srv['groups'] = $query->getElement('data', $query->serverGroupList());
$srv['clients'] = $query->getElement('data', $query->clientList('-uid -away -voice -times -groups -info -icon -country -ip'));
$srv['channel'] = $query->getElement('data', $query->channelList());
$srv['banlist'] = $query->getElement('data', $query->banList());
@file_put_contents('cache/'.$config['cache_name'], json_encode($srv));
} else {
$srv = file_get_contents('cache/'.$config['cache_name']);
$srv = json_decode($srv, true);
}
}
} else {
alert ('cache name not found in config.php');
exit;
}
} elseif ($config['settings'] == 'bot') {
$ts3 = file_get_contents('cache/'.$config['cache_name']);
$srv = json_decode($ts3, true);
}
if ($weather['status']) {
//$json = file_get_contents('https://api.xman8830.ovh/weather?key='.$config['apikey'].'&ip=' . $ip);
//$data = json_decode($json, true);
//$weathericonfile = 'weathericon/' . $data['icon'] . '.png';
foreach ($srv['clients'] as $client) {
$groups = explode(',', $client['client_servergroups']);
echo $groups;
if ($client["connection_client_ip"] == $ip) {
$nick = $client['client_nickname'];
}
foreach ($admingroups as $group) {
if (in_array($group, $groups)) {
$adminonline++;
}
}
}
}