<?php
include "common.php";
head();
?>
                <!--/span-->
                <div class="span9" id="content">

                    <div class="row-fluid">
                        <!-- block -->
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">Ban Details</div>
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12">
<?php
$id = (int) $_GET['id'];
if (empty($id)) {
    echo '<meta http-equiv="refresh" content="0; url=bans.php">';
}
$sql = mysql_query("SELECT * FROM `bans` WHERE id='$id'");
if (mysql_num_rows($sql) == 0) {
    echo 'No such ban<meta http-equiv="refresh" content="3; url=bans.php">';
} else {
    $row = mysql_fetch_assoc($sql);
?>
<form action="" method="post">
<p>
	<label>IP Address</label>
	<input name="ip" type="text" value="<?php
    echo $row['ip'];
?>">
</p>
<p>
	<label>Date: <?php
    echo $row['date'];
?></label>
</p>
<p>
	<label>Banned by: <?php
    echo $row['bannedby'];
?></label>
</p>
<p>
	<label>Reason</label>
	<input name="reason" type="text" value="<?php
    echo $row['reason'];
?>">
</p>
<p>
	<label>Redirecting to another page or site: <?php
    echo $row['redirect'];
?></label><br />
    <select name="redirect">
        <option value="No">No</option>
        <option value="Yes">Yes</option>
    </select>
</p>
<p>
	<label>Redirect URL</label>
	<input name="url" type="text" value="<?php
    echo $row['url'];
?>">
</p>
<br /><input type="submit" class="btn btn-primary" name="submit" value="Update" /> <a href="bans.php?delete-id=<?php
    echo $row['id'];
?>" class="btn btn-danger">Unban</a><br />
</form>
<?php
    if ($_POST['submit']) {
        $ip       = addslashes(htmlspecialchars($_POST['ip']));
        $reason   = addslashes(htmlspecialchars($_POST['reason']));
        $redirect = $_POST['redirect'];
        $url      = addslashes(htmlspecialchars($_POST['url']));
        $update   = "UPDATE bans SET ip='$ip', reason='$reason', redirect='$redirect', url='$url' WHERE id='$id'";
        $sql      = mysql_query($update);
        echo '
<br /><center>The ban was successfuly updated</center><br />
<meta http-equiv="refresh" content="3;url=bans.php">';
    }
}
?>
								<hr />
								</div>
                            </div>
                        </div>
                        <!-- /block -->
                    </div>
   
<?php
footer();
?>