I'm trying to update my badbot/spider trap so that it will ignore the Google wap browser . I'm want to grab the remote IP and search an array to see it matches one on my list. The code below works for text strings (UA Strings) but not for IP addresses in x.x.x.x format. If anyone has some advice on how this should be performed I would appreciate it. As you can tell I can barely spell php . -jay . <?php $ua = strtolower($_SERVER['HTTP_USER_AGENT']); $ip = $_SERVER['REMOTE_ADDR']; function checkforWap(&$a_v){ foreach($a_v as $v){ if(strpos($ua,$v)!==false) return 1; } return 0; } $a_ip = array( '68.1.1.1', '67.10.15.12', '68.233.25.25', ); if (checkforWap($a_ip) ) { print "This IP " . $ip . " matched"; } else { print( "This IP " . $up . " did not match" ); } ?> Code (markup):
function check_ip($ip_list,$ip) { foreach($ip_list AS $key=>$value) { if($value == $ip) { $match = "1"; }; }; if($match == "1") { return "TRUE"; } else { return "FALSE"; } } $ip = $_SERVER['REMOTE_ADDR']; $ip_list = array( '68.1.1.1', '67.10.15.12', '68.233.25.25', ); if(check_ip($ip_list,$ip) == "TRUE") { echo "This IP: ".$ip." is in the list"; } else { echo "This IP: ".$ip." is NOT in the list"; }; Code (markup): ^^^ should work.