From: Brian Quinion Date: Sat, 8 Dec 2012 17:58:24 +0000 (+0000) Subject: sort output of blocked list by block timestamp X-Git-Tag: v2.2.0~169 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/02e7cfd6f483a6274417e5284ba547eda7ef3007 sort output of blocked list by block timestamp --- diff --git a/lib/init-website.php b/lib/init-website.php index 40e4713e..8f04d97d 100644 --- a/lib/init-website.php +++ b/lib/init-website.php @@ -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'); diff --git a/lib/lib.php b/lib/lib.php index 20f5af17..0af91e2d 100644 --- a/lib/lib.php +++ b/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; }