aaront1 Posted November 21, 2008 Share Posted November 21, 2008 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 More sharing options...
jeffman Posted November 22, 2008 Share Posted November 22, 2008 Lookup .htaccess denyIt's easier, especially if you want to block users from the whole directory. Link to comment Share on other sites More sharing options...
aaront1 Posted November 22, 2008 Author Share Posted November 22, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.