Banning an IP address

Discussion in 'HTML & Website Design' started by kolgames, May 14, 2008.

  1. #1
    Hello, for my site (temporary URl until I get real hosting plan),link in sig(mass-share) which is a file host, I have rules that if broken result in a ban for the person's IP. How so I get the person's IP, print it, and possibly ban it if needed? I would have to manually add it to a ban list or something, which is fine. PHP or HTML please... Thanks!

    /offtopic
    PS: Also Can you give me some feedback on the site, such as CSS and the rest of it...
     
    kolgames, May 14, 2008 IP
  2. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #2
    You can easily get someone's IP address with PHP:

    
    $visitorIP = $_SERVER['REMOTE_ADDR'];
    
    Code (markup):
    You can then add that IP to a MySQL table and whenever someone visits the site with that IP address, redirect them to a special "banned" page.

    This is FAR from foolproof, though. First of all, they can have a dynamic IP address, which means it will be different every time they come to your site. Secondly, most visitors who are breaking rules are probably savvy hackers, who can spoof any IP address they want.
     
    itcn, May 15, 2008 IP
  3. kolgames

    kolgames Active Member

    Messages:
    667
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I really am not good with SQL yet... How do you redirect?
     
    kolgames, May 15, 2008 IP
  4. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #4
    Well, you'll have to do some reading on how to insert the data into a MySQL table, but redirecting to a new URL in php is very easy. If you have not sent any info to the browser yet, use this:

    
    header('Location: http://www.yoursite.com/banned.php');
    
    Code (markup):
    and if you have, use output buffering:

    
    // PUT THIS AT TOP OF PAGE
    ob_start(); 
    
    // THEN FOR REDIRECT
    ob_end_clean();
    header('Location: http://www.yoursite.com/banned.php');
    exit;
    
    Code (markup):
     
    itcn, May 15, 2008 IP
  5. ourblink

    ourblink Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    How about use the IP ban from your cpanel ?
    It will work without add any script
     
    ourblink, May 15, 2008 IP
  6. kolgames

    kolgames Active Member

    Messages:
    667
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #6
    hmm...didn't know there was a ban IP thing in Cpanel...Thanks!
     
    kolgames, May 15, 2008 IP
  7. kolgames

    kolgames Active Member

    Messages:
    667
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #7
    hmm...didn't know there was a ban IP thing in Cpanel...Thanks!
     
    kolgames, May 15, 2008 IP
  8. edward hamilton

    edward hamilton Peon

    Messages:
    2
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I see that the ip addresses are stored in the option field of the vb_database file but there is also a lot of other data contained in that field.

    Any direction of where to read how to add ip addresses to the option field would be appreciated.
     
    edward hamilton, May 16, 2008 IP