Re: ban ip addresses



<snip>
Here is the function I use to ban IP:

function isnotallowediprange($ip){
$ban_range_low = ip2long('163.0.0.0');
$ban_range_up = ip2long('172.192.255.255');
$iplong = ip2long($ip);
if (($iplong > $ban_range_low) and ($iplong < $ban_range_up)){
return true;
} else {
return false;
}
}

If you check, you will see that those numbers are negative (i.e., the highest order bit is set). Better use strings and pattern matching.

Best regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
.



Relevant Pages

  • Re: spot the error
    ... You might be looking at the wrong one, especially if the above script is also included. ... Willem Bogaerts ... Application smith ...
    (comp.lang.php)
  • Re: U.S. sees democracy coming in post-Castro Cuba
    ... Cuba already leads the region in health care and education. ... Already the best in Latin America, so the US is going to ... > of another state," Smith said. ...
    (soc.culture.cuba)
  • Re: SIs Five Worst College Coaches
    ... appears in over his head in the Big Ten, ... if that was true why would Smith be in this list? ... MSU is performing at expected levels. ...
    (rec.sport.football.college)
  • Re: Odd doings in California
    ... it may not be as complex as regular payroll. ... Consider, Mr Smith, that persons earning only or greater are ... While our understandings ...
    (comp.lang.cobol)
  • Re: Revisiting an Old Prejudice: READ INTO/WRITE FROM
    ... Rick Smith wrote: ... >of that which can be chalked up to sloppiness, ... >storage being the NOMINAL KEY for the indexed file. ...
    (comp.lang.cobol)