<?php
/* 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 3 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. If not, see <http://www.gnu.org/licenses/>.
*/
include 'config.php';
include 'functions.php';
if ($_SESSION['IsAdmin'] != "1") {
echo "<META HTTP-EQUIV='refresh' CONTENT='0;URL=/login.php'>";
exit();
}
echo basecss();
echo basemenu($logged, $meta, $serverid);
switch ($_REQUEST['Submit']) {
case 'addchannel':
if (isset($_REQUEST['chanid'])) {
$cid = $_REQUEST['chanid'];
$cname = $_REQUEST['channame'];
$server->addChannel($cname,$cid+0);
$action = "Channels";
} else {
echo "<div class='header'>Error</div></div>\n";
}
break;
case 'addchan' :
if (isset($_REQUEST['chanid'])) {
$cid = $_REQUEST['chanid'];
echo "<div class='header'>Add Channel Form</div>\n";
echo "<form method='post' name='addchan' action='".$_SERVER['PHP_SELF']."'>\n";
echo "<input type='hidden' name='chanid' value='$cid'>";
echo "<b>Channel name:</b>  <input type='text' name='channame' size='20'>\n";
echo "<input type='submit' value='addchannel' name='Submit'>\n";
echo "</p>\n";
echo "</form><br><a href='".$_SERVER['PHP_SELF']."?action=Channels'>Cancel</a><div>\n";
//$action = "Channels";
} else {
echo "<div class='header'>Error</div></div>\n";
}
break;
// Send Channel Message
case 'sendchanmes':
if (isset($_REQUEST['chanid'])) {
$cid = $_REQUEST['chanid'];
$message = $_REQUEST['message'];
if (isset($_REQUEST['tree'])) {
$tree = $_REQUEST['tree'];
} else {
$tree = 0;
}
$server->sendMessageChannel($cid + 0, (bool) $tree, $message);
echo "<div class='header'>Message Sent!</div>";
}
break;
case 'chanmes':
if (isset($_REQUEST['chanid'])) {
$cid = $_REQUEST['chanid'];
?>
<div class='header'>Send Message to Channel</div>
<form method='POST' name='chanmess' action='".$_SERVER['PHP_SELF']."'>
<input type='hidden' name='chanid' value='<?=$cid;?>'>
Message: <input type='text' name='message' size='100'><br>
<input type="checkbox" name="tree" value="TRUE">  Send to all Sub-Channels
<input type='submit' value='sendchanmes' name='Submit'><br><hr>
</form>
</div>
<?php
}
break;
case 'dcv' :
if (isset($_REQUEST['chanid'])) {
$cid = $_REQUEST['chanid'];
$cname = "";
//echo $cid;
$channels = $server->getChannels();
foreach($channels as $c) {
//echo $c->id;
if ($cid == $c->id) {
$cname = $c->name;
}
}
echo "<div class='header'>Verify Channel Deletion!</div>\n";
echo "<form method='post' name='delver' action='".$_SERVER['PHP_SELF']."'>\n";
echo "<input type='hidden' name='chanid' value='$cid'>";
echo "<b>Channel name:</b>  $cname\n";
echo "<input type='submit' value='delchan' name='Submit'>\n";
echo "</p>\n";
echo "</form><br><a href='".$_SERVER['PHP_SELF']."?action=Channels'>Cancel deletion</a><div>\n";
} else {
echo "<div class='main' style='min-width:550px;' ><div class='header'>Error</div></div>\n";
}
break;
// Delete Channel
case 'delchan' :
if (isset($_REQUEST['chanid'])) {
$cid = $_REQUEST['chanid'];
if ($cid != 0) {
$server->removeChannel($cid + 0);
echo "<div class='header'>Channel Deleted!</div>";
} else {
echo "<span class='alt_text'>You cannot delete the root channel.</span>";
}
$action = "Channels";
} else {
echo "<div class='header'>Error</div>\n";
}
break;
}
try {
$players = $server->getPlayers();
$showusers = 1;
echo "<div class='header'>Channel List</div>\n";
$channels = $server->getChannels();
echo "<ul>";
if ($_SESSION['IsAdmin'] == "1") {
echo "<li><a href='".$_SERVER['PHP_SELF']."?Submit=addchan&chanid=0'><img src='images/add.gif' class='image' alt='Add Channel' title='Add Channel' BORDER=0 HEIGHT=16 WIDTH=20/></a>";
echo "<a href='".$_SERVER['PHP_SELF']."?Submit=chanmes&chanid=0'><img src = 'images/chat.gif' class='image' alt='Send Message' title='Send Message' BORDER=0 HEIGHT=16 WIDTH=20/></a>";
echo "</li>";
} else {
echo "<ul><li></li>\n";
}
//print_channellist($channels, 0);
print_users(0,has_children(0),$server);
print_tree($channels, 0);
echo "</ul>";
echo "<br /><br /></table>\n";
$showusers = 0;
}
catch (Ice_Exception $ex) {
echo "<div class='header'>Server OffLine</div>\n";
}
include 'footer.php';
?>