for ($counter=0;$counter< sizeof($banned_array);$counter++) {
if ($banned_array[$counter] == $REMOTE_ADDR) {
print("< font color="red" face="arial" align="center" >".
"You have been banned from this chat< /font >");
exit;
}
}
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替換成
< ?php
for ($counter=0;$counter< sizeof($banned_array);$counter++) {
if (makeMask($REMOTE_ADDR) == makeMask($banned_array[$counter])) {
print("< font color="red" face="arial" align="center" >".
"You have been banned from this chat< /font >");
exit;
}
}