|
Answer» I found another POST on this forum that was very useful about banning IP in a PHP file. I will attach the code below. I do have a question about this code. I am using IP Ranges in the ban.txt file. Sometimes when doing this there is one IP within that range that is a user that does not need to be banned. How can I add another text file of set it up in the PHP file to allowed IPs and have it override the ban.txt file? Is this POSSIBLE?
Code: [Select]<?php $userIp = $_SERVER['REMOTE_ADDR']; $ips = file('/ban.txt'); $isBanned = false;
foreach($ips as $ip) { $split = explode(',', $ip);
if($split[0] == $userIp) $isBanned = true; BREAK; }
if(!$isBanned) { echo "It seems you have been banned from viewing this website."; echo " "; echo "If you think you have been banned in ERROR please contact me."; exit(); } ?>
|