/* Murmur WebAdministrator - Administration of Murmur Server on web for end users.
Copyright (C) 2009 Kevin Traub
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Mumbleviewer 1.0</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<script src="tooltip.js" type="text/javascript"></script>
<?php
$bgc = "FFFFFF";
$dlist = "555555";
$dserver = "555555";
$dfooter = "555555";
$tchan = "333333";
$tserv = "333333";
$tuser = "333333";
$tfoot = "888888";
if (isset($_REQUEST['bgc'])) {
$bgc = $_REQUEST['bgc'];
}
if (isset($_REQUEST['dlist'])) {
$dlist = $_REQUEST['dlist'];
}
if (isset($_REQUEST['dserver'])) {
$dserver = $_REQUEST['dserver'];
}
if (isset($_REQUEST['dfooter'])) {
$dfooter = $_REQUEST['dfooter'];
}
if (isset($_REQUEST['tchan'])) {
$tchan = $_REQUEST['tchan'];
}
if (isset($_REQUEST['tserv'])) {
$tserv = $_REQUEST['tserv'];
}
if (isset($_REQUEST['tuser'])) {
$tuser = $_REQUEST['tuser'];
}
if (isset($_REQUEST['tfoot'])) {
$tfoot = $_REQUEST['tfoot'];
}
?>
<style type="text/css">
a:link { text-decoration:none; }
a:visited { text-decoration:none; }
body { background-color:#<?=$bgc?>; }
.table { width:200px; }
.div_channel { white-space:nowrap; overflow:hidden; }
.div_clear { clear:left; }
.div_list { min-width:160px; max-width:220px; height:auto; border: 1px solid #<?=$dlist?>; padding:5px; background:url(images/list_background.png); background-repeat:no-repeat; background-position:inherit; }
/* NOT USED IN THIS THEME
.div_logo { width:160px; height:180px; padding:10px; background:url(background.png); background-repeat:no-repeat; background-position:top; }
*/
.div_server { padding:0px 5px 5px 5px; text-align:center; border-bottom:1px solid #<?=$dserver?>; }
.div_serverspace { padding:3px; }
.div_space { float:left; width:20px; }
.div_user { float:left; white-space:nowrap; min-width:10px; max-width:170px; overflow:hidden; }
.div_footer { padding:5px 5px 0px 5px; text-align:center; border-top:1px solid #<?=$dfooter?>; }
.image { vertical-align:middle; padding:0px 5px 0px 0px; height:20px; width:16px; }
.image_flags { vertical-align:middle; padding:0px 0px 0px 5px; height:20px; width:16px; }
.image_stats { vertical-align:middle; padding-right:5px; }
.text_channel { font:bold 11px Verdana, Arial, Helvetica, sans-serif; color:#<?=$tchan?>; vertical-align:middle; }
.text_server { font:small-caps 16px Verdana, Arial, Helvetica, sans-serif; color:#<?=$tserv?>; vertical-align:middle; }
.text_user { font:normal 11px Verdana, Arial, Helvetica, sans-serif; color:#<?=$tuser?>; vertical-align:middle; }
.text_footer { font:normal 9px Verdana, Arial, Helvetica, sans-serif; color:#<?=$tfoot?>; vertical-align:middle; width:150px; }
</style>
</head>
<?php
//error_reporting(E_ALL);
error_reporting(0);
Ice_loadProfile();
try {
$base = $ICE->stringToProxy("Meta:tcp -h 127.0.0.1 -p 6502");
$meta = $base->ice_checkedCast("::Murmur::Meta");
$servers = $meta->getBootedServers();
$default = $meta->getDefaultConf();
} catch (Ice_LocalException $ex) {
print_r($ex);
}
if (isset($_REQUEST['id'])) {
$servid = $_REQUEST['id'];
} else {
$servid=1;
}
$level[-1] = 0;
foreach($servers as $s) {
$serverids = $s->id();
//$serverids = $s->getConf("id");
//echo $serverids;
if ($servid == $serverids) {
$name = $s->getConf("registername");
if (! $name) {
$name = $default["registername"];
}
if ($name == "NotSet") {
$name = "BCB Hosting Mumble Server";
}
$channels = $s->getChannels();
$players = $s->getPlayers();
echo " <table class=\"table\"><tr><td align=\"center\"></td></tr>\n";
echo "<tr><td>\n";
echo "<div class='div_list'>\n";
echo "<div class='div_server'><span class='text_server'>$name</span></div>\n";
echo "<div class='div_serverspace'></div>";
print_users(0,has_children(0));
print_tree($channels, 0);
echo "<div class='div_serverspace'></div>\n";
echo "<a href=\"http://voice.bcbhosting.com/register.php\"target=\"_blank\"><div class ='div_footer' title=\"Click here to register!\">";
echo "<center><div class='text_footer'>Register now!</div></center></div></a>\n";
echo "</div></td></tr></table>\n";
}
}
// Functions
//Mainfunction: print tree structure
function print_tree($channels, $parentid) {
global $level;
global $printline;
$children = children($channels, $parentid);
if(!empty($children)){
foreach($children as $child => $name){
$has_children = children($channels,$child);
if(!empty($has_children)){
$has_children = 1;
}
else{
$has_children = 0;
}
if($name == end($children)){
$last_channel = 1;
}
echo "\n <!-- New channelline -->\n";
echo "<div class='div_clear'></div>";
if ($name == end($children)){
$printline[$level[$child]] = 0;
}
else{
$printline[$level[$child]] = 1;
}
for ($i = 1; $i <= $level[$child] - 1; $i++){
if($printline[$i] == 1){
print "<div class='div_space'><img src = 'images/list_tree_line.gif' class='image' alt=''/></div>";
}
else{
print "<div class='div_space'><img src = 'images/list_empty.png' class='image' alt=''/></div>";
}
}
//last branch infront of channel
if($last_channel){
echo "<div class='div_space'><img src = 'images/list_tree_end.gif' class='image' alt=''/></div>";
}
else{
echo "<div class='div_space'><img src = 'images/list_tree_mid.gif' class='image' alt=''/></div>";
}
//channel symbol and channel name
echo "<div class ='div_channel'><img src = 'images/list_channel.png' class='image' alt=''/>";
echo "<span class='text_channel'>$name</span></div>";
echo "\n <!-- End channelline -->\n";
print_users($child,has_children($child));
print_tree($channels, $child);
}
}
}
//Return all children of an ID
function children($channels, $id){
global $level;
foreach($channels as $c){
//if pid = id, push into array
if($c->parent == $id){
$children[$c->id] = $c->name;
//set level of child
if (isset($c->id)) {
$level[$c->id] = $level[$id] + 1;
}
}
}
if(!empty($children)){
asort($children);
}
if(!empty($children)){
return $children;
} else {
return null;
}
}
//display all users of a given channel
function print_users($channelid, $has_children){
global $players;
global $level;
global $printline;
//Look for players in channel and sort them
foreach($players as $player){
if($player->channel == $channelid){
$users[$player->session] = $player->name;
}
if(!empty($users)){
asort($users);
}
}
//display users
if(!empty($users)){
foreach($users as $session => $username){
echo "\n <!-- New userline -->\n";
echo "<div class='div_clear'></div>";
//Spaces
for ($i = 1; $i <= $level[$channelid]; $i++){
if($printline[$i] == 1){
print "<div class='div_space'><img src = 'images/list_tree_line.gif' class='image' alt=''/></div>";
}
else{
print "<div class='div_space'><img src = 'images/list_empty.png' class='image' alt=''/></div>";
}
}
//last branch infront of an user
if($username == end($users) && $has_children == 0){
echo "<div class='div_space'><img src = 'images/list_tree_end.gif' class='image' alt=''/></div>";
}
else{
echo "<div class='div_space'><img src = 'images/list_tree_mid.gif' class='image' alt=''/></div>";
}
//html chars for users;
$username = html_chars($username);
echo "<div class='div_user' title=\"header=[<img src='images/stats_header.png' class = 'image_stats'/>Stats for ";
echo "$username";
echo "] body=[<img src='images/stats_online_time.png' class = 'image_stats'/><b>Time online:</b> ";
get_timeonline($session);
echo "<br/><img src = 'images/stats_visitor.png' class = 'image_stats'/><b>Visitor:</b> # $session]\">";
echo "<img src = 'images/list_user.png' class='image'/>";
echo "<span class='text_user'>$username</span>";
print_userflags($session);
echo "<div class = 'div_clear'></div>";
echo "\n<!-- End userline -->\n";
}
}
}
//display all userflags
function print_userflags($session){
global $players;
if($players[$session]->playerid != -1){
echo "<img src = 'images/flag_authenticated.png' class = 'image_flags' alt = ''/>";
}
if($players[$session]->mute == 1){
echo "<img src = 'images/flag_muted_server.png' class = 'image_flags' alt = ''/>";
}
if($players[$session]->deaf == 1){
echo "<img src = 'images/flag_deafened_server.png' class = 'image_flags' alt = ''/>";
}
if($players[$session]->selfMute == 1){
echo "<img src = 'images/flag_muted_self.png' class = 'image_flags' alt = ''/>";
}
if($players[$session]->selfDeaf == 1){
echo "<img src = 'images/flag_deafened_self.png' class = 'image_flags' alt = ''/>";
}
echo "</div>";
}
//boolean, if channeld has children
function has_children($id){
global $channels;
$has_children = children($channels, $id);
if(!empty($has_children)){
return true;
}
return false;
}
//onlinetime of an user
function get_timeonline($session){
global $players;
$onlinesecs = $players[$session]->onlinesecs;
$onlinesecs = $onlinesecs % (60 * 60 * 24);
$hours = intval($onlinesecs / (60 * 60));
$onlinesecs = $onlinesecs % (60 * 60);
$mins = intval($onlinesecs / 60);
$onlinesecs = $onlinesecs % 60;
if(strlen($hours)==1){
$hours = "0".$hours;
}
if(strlen($mins)==1){
$mins = "0".$mins;
}
if(strlen($onlinesecs)==1){
$onlinesecs = "0".$onlinesecs;
}
$time = $hours.":".$mins.":".$onlinesecs;
echo $time;
}
//correct html chars
function html_chars($string){
$string = str_replace ("ü", "ü", $string);
$string = str_replace ("Ã", "Ü", $string);
$string = str_replace ("ö", "ö", $string);
$string = str_replace ("Ã", "Ö", $string);
$string = str_replace ("ä", "ä", $string);
$string = str_replace ("Ã", "Ä", $string);
$string = str_replace ("Ã", "ß", $string);
return $string;
}
?>
</body>
</html>