Jump to content

[SOLVED] Help with IP Ban (simple)


env3rt

Recommended Posts

ips.txt

66.66.66.66
12.34.56.78
127.0.0.2
127.0.0.0
98.55.26.1
127.0.0.1

 

ips.php

<?php
$file = file_get_contents("ips.txt");
$ip = $_SERVER['REMOTE_ADDR'];

$e = explode("\n",$file);

$ipa = array();

foreach($e AS $f){
$ipa[] = $f;
}

if(count($ipa) > 0){
if(in_array($ip,$ipa)){
echo "Your IP: " . $ip . " has been baniated!";
}else {
echo "NOT BANIATED!";
}
}else {
echo "NO IPS BANIATED!";
}
?>

 

Tested on localhost.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.