Jump to content
xisto Community
Sign in to follow this  
iGuest

IP Blocking with PHP code

Recommended Posts

Is there any way known to anyone about blocking IP addresses for a range that Admin can define in order to protect the site from being attaced by someone?Thanks,Eyal.

Share this post


Link to post
Share on other sites

yeah... erm i am just about to make a script to do it... though it will integrate into my site so i wont be able to give it to you, what i can do is point you in the right direction (as far as i know)...

first, the users ip can be found by:

<?$ip_address = getenv('REMOTE_ADDR');?>
you should set the value ranges for each of the 4 numbers to allow.

Im goign to store these as a minimum row and a maximum row in a table.

Now...

When the page is loaded, compare the $ip_address of the current user by splitting it up to get each of the 4 numbers...

if all of the 4 numbers fit within the range assigned to all of the 4 numbers... show the content.

If not

print user is banned.

Share this post


Link to post
Share on other sites

Thanks for the tip, However I'm afraid I am still new with PHP...I understand you security priorities and respect that, but is there another way without programing a certain code like a module for instance...Why people dosen't interest in such option to protect their site... I guess they wake up too late after someone does hack and destroy thier site...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.