@@ -12,14 +12,20 @@ |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | $ttw = (int) @$_GET['ttw']; |
15 | -if ($ttw == 0) $ttw = 10; |
|
16 | -if ($ttw < 0 || $ttw > 10) $ttw = 10; |
|
15 | +if ($ttw == 0) { |
|
16 | + $ttw = 10; |
|
17 | +} |
|
18 | +if ($ttw < 0 || $ttw > 10) { |
|
19 | + $ttw = 10; |
|
20 | +} |
|
17 | 21 | |
18 | 22 | $filterValue = @$_GET['filterValue']; |
19 | 23 | $filterValue = $filterValue != null ? (int) $filterValue : null; |
20 | 24 | |
21 | 25 | $package = unserialize(RedisQ\RedisQ::listen($queueID, $ip, $ttw, $filterValue)); |
22 | -if ($package === false) $package = null; |
|
26 | +if ($package === false) { |
|
27 | + $package = null; |
|
28 | +} |
|
23 | 29 | |
24 | 30 | $response = ['package' => $package]; |
25 | 31 | header("Access-Control-Allow-Origin: *"); |
@@ -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 |