IP Geo Targeting Function

Status
Not open for further replies.


LOL! I'd already solved the problem with:

function ipIsInNet( $ip, $net ) {
// note that $net is IP-range in cidr format
if( preg_match( '/^([^\/]+)\/([^\/]+)$/', $net, $ms )) {
$mask = 0xFFFFFFFF << ( 32 - $ms[2] );
return ( ip2long( $ip ) & $mask ) == ( ip2long( $ms[1] ) & $mask );
}

return FALSE;
}

But I'll give you $50 for your effort, PM me your PayPal address.
 
I figured you probably had figured it out since so much time had passed since you made the thread. No worries on the $, I was just kidding around... I wouldn't have posted the source otherwise. :) Just passing on good karma.
 
I'll keep a note of you for any future scripting :)

I figured you probably had figured it out since so much time had passed since you made the thread. No worries on the $, I was just kidding around... I wouldn't have posted the source otherwise. :) Just passing on good karma.
 
Status
Not open for further replies.