Tweet
Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    3
    Rep Power
    0

    Default Capturing IP address & blocking IP address

    I'm using a php script for my web site which has registration, log-in, etc.
    When I asked how I might be able to capture the registrants IP address upon registration, I was given this code and this advice:

    PHP Code:
    $userip $_SERVER[REMOTE_ADDR];
    mysql_real_escape_string($userip); 
    "Remember when you store these values in the database to use these two functions INET_ATON() and INET_NTOA(). One is for inserting the IP and one is for extracting it."

    I don't know what INET_ATON() and INET_NTOA() are, but my goal is to be able to have a users IP address just in case he spams my site, then he can be blocked, based on the thinking that typically one user has one computer.

    can someone tell me how I can block an Ip address?
    Any thoughts/replies/suggestions will be welcome.
    [URL=http://www.amfedrine.com]Weight loss *****[/URL] [URL=http://www.chacha.com/topic/madonna]Madonna[/URL]

  2. #2
    MFC Member
    Join Date
    Feb 2009
    Posts
    35
    Rep Power
    0

    Default

    you can block ip via htaccess or your web hosting control panel.

  3. #3
    Junior Member
    Join Date
    Dec 2009
    Location
    Wisconsin, USA
    Posts
    3
    Rep Power
    0

    Default

    I think he may have given you the wrong functions to use. Check out these links, they might help:

    PHP: inet_pton - Manual
    PHP: inet_ntop - Manual

  4. #4
    Junior Member
    Join Date
    Oct 2010
    Posts
    2
    Rep Power
    0

    Default

    For IP blocking, the best choice - use htaccess file. U can control directories, users ip and other stuff.

    Deny ip address via .htaccess example:

    order allow,deny
    deny from 78.61.129.229
    allow from all


    Ip address you can get, using such code snippet:

    if (isset($_SERVER['HTTP_X_FORWARD_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARD_FOR'];
    } else {
    $ip = $_SERVER['REMOTE_ADDR'];
    }
    http://www.pcsoftwarestore.net - new software shop online
    http://www.computersstoreonline.com - best prices for computers, laptops and pc components

  5. #5
    MFC Member
    Join Date
    Sep 2012
    Posts
    243
    Rep Power
    12

    Default

    When you can block ips by cpanel then why will you go for a code? This will be much easier for you.

Posting Permissions

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

Advertisement

Sponsors




Increase your deposit by 30%. Expand your trading opportunities. Earn more profit!