I'm wanting to do something similar to this: Matching an IP to a CIDR mask in PHP 5?
Except, I want to store a list of disallowed IP/Masks in a MySQL table and check for a match.
Just like the example in the link, something like '10.2.0.0/16' would be a row in the table and then I want to check the IP address of the current user ($_SERVER['REMOTE_ADDR']) and check if it matches or not.
Thanks a lot :)
A few options on the tables - you can store the IP as a human-readable string (4 dotted bytes) or in it's native long number that cidr_match uses. Assuming we've stuck with human readable (to reuse
cidr_match
from the linked page)(You can find
cird_match
on the other post)