PHPBuilder - Ip Ban



RSS Twitter
Snippets Html

Ip Ban

by: Brent Wagner
|
January 22, 2007

Version: 1

Type: Full Script

Category: HTML

License: Other

Description: IP BAN



     
    <?php
    /*
    * Banning Script
    * Written By Marc 'InSp3KtaH' Giroux
    */
    error_reporting(2048);
    // Change to your banned page
    $banned_page = 'banned.html';
    // This script requires that you pass it an array called 'banned_array' (you can create your array from mysql of from a file)
    // You must insert this script or include/require before any html or text since it's using the header function
    $banned_array = array('videotron.ca', '147.0');
    if (! headers_sent()) {
    	if (is_array($banned_array)) {
    		$ip = $_SERVER['REMOTE_ADDR'];
    		$host = gethostbyaddr($ip);
    		
    		// Process array
    		foreach ($banned_array as $entry) {
    			if ((stristr($host, $entry) !== false) or (stristr($ip, $entry))) {
    				header("location: $banned_page");
    			} else {
    				echo 'welcome to the page';
    				return 1;
    			}
    		}
    	} else {
    		echo 'the data passed to the ban script is not an array.';
    	}
    } else {
    	echo 'The ban script was included after the headers were sent.';
    }
    ?>
		

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Brent Wagner

Comment:



Comment:

(Maximum characters: 1200). You have characters left.