I'm trying to create a banlist based on a .txt file which has the IP's stored (one per line).
Now I'm comparing the current users IP with the .txt file content like this:
$file = file_get_contents( "text_file.txt" );
if( preg_match( "/$ip/", $file ) ) {
// block
}
My problem is that non-exact matches also trigger the block, for example 127.0.0.12 is in the .txt, my IP is 127.0.0.1 and I'm getting blocked.
How can I make it an exact match only ?
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.