forked from hans/Nominatim
sort output of blocked list by block timestamp
This commit is contained in:
@@ -17,6 +17,12 @@
|
||||
(defined('CONST_ConnectionBucket_PageType')?constant('CONST_ConnectionBucket_Cost_'.CONST_ConnectionBucket_PageType):1) + user_busy_cost(),
|
||||
CONST_ConnectionBucket_LeakRate, CONST_ConnectionBucket_BlockLimit);
|
||||
|
||||
if ($fBucketVal > CONST_ConnectionBucket_WaitLimit && $fBucketVal < CONST_ConnectionBucket_BlockLimit)
|
||||
{
|
||||
sleep(($fBucketVal - CONST_ConnectionBucket_WaitLimit)/CONST_ConnectionBucket_LeakRate);
|
||||
$fBucketVal = doBucket($aBucketKeys, 0, 0, CONST_ConnectionBucket_BlockLimit);
|
||||
}
|
||||
|
||||
if (strpos(CONST_BlockedIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false || $fBucketVal >= CONST_ConnectionBucket_BlockLimit)
|
||||
{
|
||||
echo "Your IP has been blocked. \n";
|
||||
@@ -25,9 +31,4 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($fBucketVal > CONST_ConnectionBucket_WaitLimit)
|
||||
{
|
||||
sleep(($fBucketVal - CONST_ConnectionBucket_WaitLimit)/CONST_ConnectionBucket_LeakRate);
|
||||
}
|
||||
|
||||
header('Content-type: text/html; charset=utf-8');
|
||||
|
||||
10
lib/lib.php
10
lib/lib.php
@@ -994,6 +994,15 @@
|
||||
return $iMaxVal;
|
||||
}
|
||||
|
||||
function byLastBlockTime($a, $b)
|
||||
{
|
||||
if ($a['lastBlockTimestamp'] == $b['lastBlockTimestamp'])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ($a['lastBlockTimestamp'] > $b['lastBlockTimestamp']) ? -1 : 1;
|
||||
}
|
||||
|
||||
function getBucketBlocks()
|
||||
{
|
||||
$m = getBucketMemcache();
|
||||
@@ -1014,6 +1023,7 @@
|
||||
'currentlyBlocked' => $iCurrentBucketSize + (CONST_ConnectionBucket_Cost_Reverse) >= CONST_ConnectionBucket_BlockLimit,
|
||||
);
|
||||
}
|
||||
uasort($aBlockedList, 'byLastBlockTime');
|
||||
return $aBlockedList;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user