Advertisement
Guest User

PHP ban ips if in file

a guest
Jan 25th, 2013
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2. $lines = file('ips.txt');
  3. $myproto = 'http';
  4. $mywebsiteurl = 'example';
  5. $endingstring = 'com';
  6. // you can use the 3 variables above(myproto, websiteurl, endingstring) in the exit message if you want. you can do {$myproto}://{$mywebsiteurl}.{$endingstring}
  7. // Loop through our array, show HTML source as HTML source; and line numbers too.
  8. foreach ($lines as $line_num => $line) {
  9.     $visitorIP = $_SERVER['REMOTE_ADDR'];
  10.     //DEV TEST: $visitorIP = '90.90.90.90';
  11.     if($line==$visitorIP&&!empty($visitorIP)) {exit('IP Address is blacklisted/banned');
  12.     }
  13. }
  14. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement