Jump to content

IP banning


Cless

Recommended Posts

But in some cases...it helps as a deterrent. I say do both username and IP bans....and store it in a cookie as an additional step...just an extra step to annoy them more. The method depends on how you're storing the banned users...MySQL database? Flat file?

Link to comment
Share on other sites

the cookie idea works because if their IP is in the cookie + its banned you know it came from that machine, but if someone can get around a proxy they will know how to kill your cookies, but you could say if they have the "bad cookie" set  a session with them that says they are bad too

Link to comment
Share on other sites

A simplification...

 

<?php

  $usrip = $_SERVER['REMOTE_ADDR'];
  $usrname = $_SESSION['username'];

  $banlist = file_get_contents('banlist.txt');

    if((preg_match('/'.$usrip.'/i', $banlist)) || (preg_match('/'.$usrname.'/i', $banlist)) || ($_COOKIE['banned'] == '1')) 
    {
      header("Location: index.php?notice=banned");
      exit;
    }

?>

 

And in index.php you set your cookie.

 

And sure...they can clear their cookies. But every time they get banned...they have to take extra steps to get to your site. At that point, they have to start wondering what the hell they're doing with their spare time. They've got issues. :-P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.