What this script does
I wrote this quick script to ban IP's. It is quite straight forward to use you can, block, unblock user's IP address. If user is banned from accessing the site script will send him to a page notifying them that their IP has been blocked.
How Admin panel works:
This script does not user any admin table to check if user logging in is admin. It first checks by IP, if IP specified in ip_ban.php file matches client IP it will allow access to the page. Note: Access to just page. Then it will ask you for two keys, Key 1, and Key 2, these are the keys that have also been set in ip_ban.php file. You must change these keys to whatever but unique keys, so whenever you try logging in, it will try matching the keys you enter to the ones set in script.
Change IP address(allowed_ip) to your IP address.
$allowed_ip = "127.0.0.1";
if($_SERVER["REMOTE_ADDR"] !== $allowed_ip){
header("location: index.php");
}
Keys to change
/*********************************************/
//CHANGE THE KEYS!
/*********************************************/
$default_key_1 = "1stkey";
$default_key_2 = "2ndkey";
/*********************************************/
/*********************************************/
How to use
It is pretty simple to use this script, all you need to do is go to phpmyadmin and create a database named whatever you wish, and then import the ip_ban_table.sql file I have provided. Then just connect to database by changing the information in connection_to_db.php file and you are good to go.
Additional info
- To open admin panel go to ip_ban.php
- index.php is our default page, if your site uses different page, or have more than one page, all you need to do is post this code at the top of those pages.
<?PHP
include("is_ip_banned.php");
?>
Screenies
Banning unbanning panel
Admin login
Download
https://dl.dropboxusercontent.com/u/28490184/webdevtown/IP%20ban%20script.rar


No comments:
Post a Comment