Jump to content

block ip address


aaront1

Recommended Posts

Hi I want to write a script to block some ip address on my index.php<?php$deny = array("111.111.111", "222.222.222", "333.333.333");if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) { exit();} ?>i have tried the script above.it only block when i type domain.com as my urlbut it will not block when i type in www.domain.comanyone know why? and how can i rewrite the script to block www.domain.com too?

Link to comment
Share on other sites

:) Lookup .htaccess denyIt's easier, especially if you want to block users from the whole directory.
well, i want to be able to add a if statement,likewww.domain.com/?allow=1 this will be okay even if the ip is blocked.www.domain.comthis will not okay, since they didn't type in the allow variable.<?php$deny = array("111.111.111", "222.222.222", "333.333.333");if (in_array ($_SERVER['REMOTE_ADDR'], $deny) && $allow == NULL) {exit();} ?>
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...