Change load rate for throttling a user/spider if necessary

This commit is contained in:
Retro_Guy 2021-05-03 03:00:40 -07:00
parent 1dda180752
commit d834f7757d
1 changed files with 3 additions and 1 deletions

View File

@ -30,8 +30,10 @@
}
$_SESSION['views']++;
// $loadrate = allowed article request per second
$loadrate = 1.5;
$rate = ($_SESSION['views'] / (time() - $_SESSION['starttime']));
if (($rate > .15) && ($_SESSION['views'] > 5)) {
if (($rate > $loadrate) && ($_SESSION['views'] > 5)) {
header("HTTP/1.0 429 Too Many Requests");
if(!isset($_SESSION['throttled'])) {
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Too many requests from ".$_SERVER['REMOTE_ADDR']." throttling", FILE_APPEND);