Results 1 to 3 of 3

Thread: BAN ip

  1. #1
    Senior Member wap-ruler's Avatar
    Join Date
    Nov 2010
    Location
    India
    Posts
    145
    Thanks
    16
    Thanked 100 Times in 38 Posts
    Rep Power
    3

    Default

    very besic script to block a ip to ur site
    Code:
    1. <?php - Starts the php tag. Lets the browser know what language you are using.
    2. $ip = getenv('REMOTE_ADDR'); - Gets the users IP address
    3. $blocked = "xx.xx.xx.xx"; - Tells the browser that the "xx.xx.xx.xx" IP is blocked/banned
    4. if (ereg($blocked,$ip)) - If the blocked/banned IP is the same as the users IP, the following echo will be displayed.
    5. { - Starts a bracket
    6. echo "You Have Been Banned"; - Echos the "You Have Been Banned" line onto the page.
    7. exit(); - Exit so no more content is ouput
    8. } - Ends a bracket
    9. ?> - Ends the php tag

    use thanks plz

    Added after 4 minutes:

    it look likes such..
    Code:
    <?php
    $ip = getenv('REMOTE_ADDR');
    $blocked = "xx.xx.xx.xx"; //chnge d ip address u want to block
    if (ereg($blocked,$ip))
    {
    echo "You Have Been Banned";
    exit();
    ?>
    Last edited by wap-ruler; 08-11-10 at 20:44.
    ImPoSsIbLe iS nOthInG aS ImPoSsible ItSelF SaYs "I M POSSIBLE"

  2. The Following User Says Thank You to wap-ruler For This Useful Post:

    GumSlone (08-11-10)

  3. #2
    Administrator GumSlone's Avatar
    Join Date
    Mar 2005
    Location
    Mars, GumCity
    Posts
    1,495
    Thanks
    125
    Thanked 573 Times in 201 Posts
    Blog Entries
    2
    Rep Power
    10

    Default

    I use this one:
    PHP Code:
    function is_banned()
    {
    $banned_ip = array();
    $banned_ip[] = '117.201.35.*';
    $banned_ip[] = '114.31.129.*';
    foreach(
    $banned_ip as $banned)
    {
    $blacked=str_replace('*'''$banned);
    if (
    stristr($_SERVER['REMOTE_ADDR'],$blacked))
    {
    return 
    true;
    }
    }
    return 
    false;
    }

    if (
    is_banned()) exit(); 
    Advertise your mobile site for FREE with [Only registered and activated users can see links. Click Here To Register...]

    [Only registered and activated users can see links. Click Here To Register...]


  4. The Following User Says Thank You to GumSlone For This Useful Post:

    wap-ruler (08-11-10)

  5. #3
    Senior Member wap-ruler's Avatar
    Join Date
    Nov 2010
    Location
    India
    Posts
    145
    Thanks
    16
    Thanked 100 Times in 38 Posts
    Rep Power
    3

    Default

    nice share br0..!!
    ImPoSsIbLe iS nOthInG aS ImPoSsible ItSelF SaYs "I M POSSIBLE"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19