How to IP ban people from your website

Results 1 to 22 of 22
  1. #1
    Enthusiast Psycho666 is offline
    MemberRank
    Sep 2004 Join Date
    Santa Rosa, CALocation
    29Posts

    How to IP ban people from your website

    Got a Flamer on your site or forums? Ban'em!
    I know alot of you guys already know how to do this but I thought I'd show everyone how to.
    Copy and paste one of the two codes below into a new document and call it ipbanned.php
    1.Single IP Ban
    PHP Code:
    $bad_ip 'xxx.xxx.xxx.xxx'// the "x's" are where you put the ip of who you want to ban.
    $visitor_ip $_SERVER['REMOTE_ADDR']; // the ip address of the visitor
    if($visitor_ip == $bad_ip)
    {
    die(
    "Tsk, tsk, tsk you got banned!!");
    ** 
    ?> 
    Is there more than 1 person you just hate. Well here is the script to ban multiple people.
    PHP Code:
    $ban_ips "xxx.xxx.xxx.1,xxx.xxx.xxx.2"); First ip goes before the commasecond goes after the comma.
    $visitor_ip $_SERVER['REMOTE_ADDR'];
    $ip_list explode(","$ban_ips);
    foreach(
    $ip_list as $ip)
    {
    if(
    $visitor_ip == $ip)
    {
    die(
    "Tsk, tsk, tsk you got banned!");
    **
    **
    ?> 
    Now, if you just want to ban them from one page of your site, put that code in there. But if u just hate them, and you dont want them to access anything, then save the above code as ipbanned.php and use the include php code to easily put it on every site.
    Now the person cant acsess the site anymore. Have Fun.
    (the "**"'s are end brackets)


  2. #2
    Apprentice OnacHbIu is offline
    MemberRank
    May 2005 Join Date
    12Posts

    :)

    nice :smilie3:

  3. #3
    Valued Member nevienc is offline
    MemberRank
    Apr 2005 Join Date
    104Posts
    .htaccess
    Code:
    Order Allow,Deny
    Allow from all
    Deny from 80.228.146.251
    Deny from 80.224.143.190
    Deny from 61.152.158.101

  4. #4
    Account Upgraded | Title Enabled! elche27 is offline
    MemberRank
    Dec 2004 Join Date
    TucumanLocation
    302Posts
    Ok this a great guide to those who havent got dynamic ip bt almost of the ppl from south america have it so....ull banned it just from one day...some solution for this?

  5. #5
    Omega FragFrog is offline
    MemberRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,630Posts
    Quote Originally Posted by nevienc
    .htaccess
    Code:
    Order Allow,Deny
    Allow from all
    Deny from 80.228.146.251
    Deny from 80.224.143.190
    Deny from 61.152.158.101
    And this folks, is what should be in the start post right now.

    Don't go fucking about with php code, Apache has a build in module for banning IP's which uses the .htacces files which is faster and more reliable (what if they open a non-php file? they could still hog your bandwith by automatically redownload a large picture for instance. Might even SQL inject you still - there was an important security bug in my latest package that is perfectly solved by this, but not by the startpost's "sollution").

    On a sidenote: I recommand setting deny permissions directly into your apache config files, or modify the .htacces file located in your webroot. Otherwise other folders still might not be protected. Also, the last article I read about this did in fact state that its better to set acces permissions directly in your apache config files.

    Last but not least: like elche27 already said, if you get hacked banning the people responsable really isn't the answer. Better security is. Though I personally favor banning all polish IP's, I'm continiously seeing hack attempts from that country...
    Last edited by FragFrog; 01-08-05 at 12:48 AM.

  6. #6
    Member katzif is offline
    MemberRank
    Dec 2004 Join Date
    Tel Aviv, Israel.Location
    92Posts
    Where do I need to put the file ipbanned.php ? in C:\AppServ\www ?

    Thanks in advanced.

  7. #7
    Member vacyracers is offline
    MemberRank
    Jun 2004 Join Date
    Estonia >> TallinnLocation
    54Posts
    love it lots of ppl can have some fun by banning some hackers now :)

  8. #8
    Back again Darkthrone is offline
    MemberRank
    Dec 2003 Join Date
    The NetherlandsLocation
    449Posts
    Quote Originally Posted by katzif
    Where do I need to put the file ipbanned.php ? in C:\AppServ\www ?
    Thanks in advanced.
    is also what i like to know.

  9. #9
    hello danse is offline
    MemberRank
    Jun 2004 Join Date
    1,809Posts
    this version had a little syntax errors..
    fixed version is attachment..
    Frag ur right that appserve have ban function but not all servers have it so it's usefull for them..

    Quote Originally Posted by Darkthrone
    is also what i like to know.
    put it in ur folder where you have web.
    choose the page wich you want to user be banned from and
    open with notepad
    and add line
    <?PHP
    include('ipbanned.php');
    ?>
    Attached Files Attached Files
    Last edited by Boko; 05-10-05 at 06:28 PM. Reason: Double Post

  10. #10
    Apprentice nittobr is offline
    MemberRank
    Apr 2005 Join Date
    BrLocation
    20Posts
    nice man!

    tkz for your contribuiton to eliminate de lammers! :)

  11. #11
    Member _master is offline
    MemberRank
    Oct 2004 Join Date
    MoldovaLocation
    98Posts
    ipfw add deny all from xxx to any
    :-)

  12. #12
    Ex Post Whore Josh is offline
    MemberRank
    Dec 2004 Join Date
    8,333Posts
    very nice ;)

  13. #13
    hello danse is offline
    MemberRank
    Jun 2004 Join Date
    1,809Posts
    Quote Originally Posted by FragFrog
    Last but not least: like elche27 already said, if you get hacked banning the people responsable really isn't the answer. Better security is. Though I personally favor banning all polish IP's, I'm continiously seeing hack attempts from that country...
    Not all of polish ppl are lames, noobs, hackers.

  14. #14
    Enthusiast Thug_Teerz is offline
    MemberRank
    Sep 2005 Join Date
    Livin ma lyfeLocation
    45Posts
    I use mutoolz so where do i put the ipbanned php file?

  15. #15
    Enthusiast Bloder is offline
    MemberRank
    Jul 2005 Join Date
    Everywhere...Location
    34Posts
    Could u tell me how to do the contrary thing, i mean, for example, to be only allowed the ip's of my lan, for example on a cyber... that only my cyber's people can entry to the options of the acc on the site, do u understand what i mean?

  16. #16
    Enthusiast Bloder is offline
    MemberRank
    Jul 2005 Join Date
    Everywhere...Location
    34Posts
    how do i do the contrary thing? i mean, to allow, not to ban, just ip's i want can entry the page and the rest don't... it could works to restrict changes of account to a certain ip's... do you understand what i mean?

  17. #17
    Enthusiast Bloder is offline
    MemberRank
    Jul 2005 Join Date
    Everywhere...Location
    34Posts
    how do i do the contrary thing? i mean, to allow, not to ban, just ip's i want can entry the page and the rest can't... it could works to restrict changes of account to a certain ip's... do you understand what i mean?

  18. #18
    Account Upgraded | Title Enabled! aspire219 is offline
    MemberRank
    Jul 2004 Join Date
    californiaLocation
    436Posts

    Question

    im using mutoolz too where i gonna put it?

  19. #19
    Apprentice 2fastMG is offline
    MemberRank
    Nov 2005 Join Date
    5Posts
    very nice

  20. #20
    Proficient Member CarcaBot is offline
    MemberRank
    Nov 2005 Join Date
    181Posts
    Guys, make in your www folder one file with name .htaccess and type that in him:
    Code:
    Order Allow,Deny
    Allow from all
    Deny from 127.0.0.1
    where 127.0.0.1 is the ip who want to get ban!

    Or try other method ;)
    make one file called banned as .php and type this in him :
    Code:
    <?PHP
    $banned_ip = '127.0.0.1';
    $guest_ip = $_SERVER['REMOTE_ADDR'];
    if($guest_ip == $banned_ip) 
    { 
    die("You have been banned from this page, contact administrator"); 
    **
    ?>
    where 127.0.0.1 => victim ip
    or if u want to ban many ips write this in your php file:
    Code:
    <?PHP
    $banned_ips = ("127.0.0.1,127.0.0.2");
    $guest_ip = $_SERVER['REMOTE_ADDR']; 
    $ip_list = explode(",", $banned_ips); 
    foreach($ip_list as $ip) 
    { 
    if($guest_ip == $ip) 
    { 
    die("You have been banned from this page, contact administrator!"); 
    ****
    ?>
    where 127.0.0.1.127.0.0.2 it's victim's ips so u can put many separed with , !

    now if u want to include this php file in index page write in
    news.php or what page it's first , at first line :
    Code:
    <?
    include('banned.php');
    ?>
    attention if u use MuToolz 2.1F the first lines is:
    Code:
    <?PHP
    //ob_start("ob_gzhandler");
    define ("_LOCATION",dirname(__FILE__) . "/");
    require(_LOCATION.'_libs/header.php');
    if (isset($_GET['read'])) {
    ...
    set following :
    Code:
    <?PHP
    include('banned.php');
    //ob_start("ob_gzhandler");
    define ("_LOCATION",dirname(__FILE__) . "/");
    require(_LOCATION.'_libs/header.php');
    if (isset($_GET['read'])) {

    That's All

  21. #21
    Proficient Member CarcaBot is offline
    MemberRank
    Nov 2005 Join Date
    181Posts
    Guys, make in your www folder one file with name .htaccess and type that in him:
    Code:
    Order Allow,Deny
    Allow from all
    Deny from 127.0.0.1
    where 127.0.0.1 is the ip who want to get ban!

    Or try other method ;)
    make one file called banned as .php and type this in him :
    Code:
    <?PHP
    $banned_ip = '127.0.0.1';
    $guest_ip = $_SERVER['REMOTE_ADDR'];
    if($guest_ip == $banned_ip) 
    { 
    die("You have been banned from this page, contact administrator"); 
    **
    ?>
    where 127.0.0.1 => victim ip
    or if u want to ban many ips write this in your php file:
    Code:
    <?PHP
    $banned_ips = ("127.0.0.1,127.0.0.2");
    $guest_ip = $_SERVER['REMOTE_ADDR']; 
    $ip_list = explode(",", $banned_ips); 
    foreach($ip_list as $ip) 
    { 
    if($guest_ip == $ip) 
    { 
    die("You have been banned from this page, contact administrator!"); 
    ****
    ?>
    where 127.0.0.1.127.0.0.2 it's victim's ips so u can put many separed with , !
    That's All

  22. #22
    Proficient Member CarcaBot is offline
    MemberRank
    Nov 2005 Join Date
    181Posts
    Guys, make in your www folder one file with name .htaccess and type that in him:
    Code:
    Order Allow,Deny
    Allow from all
    Deny from 127.0.0.1
    where 127.0.0.1 is the ip who want to get ban!

    Or try other method ;)
    make one file called banned as .php and type this in him :
    Code:
    <?PHP
    $banned_ip = '127.0.0.1';
    $guest_ip = $_SERVER['REMOTE_ADDR'];
    if($guest_ip == $banned_ip) 
    { 
    die("You have been banned from this page, contact administrator"); 
    **
    ?>
    where 127.0.0.1 => victim ip
    or if u want to ban many ips write this in your php file:
    Code:
    <?PHP
    $banned_ips = ("127.0.0.1,127.0.0.2");
    $guest_ip = $_SERVER['REMOTE_ADDR']; 
    $ip_list = explode(",", $banned_ips); 
    foreach($ip_list as $ip) 
    { 
    if($guest_ip == $ip) 
    { 
    die("You have been banned from this page, contact administrator!"); 
    ****
    ?>
    where 127.0.0.1.127.0.0.2 it's victim's ips so u can put many separed with , !
    That's All



Advertisement