I do not know if the question is well formulated, but with the code below, I get the user's IP and save it in a .txt file. and when the user tries to enter again, he reads the .txt file and sends a message saying that his IP has already been used. what I want to do is that if the saved IP is for example: 192.168.1.10, and the user's ip is 192.168.1.15. tell you the same as if the ip was saved, but if your IP is for example: 192.168.1.21. then if you save it and allow you to visit the link. that is to say that the last rank of numbers of the ip, must have a difference of at least 10.
$ip = $_SERVER['REMOTE_ADDR']; $file = file_get_contents( "ips.txt" ); $archivo = "ips.txt"; $proceso = fopen($archivo, "a"); $datos = "".$ip."\n"; if( preg_match( "/$ip/", $file ) ) { echo "Esta IP ha sido usada recientemente, cambia la IP."; } else{ header ('Location: https://www.ejemplo.com/?view=ad1'); fwrite($proceso, $datos); fclose($proceso); }