All pastes #372056 Raw Edit

Stuff

public text v1 · immutable
#372056 ·published 2007-02-25 20:44 UTC
rendered paste body
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
     <title>bans bad IPs</title>
  </head>
  <body>
    <?php

    if (getenv('HTTP_CLIENT_IP')) $ip = getenv('HTTP_CLIENT_IP'); 
    else if(getenv('HTTP_X_FORWARDED_FOR')) $ip = getenv('HTTP_X_FORWARDED_FOR'); 
    else if(getenv('remote_addr')) $ip = $_SERVER['remote_addr']; 
    else $ip = 'UNKNOWN';

  /*  $ban_file = fopen("ban.txt", "r");
    $banned_list = file($ban_file); */
	
	$badips = file('ban.txt');
	
	
	echo "your ip is $ip <br /><br />list of bad IPs:<br /><ul>";
	
	foreach ($badips as $ipentry) {	//print list of bad IPs
	echo "<li>$ipentry <br />";
	}
	
	echo "</ul>";
	
    if (in_array($ip, $badips))		//check for bad ip 1
    {
            echo "Bad IP detected.";
            exit();
    }
    else
    echo "Bad IP not detected.";

    ?>
  </body>
</html>