]> git.openstreetmap.org Git - nominatim.git/commitdiff
sort output of blocked list by block timestamp
authorBrian Quinion <openstreetmap@brian.quinion.co.uk>
Sat, 8 Dec 2012 17:58:24 +0000 (17:58 +0000)
committerBrian Quinion <openstreetmap@brian.quinion.co.uk>
Sat, 8 Dec 2012 17:58:24 +0000 (17:58 +0000)
lib/init-website.php
lib/lib.php

index 40e4713e21c1c6261fd12910d239c880d522a402..8f04d97d9029832af60cb84e254996726b2b1511 100644 (file)
                        (defined('CONST_ConnectionBucket_PageType')?constant('CONST_ConnectionBucket_Cost_'.CONST_ConnectionBucket_PageType):1) + user_busy_cost(),
                        CONST_ConnectionBucket_LeakRate, CONST_ConnectionBucket_BlockLimit);
 
                        (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";
        if (strpos(CONST_BlockedIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false || $fBucketVal >= CONST_ConnectionBucket_BlockLimit)
        {
                echo "Your IP has been blocked. \n";
@@ -25,9 +31,4 @@
                exit;
        }
 
                exit;
        }
 
-       if ($fBucketVal > CONST_ConnectionBucket_WaitLimit)
-       {
-               sleep(($fBucketVal - CONST_ConnectionBucket_WaitLimit)/CONST_ConnectionBucket_LeakRate);
-       }
-
        header('Content-type: text/html; charset=utf-8');
        header('Content-type: text/html; charset=utf-8');
index 20f5af17787c7386cd98594f74c1e5c30198ead5..0af91e2d89a348091d8726bfc151776afb0d165a 100644 (file)
                return $iMaxVal;
         }
 
                return $iMaxVal;
         }
 
+       function byLastBlockTime($a, $b)
+       {
+               if ($a['lastBlockTimestamp'] == $b['lastBlockTimestamp'])
+               {
+                       return 0;
+               }
+               return ($a['lastBlockTimestamp'] > $b['lastBlockTimestamp']) ? -1 : 1;
+       }
+
        function getBucketBlocks()
        {
                $m = getBucketMemcache();
        function getBucketBlocks()
        {
                $m = getBucketMemcache();
                                'currentlyBlocked' => $iCurrentBucketSize + (CONST_ConnectionBucket_Cost_Reverse) >= CONST_ConnectionBucket_BlockLimit,
                                );
                }
                                'currentlyBlocked' => $iCurrentBucketSize + (CONST_ConnectionBucket_Cost_Reverse) >= CONST_ConnectionBucket_BlockLimit,
                                );
                }
+               uasort($aBlockedList, 'byLastBlockTime');
                return $aBlockedList;
        }
 
                return $aBlockedList;
        }