Jump to content
Welcome, Guest
Existing user? Sign In

Sign In



Sign Up
The MatriX
  • Welcome To Ghbsys
  • CS GO Streaming Version is released. Have fun streaming while cheating!
  • Have a Payment Issue? Send us a Support ticket.
  • Make a thread if you need support or join our discord for live support.
  • Have Suggestions? Make a thread and you'll earn Ghbsys Points for implemented suggestions.
  • Join our discord to stay well connected! Don't forget to integrate your discord to the site
  • Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum

    Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of [GHB] - GAmEhAcKbAsTaRdS Forum by signing in or creating an account.
    • Start new topics and reply to others
    • Subscribe to topics and forums to get email updates
    • Get your own profile page and make new friends
    • Send personal messages to other members.

    Mit PHP IP's bannen.


    meijör
     Share

    Recommended Posts

    Ich erkläre euch hier kurz, wie ihr eine IP von eurer Homepage verbannen könnt, die ihr schon kennt!

    I will show you, how to ban a known IP from your website.

     

    Als erstes ist es wichtig, zu wissen wie PHP die IP von Leuten "aufspürt". Das geht wie folgt :

    At the beginning it's important to know how PHP "sniffs up" the IP of the surfers. That works like this :

     

    <?
       $_SERVER['REMOTE_ADDR'];
    ?>

     

    In dieser Variablen ist die IP des Anwenders gespeichert.

    In this variable the IP of the user is saved.

     

    Um den Bösewicht nun mit Hilfe dieser Variablen von eurer Seite zu verbannen prüft ihr einfach ob er die IP hat, welche ihr bannen wollt.

    To ban the baddie with this variable you just need to check, if he has the IP you wanna ban.

     

    <?
    if ($_SERVER['REMOTE_ADDR'] == /*Ip of baddie*/ )
     {
    	   die("Your Ip has been banned!");
     }
    ?>

     

    Diesen kleinen Schnipsel könnt ihr einfach vor Beginn der eigentlichen Seite einfügen und der User ist gebannt.

    To ban someone you can just add this snippet before the beginning of the actual site.

     

     

    Ich hoffe ich konnte euch helfen O.o

    I hope i could help you xD

     

    EDIT : This script makes just sense when the one to ban has a static ip!

    Edited by MajorBitch`
    Link to comment
    Share on other sites

    You also could fetch the IP's out of a database, compare, then ban, example:

     

    <?php
    mysql_connect(yourhost,youruser,yourpw);
    mysql_select_db(your_db);
    $ip = $_SERVER['REMOTE_ADDR'];
    $query = mysql_query("SELECT * FROM `yourtable` WHERE `ip` = '$ip'");
    if(mysql_num_rows($query) >0)
    {
    die("bANNED!!111111eleventy");
    }
    else
    {
    // Your site
    }
    ?>

    Link to comment
    Share on other sites

    • 4 weeks later...

    If you don't have mysql installed, you may also have it in a simple file.

     

     

    <?php
    $ip = $_SERVER['REMOTE_ADDR'];
    $ips = file('bannedips.txt');
    
    if (in_array($ip, $ips)) {
    die("YOUR IP IS BANNED");
    }
    ?>

     

    bannedips.txt (example)

    156.81.20.111
    91.5.1.98

    Edited by MinIGod
    Link to comment
    Share on other sites

    i never did it like that :-O

    with files i used to do it with fopen fclose etc

    Link to comment
    Share on other sites

    • 2 months later...

    <?php
    $bannedip = array('127.0.0.1','87.209.160.22');
    function GetRealIP()
    {
       if (!empty($_SERVER['HTTP_CLIENT_IP']))
       {
         $ip=$_SERVER['HTTP_CLIENT_IP'];
       }
       elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
       {
         $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
       }
       else
       {
         $ip=$_SERVER['REMOTE_ADDR'];
       }
       return $ip;
    }
    function HideIP($ip)
    {
     $ding = "([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})";
     return ereg_replace($ding, "\\1.\\2.\\3.***", $ip);
    }
    if(in_array(GetRealIP(),$bannedip)){
    echo HideIP(GetRealIP())." is banned";
    die();
    }
    ?>
    

     

    AntiProxy >_>"

    Works 80%.

    Edited by Sayuta
    Link to comment
    Share on other sites

    Guest
    This topic is now closed to further replies.
     Share

    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...