Lid |
|
Ja. Ik zal even de volledige code geven.
<!DOCTYPE html>
<?php
// Connecting to database
require("../connect.php");
require("../config.php");
$admin_ip = $_SERVER['REMOTE_ADDR'];
// Starting session, this piece of code should be at every page with restricted access
session_start();
// Checking if session exists and user has been active within last 15 minutes
if(!isset($_SESSION) || $_SESSION['lastActive'] < time()-60*15) {
// User has not, or session doesn't exist
unset($_SESSION);
session_destroy();
header("Location: login.php");
exit;
} else {
// User has been and session exists
$_SESSION['lastActive'] = time(); // Every click updates last active time
}
?>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../style/main.css" />
<link rel="stylesheet" type="text/css" href="../style/admin.css" />
<link rel="shortcut icon" href="../favicon.ico" />
<title><?php echo $config_title." | Admin"; ?></title>
</head>
<body>
<h2>Blacklist</h2>
<?php
if( isset($_POST['admin_blc_subm'])) {
// Simplifying variables for further use
$admin_blc_ip = $_POST['admin_blc_ip'];
$admin_blc_cat = $_POST['admin_blc_cat'];
// Checking if everything has been filled in
if(!empty($admin_blc_ip)) {
if(!$admin_ip == $admin_blc_ip) {
if( $admin_blc_cat == "add") {
mysql_query("INSERT INTO list (ip) VALUES ('".$admin_blc_ip."')");
}
elseif( $admin_blc_cat == "remove") {
mysql_query("DELETE FROM list WHERE ip='".$admin_blc_ip."'");
} else {
echo "<span class='fail'>Not everything has been filled in</span>";
}
// Win!
echo "<span class='win'>The blacklist has succesfully been edited</span><br />";
echo "<a href='index.php'>Click here to return to the Admin Panel</a>";
} else {
// Fail!
echo "<span class='fail'>You can not (un)ban your own IP adress</span><br />
<a href='javascript:history.go(-1)'>Click here to return to the previous page</a><br /><br />".$admin_ip." | ".$admin_blc_ip;
}
} else {
echo "<span class='fail'>Not everything has been filled in</span><br />
<a href='javascript:history.go(-1)'>Click here to return to the previous page</a>";
}
} else {
?>
<form action="blc.php" method="POST">
<span class="bold">IP-adress</span><br />
<input type="text" name="admin_blc_ip" /><br />
Add <input type="radio" name="admin_blc_cat" value="add" /> | <input type="radio" name="admin_blc_cat" value="remove" /> Remove<br /><br />
<input type="submit" name="admin_blc_subm" value="Submit" />
</form>
<?php
}
?>
</body>
</html>
<!DOCTYPE html> <?php // Connecting to database require("../connect.php"); require("../config.php"); $admin_ip = $_SERVER['REMOTE_ADDR']; // Starting session, this piece of code should be at every page with restricted access // Checking if session exists and user has been active within last 15 minutes if(!isset($_SESSION) || $_SESSION['lastActive'] < time()-60*15) { // User has not, or session doesn't exist header("Location: login.php"); } else { // User has been and session exists $_SESSION['lastActive'] = time(); // Every click updates last active time } ?> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="../style/main.css" /> <link rel="stylesheet" type="text/css" href="../style/admin.css" /> <link rel="shortcut icon" href="../favicon.ico" /> <title ><?php echo $config_title." | Admin"; ? ></title > </head> <body> <h2>Blacklist</h2> <?php if( isset($_POST['admin_blc_subm'])) { // Simplifying variables for further use $admin_blc_ip = $_POST['admin_blc_ip']; $admin_blc_cat = $_POST['admin_blc_cat']; // Checking if everything has been filled in if(!empty($admin_blc_ip)) { if(!$admin_ip == $admin_blc_ip) { if( $admin_blc_cat == "add") { mysql_query("INSERT INTO list (ip) VALUES ('".$admin_blc_ip."')"); } elseif( $admin_blc_cat == "remove") { mysql_query("DELETE FROM list WHERE ip='".$admin_blc_ip."'"); } else { echo "<span class='fail'>Not everything has been filled in</span>"; } // Win! echo "<span class='win'>The blacklist has succesfully been edited</span><br />"; echo "<a href='index.php'>Click here to return to the Admin Panel</a>"; } else { // Fail! echo "<span class='fail'>You can not (un)ban your own IP adress</span><br /> <a href='javascript:history.go(-1)'>Click here to return to the previous page</a><br /><br />".$admin_ip." | ".$admin_blc_ip; } } else { echo "<span class='fail'>Not everything has been filled in</span><br /> <a href='javascript:history.go(-1)'>Click here to return to the previous page</a>"; } } else { ?> <form action="blc.php" method="POST"> <span class="bold">IP-adress</span><br /> <input type="text" name="admin_blc_ip" /><br /> Add <input type="radio" name="admin_blc_cat" value="add" /> | <input type="radio" name="admin_blc_cat" value="remove" /> Remove<br /><br /> <input type="submit" name="admin_blc_subm" value="Submit" /> </form> <?php } ?> </body> </html>
|