I\'m trying to implement an IP banning system into my web app using MySQL, i know i can do it using .htaccess
but that\'s not neat to me.
Basically my curre
convert wildcards from 42.21.*.*
to 42.21.0.0
and back when writing or reading entries from database. For efficiency (low memory and disk footprint, performance) store it as an integer, use INET_NTOA and INET_ATON for conversion.
when you look up an IP address a.b.c.d:
SELECT ip FROM ip_blacklist WHERE ip=INET_ATON('a.b.c.d') or ip=INET_ATON('a.b.c.0') or ip=INET_ATON('a.b.0.0') or ip=INET_ATON('a.0.0.0')
Ok, the last match is probably silly.
Don't forget to add indexes.