@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $timeToWait = max(1, min(10, $timeToWait)); |
| 43 | 43 | |
| 44 | - if ($ip != "37.59.50.21" && $redis->get("redisQ:banned:$ip") == "true") { |
|
| 44 | + if ($ip != "37.59.50.21" && $redis->get("redisQ:banned:$ip") == "true") { |
|
| 45 | 45 | sleep(10); |
| 46 | 46 | header("Location: /banned.html", 302); |
| 47 | 47 | exit(); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | protected static function recursive_array_search($needle, $haystack) { |
| 90 | - foreach($haystack as $key=>$value) { |
|
| 90 | + foreach ($haystack as $key=>$value) { |
|
| 91 | 91 | $current_key = $key; |
| 92 | 92 | if ($needle === $value || (is_array($value) && self::recursive_array_search($needle, $value) !== false)) { |
| 93 | 93 | return true; |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | if ($redis->set($wQueueID, true, Array('nx', 'ex'=>15)) === false) { |
| 53 | 53 | $redis->incr("redisQ:queueID:429count:$ip"); |
| 54 | 54 | $redis->expire("redisQ:queueID:429count:$ip", 300); |
| 55 | - if ($redis->get("redisQ:queueID:429count:$ip") > 30) $redis->setex("redisQ:banned:$ip", 10000, "true"); |
|
| 55 | + if ($redis->get("redisQ:queueID:429count:$ip") > 30) { |
|
| 56 | + $redis->setex("redisQ:banned:$ip", 10000, "true"); |
|
| 57 | + } |
|
| 56 | 58 | header('HTTP/1.1 429 Too many requests.'); |
| 57 | 59 | exit(); |
| 58 | 60 | } |
@@ -65,7 +67,9 @@ discard block |
||
| 65 | 67 | $object = false; |
| 66 | 68 | $pop = $redis->blPop($rQueueID, 1); |
| 67 | 69 | if (!isset($pop[1])) { |
| 68 | - if (time() >= ($time + $timeToWait)) return; |
|
| 70 | + if (time() >= ($time + $timeToWait)) { |
|
| 71 | + return; |
|
| 72 | + } |
|
| 69 | 73 | } else { |
| 70 | 74 | $objectID = $pop[1]; |
| 71 | 75 | $object = $redis->get($objectID); |
@@ -82,7 +86,9 @@ discard block |
||
| 82 | 86 | |
| 83 | 87 | protected static function matchesFilter($filterValue, $object) |
| 84 | 88 | { |
| 85 | - if ($filterValue == null) return $object; |
|
| 89 | + if ($filterValue == null) { |
|
| 90 | + return $object; |
|
| 91 | + } |
|
| 86 | 92 | return self::recursive_array_search($filterValue, unserialize($object)) ? $object : false; |
| 87 | 93 | } |
| 88 | 94 | |