[PHP] Simple IP Block System 01-28-2013, 05:22 PM
#1
PHP Code:
<html>
<head>
<title>IP Block System By Exo94</title>
</head>
<body>
<?php
///////////////////////////
//Simple IP Block System //
// Coded By Exo94 //
// Hackcommunity.com //
// http://www.gigadev.tk //
///////////////////////////
//Advance version to come//
// SOON! //
///////////////////////////
// List of IPs that you don't want to access your website
$ip_list = array('Add your ip here to test');
//Get hostname of the visiting user
$user_ip = $_SERVER['REMOTE_HOST'];
//Resolve Hostname of the user
$res_host = gethostbyname($user_ip);
//Store all the IPs in the array in a Variable
foreach ($ip_list as $black_list) {
//If the IP of the visiting guest is a match with the IP List (Array), He'll be redirected to another website.
//Replace the URL with your redirect location
if($res_host == $black_list) {
//Code to redirect user to another website and not letting him access your site if his IP matches the one in the Array
header('Location: http://www.your_redirect_page.com');
} else {
//If guest IP is not a match with the listed one, He'll be led to the index
//page of your website, Either it's a login form or anything else that you have entered the url of.
//Replace the URL with the one where you want to redirect the user
header('Location: http://www.gigadev.tk')
}
}
?>
</body>
</html>
For now this is it but I'll be working on a more advance one which will:
1) Have a Login Form
2) IP Logger
3) Proxy Detector
4) Blocks user if enters wrong user and pass for the first time
5) Detects Country IP
6) Will append IP's from a text file to the array making it user friendly and easy to manage block list
7) Might have a Admin Panel if I cover the major topics of PHP in time
and more they'll come into me mind![Smile Smile](https://sinister.ly/images/smilies/set/smile.png)
Have fun!
[/code]
1) Have a Login Form
2) IP Logger
3) Proxy Detector
4) Blocks user if enters wrong user and pass for the first time
5) Detects Country IP
6) Will append IP's from a text file to the array making it user friendly and easy to manage block list
7) Might have a Admin Panel if I cover the major topics of PHP in time
and more they'll come into me mind
![Smile Smile](https://sinister.ly/images/smilies/set/smile.png)
Have fun!