Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 19th, 2005, 7:11 PM   #1
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
IP Blocking method (finished, source included)

block.php :
<?php
    $list = array(
                   "123.*.*.*",
                   "124.51.12.*"
                 );

    function checkBlockList() {
        global $list;

        foreach($list as $ip) {
            $ip = split($ip, ".");
            $rmip = split($_SERVER['REMOTE_ADDR'], ".");
            $count = 0;

            if(count($ip) != 4)
                die("Invald IP in \$list array. Check \"{$_SERVER['PHP_SELF']}\" file.");

            if(count($rmip) != 4)
                die("Invalid remote IP address??!?!");

            for($i=0;$i<4;$i++)
                if(trim($ip[$i]) != "*" && trim($ip[$i]) != trim($rmip[$i]))
                    break;

            if($i == 4)
                die("Your IP is invalid. You're blocked, must suck.");
        }
    }
?>

index.php (implementation example) :
<?php
    include("block.php");
    checkBlockList();
    echo "You aren't on the block list, welcome!";
?>
__________________

tempest is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:19 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC