View Full Version : IP Blocking
top99gaming
03-28-2007, 02:50 PM
there is this network I would like to block from my site as people from this same network, well abuse my site by making it look stupid by registering with names that could offend people and by giving false details
are there any scripts I could use that would do this for me
UnlimitedMB
03-28-2007, 03:40 PM
Usually your forum/CMS will have this built in.
This code will block any IP starting with 123.456
function block_ip($ip){
if (substr($_SERVER['REMOTE_ADDR'], 0, strlen($ip)) == $ip){
return true;
} else {
return false;
}
}
// check if ip is blocked
if (block_ip("123.456.")){
echo 'go away';
exit;
}
top99gaming
03-28-2007, 04:37 PM
ok that helps, but its not a forum but an arcade script, would the code work if I just put it on the index page and a few other, also would it still work if I changed the IP address to the one I want to block
Tyler
03-28-2007, 05:48 PM
Yes, try it.
top99gaming
03-28-2007, 07:50 PM
thanks I think it works, I just need to get the IP address tomorrow
top99gaming
03-29-2007, 11:06 AM
thanks it that worked, how would I add more IP addreses, wouldI just put them in another set of bracket like this
function block_ip($ip){
if (substr($_SERVER['REMOTE_ADDR'], 0, strlen($ip)) == $ip){
return true;
} else {
return false;
}
}
// check if ip is blocked
if (block_ip("123.456.")(123.457)){
echo 'go away';
exit;
}
UnlimitedMB
03-29-2007, 01:58 PM
no you cant use php like that.
You use
if (block_ip("123.456.") or block_ip("123.457.")){
echo 'go away';
exit;
}
top99gaming
03-29-2007, 02:49 PM
oh ok thanks, I don't know much about php
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.