Link to home
Start Free TrialLog in
Avatar of showmeurgoods
showmeurgoods

asked on

How To Prevent False Reads From Anti-Flood Protection?

Hello

The below code is for redirecting flood attempts to a flood page I have made.  The only problem with the below coding is that sometimes it gives false positives and redirects to the flood page when there is no flood.  It will do this on such things as loggin in to my site, or posting in the forum at times it will do this. The 0.000001 below is the time set for it.

What adjustments can be made to increase the accuracy of the flood protection?

Thanks
Rob

// anti flood protection
if($_SESSION['last_session_request'] > time() - 0.000001 && !$_SESSION['forum_flood'] && !$ir['forummod'] && !$ir['forumadmin']  && !$ir['forumcoder']){
    // users will be redirected to this page if it makes requests faster than 2 seconds
    header("Location: ../flood.php");
    exit;
}
$_SESSION['last_session_request'] = time();
unset($_SESSION['forum_flood']);
 //end anti flood protection
}	

Open in new window

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Please explain a little more... What is the problem you are up against?
Avatar of showmeurgoods
showmeurgoods

ASKER

Hello

What the code does is send a member/visitor who is excessively reqeusting pages.  This is a flood prevention code.  The issue is that it gives false positives sometimes.  I've tried to adjust the time to be more accurate, but it has not done it.

Are there any adjustments to the code or to the time, which will stop the false positives?

I know there are similar codes online for anti flood, this one is all good except for the 0.00001 which I've tried to adjust to different times, but seems to still give false redirects.

Thanks
Rob
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello Ray

The protection is meant redirect any/all over excessive requests to a page. I've been told it will redirect some ddos type attacks also and/or bad bots.  Its placed in the header of both site and forum. (two separate headers).

They forum are post requests, which are submitted via a member.

The flood.php page is just a landing page which tells them that they are over excessively requesting page requests.  Once this is running well, I'll add the option to either redirect to a page of choice via {($set['redirect_page'])} in place of flood.php and I'll add the history recording also on the flood.php page to record in the db the username, date/time, the page the user came from, and set it to count+1 per hit.  Then in the admin area I can make a page to display this info which will provide helpful.

I'm going to try the above later today and I'll report back :)  
Thank you very much for your posting.

Rob
Understood.  You should be able to install the code and run it on your server to see what it does.

It will not inoculate against DOS attacks because your server will run out of data pipes - that is the principle issue with denial of service.  But it should be able to limit some bad bots and other scripting attacks.  For good bots, be sure you have the right robots.txt files.
http://www.robotstxt.org/

Best of luck with it, ~Ray