function makeMask($ip) { // remember to escape the . so PHP doesn't think it's a concatenation $ip_array = explode(".", $ip); $ip_mask = "$ip_array[0].$ip_array[1].$ip_array[2]"; return $ip_mask; }
?>
然后我们把循环中的if替换成
for ($counter=0;$counter if (makeMask($REMOTE_ADDR) == makeMask($banned_array[$counter])) { print("". "You have been banned from this chat"); exit; } }