This is a small script can be used to redirect banned ip address users from your website, what it does exactly is calls the function “ipbanCheck” checks the database “ipban” for a matching IP Addresses of the current users IP Address then redirects them via javascript to = http://www.google.co.uk/search?q=GTFO
Database Setup:
1) log into phpMyAdmin, select the database you want the table built into.
2) select “SQL” from the tab menu, run the below.
SQL code:
CREATE TABLE ipban ( ID int(12) NOT NULL auto_increment, IP varchar(25) NOT NULL default '', PRIMARY KEY (ID) ) TYPE=MyISAM;
3) should output “executed successfully” etc. now select the table “ipban” then select “Insert” from tab menu now enter the IP Address your want to BAN in the field “IP”.
Usage:
Reason why i’m out putting the echo’s with outs like: “&conn=YES&IP=$ip” is for Flash loadVars integration. To use this function “ipbanCheck” just call it like so;
require_once 'ipban.php'; //file path to the file ipbanCheck(); //check function
Example
http://3l3373.com/dl/tutorials/ipBan/check.php – You should see an output of “&conn=YES&IP=93.97.40.201ban=NO&” unless You have been BANNED
PHP Code
<?php
/*
/////////////////////////////////
IP BAN - Kurt Grung - 3L3373.com
/////////////////////////////////
Database Setup:
1) log into phpMyAdmin, select the database you want the table built into.
2) select "SQL" from the tab menu, run the below SQL code:
CREATE TABLE ipban ( ID int(12) NOT NULL auto_increment, IP varchar(25) NOT NULL default '', PRIMARY KEY (ID) ) TYPE=MyISAM;
3) should output "executed successfully" etc. now select the table "ipban" then select "Insert" from tab menu now enter the IP Address your want to BAN in the field "IP".
Usage:
Reason why i'm out putting the echo's with outs like: "&conn=YES&IP=$ip" is for Flash loadVars integration.
To use this function "ipbanCheck" just call it like so;
require_once 'ipban.php'; //file path to the file
ipbanCheck();
*/
function ipbanCheck(){
//config
$ip = $_SERVER['REMOTE_ADDR'];
$redirectURL = "http://www.google.co.uk/search?q=GTFO";
//db.conn
$dbHost = "";
$dbUser = "";
$dbPass = "";
$dbName = "";
//connection sucsessful?
$link = mysql_connect($dbHost, $dbUser, $dbPass, $dbName);
if(!$link){
die('&conn=NO&');
die('Could not connect: '.mysql_error());
}
echo '&conn=YES&IP='.$ip;
//db.conn
mysql_connect($dbHost, $dbUser, $dbPass) or die(mysql_error());
mysql_select_db($dbName) or die(mysql_error());
$s=$_SERVER["REMOTE_ADDR"];
//draws IP address of visitor
$ipbancheck="SELECT * from ipban where IP='$s'";
$ipbancheck2=mysql_query($ipbancheck);
while($ipbancheck3=mysql_fetch_array($ipbancheck2)){
$IPBANNED=$ipbancheck3[IP];
}
//above lines check to see if user Ip is in banned IPs
if ($IPBANNED){
//redirect user..
echo "<script> setTimeout(location.href=\"$redirectURL\", 1); </script>";
}else{
echo 'ban=NO&';
//put content you want unbanned users to see here
}
}
?>














