i'm getting this error when for this php script , this script is to block multi ip address Deprecated: Function eregi() is deprecated in C:\xampp\htdocs\clients\block.php on line 11 <?php // array's of banned IP addresses $bannedIP = array("^22.22.*.*","^11.11.*.*");if(in_array($_SERVER['REMOTE_ADDR'],$bannedIP)){// this is for exact matches of IP address in array header('HTTP/1.0 404 Not Found');exit();}else{// this is for wild card matchesforeach($bannedIP as $ip){if(eregi($ip,$_SERVER['REMOTE_ADDR'])){ header('HTTP/1.0 404 Not Found');exit();}}} ?> how to fix that ?
i did what you say and got this output <?php // array's of banned IP addresses $bannedIP = array("^22.22.*.*","^11.11.*.*");if(in_array($_SERVER['REMOTE_ADDR'],$bannedIP)){// this is for exact matches of IP address in array header('HTTP/1.0 404 Not Found');exit();}else{// this is for wild card matchesforeach($bannedIP as $ip){if(preg_match($ip,$_SERVER['REMOTE_ADDR'])){ header('HTTP/1.0 404 Not Found');exit();}}} ?> Warning: preg_match(): No ending delimiter '^' found in C:\xampp\htdocs\clients\block.php on line 11
Sorry, I forgot the delimiter, try this $bannedIP = array("^22.22.*.*","^11.11.*.*");if(in_array($_SERVER['REMOTE_ADDR'],$bannedIP)){// this is for exact matches of IP address in array header('HTTP/1.0 404 Not Found');exit();}else{// this is for wild card matches foreach($bannedIP as $ip){if(preg_match('/' . $ip . '/',$_SERVER['REMOTE_ADDR'])){ header('HTTP/1.0 404 Not Found');exit();}}} Code (markup):
hmm srry to say that it's not worked on the second server Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in C:\AppServ\www\clients\block.php on line 11