Forum / Guestbook




103.81.104.66 Sun 28 Apr 2019 at 1:23:58
SPAM

-
Blocking Ban BlackList Multiple IP Addresses With PHP
https://www.hashbangcode.com/article/blocking-multiple-ip-addresses-php


The code includes two ways to load the list of IP addresses. 
The first is by hard coding it into an array, 
and the second is by the use of a plain text file called "blocked_ips.txt". 

The format of this file is simply a list of IP addresses, 
with one address on each line. 
Through the use of the file() function this file is loaded as an array into of addresses.

you can also use something like this for giving access to a php page only for server ip or other desired ip
and block it for other ip
for example a info.php phpinfo.php counter.php log or setup.php admin.php etcetera
   if ip is not admin ip then exit
   if ($_SERVER['REMOTE_ADDR'] != "84.106.2.21"){echo"wrong_ip";die;}

put this on the top of php page

if ( !file_exists('blocked_ips.txt') ) {
 $deny_ips = array(
"192.162.165.22", 
"5.248.165.148", 
"153.92.0.14", 
"5.248.226.148", 
"123.56.49.19", 
"117.206.83.242", 
"118.172.11.196", 
"103.103.88.91", 
"188.213.49.138", 
"83.85.221.221", 
"5.188.45.160", 
"185.98.131.144", 
"195.114.18.131", 
"213.251.182.110", 
"153.92.0.8", 
"185.224.138.70", 
"103.14.97.80", 
"46.165.245.154", 
"46.119.4.212", 
"58.82.224.162", 
"103.81.104.66", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
""
 );
} else {
 $deny_ips = file('blocked_ips.txt');
}
// read user ip adress:
$ip = isset($_SERVER['REMOTE_ADDR']) ? trim($_SERVER['REMOTE_ADDR']) : '';
 
// search current IP in $deny_ips array
if ( (array_search($ip, $deny_ips))!== FALSE ) {
 // address is blocked:
 echo 'Your IP adress ('.$ip.') was blocked!';
 // header("location: http://www.projecthoneypot.org"); 
 exit;
}








Blocking Multiple IP Addresses With PHP
https://www.hashbangcode.com/article/blocking-multiple-ip-addresses-php


End of Message, Thanks For Viewing! ☺
Tip: if your watching on your phone or tablet ⁝ add / save to homescreen and you get a nice icon its Free!
Tip: on your computer or laptop do not forget to bookmark this page its Free!
BookMark ShortCut Keys press ctrl+d on your keyboard




-

-

Reply to this Message


Name
Subject
Message

, <code> <b> <i> <u> .






POLL / VOTE
Did you like this Page id=286 ?

NO:         YES:




   


Design a Bit like ForumOne 4.0 WayBack 1999 ©
Always Read the Small print?!



http://forum.luberth.com - - http://www.luberth.com/forum/

NO COOKIES !?

thanks for your support
Thank You!




Co2 FootPrint WebServer



                         My Cheap Chinese Friend Ali     
Copyright Luberth Dijkman 2018 ... 2019




GoodBye Galaxy!