2016-06-28 21:18:59 +00:00
|
|
|
<?php
|
|
|
|
require_once __DIR__ . "/tsutils.php";
|
2017-01-29 21:56:17 +00:00
|
|
|
require_once __DIR__ . "/cacheutils.class.php";
|
2016-06-28 21:18:59 +00:00
|
|
|
|
2017-01-29 21:56:17 +00:00
|
|
|
$cacheutils = new CacheUtils('adminlist');
|
2016-06-28 21:18:59 +00:00
|
|
|
|
2017-01-29 21:56:17 +00:00
|
|
|
if($cacheutils->isExpired()) {
|
2017-04-12 00:37:32 +00:00
|
|
|
$cacheutils->setValue([getAdminList(), date('d-m-Y H:i:s')], 120);
|
2016-06-28 21:18:59 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 21:56:17 +00:00
|
|
|
$adminlist = $cacheutils->getValue();
|
2016-06-30 02:20:51 +00:00
|
|
|
|
2016-06-28 21:18:59 +00:00
|
|
|
// FUNCTIONS
|
|
|
|
|
|
|
|
function getAdminList() {
|
2016-06-30 02:20:51 +00:00
|
|
|
global $config;
|
2016-07-25 14:14:04 +00:00
|
|
|
global $lang;
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-30 02:20:51 +00:00
|
|
|
$admingroups = $config["adminlist"];
|
|
|
|
$localIcons = array(100, 200, 300, 400, 500, 600);
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-28 21:18:59 +00:00
|
|
|
try {
|
2017-02-01 15:31:32 +00:00
|
|
|
$tsAdmin = getTeamspeakConnection();
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-28 21:18:59 +00:00
|
|
|
$output = "";
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-30 02:20:51 +00:00
|
|
|
foreach ($admingroups as $group) {
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-10-31 02:18:46 +00:00
|
|
|
if (!array_key_exists((string)$group, $tsAdmin->serverGroupList()))
|
2016-06-28 21:18:59 +00:00
|
|
|
continue;
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-30 02:20:51 +00:00
|
|
|
$group = $tsAdmin->serverGroupGetById($group);
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-30 02:20:51 +00:00
|
|
|
$icon = '';
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-10-31 02:18:46 +00:00
|
|
|
if ($group["iconid"]) {
|
|
|
|
if (!$group->iconIsLocal("iconid")) {
|
2016-06-30 02:20:51 +00:00
|
|
|
$groupicon = getGroupIcon($tsAdmin, $group);
|
|
|
|
|
2016-10-31 02:18:46 +00:00
|
|
|
if ($groupicon) {
|
2016-07-10 16:46:04 +00:00
|
|
|
$icon = '<img src="data:' . TeamSpeak3_Helper_Convert::imageMimeType($groupicon) . ';base64,' . base64_encode($groupicon) . '" alt="Ikona grupy" /> ';
|
2016-06-30 02:20:51 +00:00
|
|
|
}
|
2016-10-31 02:18:46 +00:00
|
|
|
} elseif (in_array($group["iconid"], $localIcons)) {
|
2016-07-10 16:46:04 +00:00
|
|
|
$icon = '<img src="lib/ts3phpframework/images/viewer/group_icon_' . $group["iconid"] . '.png" alt="Ikona grupy" /> ';
|
2016-06-30 02:20:51 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-30 02:20:51 +00:00
|
|
|
$output .= "<p class=\"groupname\">$icon$group</p>";
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-30 02:20:51 +00:00
|
|
|
$clients = $group->clientList();
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-10-31 02:18:46 +00:00
|
|
|
if (empty($clients)) {
|
2016-07-25 14:14:04 +00:00
|
|
|
$output .= '<p class="text-center"><i>' . translate($lang["adminlist"]["emptygroup"]) . '</i></p>';
|
2016-06-30 02:20:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-11-18 20:38:05 +00:00
|
|
|
$onlineClients = [];
|
|
|
|
$offlineClients = [];
|
|
|
|
|
2016-06-30 02:20:51 +00:00
|
|
|
foreach ($clients as $userInfo) {
|
2016-06-28 21:18:59 +00:00
|
|
|
$user = getClientByDbid($tsAdmin, $userInfo['cldbid']);
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2017-01-27 05:02:52 +00:00
|
|
|
if($user["client_type"]) continue;
|
|
|
|
|
2016-10-31 02:18:46 +00:00
|
|
|
if (!$user) {
|
2016-11-18 20:38:05 +00:00
|
|
|
$offlineClients[] = '<p><span class="label label-primary iconspacer">' . $userInfo['client_nickname'] . '</span><span class="label label-danger pull-right">' . translate($lang["adminlist"]["status"]["offline"]) . '</span></p>';
|
2016-06-28 21:18:59 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-11-18 20:38:05 +00:00
|
|
|
$onlineClients[] = '<p><img src="lib/ts3phpframework/images/viewer/' . $user->getIcon() . '.png" alt="User status">' . '<span class="label label-primary">' . $user . '</span>' . ($user['client_away'] ? '<span class="label label-warning pull-right">' . translate($lang["adminlist"]["status"]["away"]) . '</span>' : '<span class="label label-success pull-right">' . translate($lang["adminlist"]["status"]["online"]) . '</span>') . '</p>';
|
2016-06-28 21:18:59 +00:00
|
|
|
}
|
2016-11-18 20:38:05 +00:00
|
|
|
|
|
|
|
foreach (array_merge($onlineClients, $offlineClients) as $str)
|
|
|
|
$output .= $str;
|
2016-06-28 21:18:59 +00:00
|
|
|
}
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-28 21:18:59 +00:00
|
|
|
return $output;
|
2016-10-31 02:18:46 +00:00
|
|
|
} catch (TeamSpeak3_Exception $e) {
|
2016-07-25 14:14:04 +00:00
|
|
|
return '<div class="alert alert-danger"><p class="text-center">' . translate($lang["general"]["scripterror"], [$e->getCode(), $e->getMessage()]) . '</p></div>';
|
2016-06-28 21:18:59 +00:00
|
|
|
}
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-28 21:18:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getClientByDbid($tsAdmin, $cldbid) {
|
|
|
|
try {
|
|
|
|
return $tsAdmin->clientGetByDbid($cldbid);
|
2016-10-31 02:18:46 +00:00
|
|
|
} catch (TeamSpeak3_Exception $e) {
|
2016-06-28 21:18:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-30 02:20:51 +00:00
|
|
|
function getGroupIcon($tsAdmin, $group) {
|
|
|
|
try {
|
|
|
|
return $group->iconDownload();
|
2016-10-31 02:18:46 +00:00
|
|
|
} catch (TeamSpeak3_Exception $e) {
|
2016-06-30 02:20:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 21:18:59 +00:00
|
|
|
// echo getAdminList();
|