Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: ban IP adress

  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ban IP adress

    hello all,,, how can i set a simple PHP code that says


    get ip
    if $ip = "00.00.00.00"//the list of banned users
    header("Location: banned.shtml");
    else
    //just carry on



    you get the point sorry my PHP is bad lol,,

  • #2
    Regular Coder
    Join Date
    Apr 2004
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so do i just use this code

    PHP Code:
    <? 

    $ip 
    $_SERVER['REMOTE_ADDR']; 

    $bannedips = array("IP HERE","IP HERE","IP HERE"); 

    if (
    in_array($ip$bannedips)) { 

       
    // disallow 

    } else { 

       
    // allow 



    ?>
    ????????????

  • #4
    Regular Coder
    Join Date
    Apr 2004
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes that should work.

  • #5
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That'll work, but it's not going to save you as much bandwidth as doing it in .htaccess....

    Code:
    <Limit GET>
    order allow,deny
    allow from all
    deny from 000.000.0.01
    deny from badserver.com
    </Limit>

    I take no responsibility for the above nonsense.


    Left Justified

  • #6
    Regular Coder
    Join Date
    May 2005
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    allright its good thanx all for your help


  •  

    Posting Permissions

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