Location: PHPKode > projects > Murmuradmin > banlist.php
<?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 ($_POST['Submit']) {
	case 'Add Ban' :
		$newbans = array();
		$ip = $_REQUEST['bip'];
		$dip = ip2dec($ip);
		$bans = $server->getBans();
		foreach($bans as $b) {
			//$newbans[] = array("address"=>$b->address, "bits"=>$b->bits);
			//$structure['Murmur_Ban Object'][] = array("address"=>$b->address);
			//$structure['Murmur_Ban Object'][] = array("bits"=>$b->bits);
			$server->setBans(array("address"=>$b->address));

		}
		$newbans[] = array("address"=>(int)$dip, "bits"=>32);
		//$server->setBans($structure);
	break;
}

if ($action == "DeleteBan") {
	if (isset($_REQUEST['ip'])) {
		$newbans = array();
		$ip = (int)$_REQUEST['ip'];
		$dip = ip2dec($ip);
		$bans = $server->getBans();
		foreach($bans as $b) {
			if ($b->address != $dip) {
				//$newbans[] = array("Murmur_Ban Object"=>("address"=>$b->address, "bits"=>$b->bits));
				$newbans[] = "Murmur_Ban Object,address,$b->address,bits,$b->bits";
			}
		}
		$server->setBans($newbans);
	} else {
		echo "<div class='header'>Unknown Address!</div><br>\n";
	}
}

try {
	echo "<div class='header'>Ban List</div>\n";
	echo "<table id='hor-minimalist-b'>\n";
	echo "<tr><th>Banned IP Address</th><th>";
	echo "</th></tr>\n";
	$bans = $server->getBans();
	print_r($bans);
	asort($bans);
	foreach($bans as $b) {
		$ip = dec2ip($b->address);
		echo "<tr><td>$ip</td><td>";
		echo "<a href='?action=DeleteBan&ip=".$b->address."'>Remove Ban</a> ";
		echo "</td></tr>\n";
		//print_r($b);
	}
	echo "</table>\n";

	echo "<div class='header'>Add Ban:</div>";
	echo "<form method='post' name='addban' action='".$_SERVER['PHP_SELF']."'>\n";
	echo "<center><table>\n";
	echo "<b>IP Address to ban:</b> <input type='text' name='bip' size='30' maxlength='30' value='xxx.xxx.xxx.xxx' /><br />\n";
	echo "<input type='submit' value='Add Ban' name='Submit'>\n";
	echo "</table></center>\n";
	echo "</form><br>\n";

}

catch (Ice_Exception $ex) {
	echo "<div class='header'>Server OffLine</div>\n";
}

include 'footer.php';

?>
Return current item: Murmuradmin