php - Check ipaddress with ip2long fails -
hi attempting check users ipaddress can come 2 specific ranges. convert users ipaddress using ip2long, check see if in range failing. wondered if can spot rookie mistakes quite new php. in advance:
$high_ip = ip2long('87.228.97.128'); $low_ip = ip2long('83.229.97.165'); $second_high_ip = ip2long('16.254.116.1'); $second_low_ip = ip2long('16.254.116.128'); $userip = ip2long($_server['remote_addr']); if($userip <= $high_ip && $low_ip <= $userip ){ //do }else if($userip <= $second_high_ip && $second_low_ip <= $userip ) { // }else { // echo "invalid ip"; }
-- edit -- when hitting page ipaddress within range fails if check though ipaddress wrong.
thanks had made rookie error :-0
quite embarrassing lol
i had if statement incorrectly.
should have been :
($userip <= $second_high_ip && $second_low_ip >= $userip )
Comments
Post a Comment