• home
  • forum
  • my
  • kt
  • download
  • Ban an IP Address Using PHP

    Author: 2008-08-22 08:34:15 From:

    Someone causing you pain? BAN THEM!

    CODE
    <?php
    $ip=getenv('REMOTE_ADDR');
    $banned=xxx.xxx.xxx.xxx;
    if (ereg($banned,$ip)) {
    echo 'Sorry...but you've been BANNED!';
    exit();
    }
    ?>


    -- That's the full code...but what's the use of it without an explination?

    <?php
    This opens the php script.

    $ip=getenv('REMOTE_ADDR');
    This gets the visitor's IP address.

    $banned=xxx.xxx.xxx.xxx;
    Replace "xxx.xxx.xxx.xxx" with the IP of the banned user.

    if (ereg($banned,$ip)) {
    This see's if the visitor's IP and the Banned IP match.

    If they do match the visitor will recieve a message:
    echo 'Sorry...but you've been BANNED!';
    And the page wont load. (Feel free to change the message).

    exit();
    }
    ?>

    Just closing the script.

    ---

    No more trouble!

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      Ad Management (4)
      Calendars (3)
      Chat Systems (7)
      Content Management (6)
      Cookies and Sessions (8)
      Counters (8)
      Database Related (8)
      Date and Time (9)
      Development (6)
      Discussion Boards (7)
      E Commerce (6)
      Email Systems (9)
      Error Handling (5)
      File Manipulation (10)
      Flash and PHP (4)
      Form Processing (7)
      Guestbooks (8)
      Image Manipulation (3)
      Installing PHP (5)
      Introduction to PHP (9)
      Link Indexing (6)
      Mailing List Management (8)
      Miscellaneous (37)
      Networking (8)
      News Publishing (9)
      OOP (24)
      PEAR (6)
      PHP vs Other Languages (2)
      Polls and Voting (6)
      Postcards (1)
      Randomizing (14)
      Redirection (11)
      Searching (9)
      Security (29)
      Site Navigation (16)
      User Authentication (14)
      WAP and WML (7)
      Web Fetching (8)
      Web Traffic Analysis (15)
      XML and PHP (16)

    New

    Hot