This repository has been archived by the owner on Feb 18, 2023. It is now read-only.
/
index.php
99 lines (81 loc) · 2.26 KB
/
index.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
// include configurtion
include 'config.inc.php';
// build Ice connection to murmur
try {
require_once 'Ice.php';
require_once 'Murmur.php';
$ICE = Ice_initialize();
$meta = Murmur_MetaPrxHelper::checkedCast($ICE->stringToProxy($config['ice_proxy_string']));
} catch (Ice_Exception $ex) {
print_r($ex);
}
// get server 1
$server = $meta->getServer($config['mumble_server']);
$tree = $server->getTree();
// helper functions
function has_Sub($item) {
if (count($item->children) > 0 || count($item->users) > 0) {
// if ($item->children || $item->users) {
return True;
} else {
return False;
}
}
function pChannel($c) {
$channelID = $c->c->id;
$channelName = $c->c->name;
$html_class = 'mumble-channel';
$extra_tags = '';
// has sub channels or users?
if (!has_Sub($c)) {
$html_class .= ' nosub';
}
// open root channel
if ($channelID == 0) {
$extra_tags = 'checked="checked"';
}
echo '<li class="'. $html_class .'">';
if (has_Sub($c)) {
echo '<input type="checkbox" '.$extra_tags . ' id="channelID-'. $channelID . '" />';
}
echo '<label for="channelID-' . $channelID .'">'. $channelName . '</label>';
// echo '<li>'. $c->c->name ;
}
function pUsers($users) {
// echo '<ul>';
foreach($users as $user) {
echo '<li class="mumble-user"><span>' . $user->name . '</span></li>';
}
// echo '</ul>';
}
function getChannel($c) {
// echo '<li>';
pChannel($c);
if (has_Sub($c)) {
// if ($c->children || $c->users) {
echo '<ul>';
for ($i =0 ; $i < count($c->children); ++$i) {
// foreach on $c use a wrong channel order
// foreach ($c->children as $child) {
getChannel($c->children[$i]);
}
pUsers($c->users);
echo '</ul>';
}
//echo '</li>';
// if ($c->users) {pUsers($c->users);}
echo '</li>';
}
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
echo '<html lang="en-GB">';
echo '<head>';
echo '<meta http-equiv="Content-Type" content="text/html;charset=utf-8">';
echo '<link rel="stylesheet" type="text/css" href="style/default/style.css" media="screen">';
echo '<title>MumbleViewer without any JavaScript</title>';
echo '</head><body>';
echo '<div class="mv-treeview">';
echo '<ul>';
getChannel($tree);
echo '</ul>';
echo '</div></body></html>';