<?php
// IP to ban
$banned_ip = "1.3.2.2";
$user_ip = $_SERVER['REMOTE_ADDR'];
if($user_ip == $banned_ip) {
echo "Access denied"; //Don't have to have that
header( 'Location: https://www.yoursite.com/banned.php' ) ;
}
$banned_ips = array("1.2.3.5", "1.2.3.4");
foreach($banned_ips as $ip_ban) {
if($user_ip == $ip_ban) {
echo "Access denied";//Don't have to have that
header( 'Location: https://www.yoursite.com/banned.php' ) ;
}
}
?>

<?php
//get ip or ip behind proxy
if($_SERVER["HTTP_X_FORWARDED_FOR"] != "")
{
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
$proxy = $_SERVER["REMOTE_ADDR"];
$host = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]);
}
else
{
$IP = $_SERVER["REMOTE_ADDR"];
$proxy = "No proxy detected";
$host = @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
}
//connect to database (mysql pref.)
//database connect here
$all_bans = mysql_query("SELECT * WHERE 'ban' = 'true'"); //get all ip bans
$banned = false; //initialize ban to false
//check through all the bans to determine if banned.
foreach( $banned_ip in $all_bans )
if($banned_ip == $IP)
$banned = true;
if($banned)
echo "Banned. gtfo.";
else
echo "Continue on! (Not Banned)";
?>

<?php
//get ip or ip behind proxy
if($_SERVER["HTTP_X_FORWARDED_FOR"] != "")
{
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
$proxy = $_SERVER["REMOTE_ADDR"];
$host = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]);
}
else
{
$IP = $_SERVER["REMOTE_ADDR"];
$proxy = "No proxy detected";
$host = @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
}
//connect to database (mysql pref.)
//database connect here
$all_bans = mysql_query("SELECT * WHERE 'ban' = 'true'"); //get all ip bans
$banned = false; //initialize ban to false
//check through all the bans to determine if banned.
foreach( $banned_ip in $all_bans )
if($banned_ip == $IP)
$banned = true;
if($banned)
echo "Banned. gtfo.";
else
echo "Continue on! (Not Banned)";
?>
Copyright © 2026, NextGenUpdate.
All Rights Reserved.