Skip to content

Commit 51a0ffa

Browse files
florincmchriskacerguis
authored andcommitted
fix rate limiting (chriskacerguis#702)
1 parent 079ea94 commit 51a0ffa

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

application/libraries/REST_Controller.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,12 +1133,10 @@ protected function _check_limit($controller_method)
11331133
{
11341134
case 'API_KEY':
11351135
$limited_uri = 'api-key:' . (isset($this->rest->key) ? $this->rest->key : '');
1136-
$limited_method_name = isset($this->rest->key) ? $this->rest->key : '';
11371136
break;
11381137

11391138
case 'METHOD_NAME':
11401139
$limited_uri = 'method-name:' . $controller_method;
1141-
$limited_method_name = $controller_method;
11421140
break;
11431141

11441142
case 'ROUTED_URL':
@@ -1149,20 +1147,19 @@ protected function _check_limit($controller_method)
11491147
$limited_uri = substr($limited_uri,0, -strlen($this->response->format) - 1);
11501148
}
11511149
$limited_uri = 'uri:'.$limited_uri.':'.$this->request->method; // It's good to differentiate GET from PUT
1152-
$limited_method_name = $controller_method;
11531150
break;
11541151
}
11551152

1156-
if (isset($this->methods[$limited_method_name]['limit']) === FALSE )
1153+
if (isset($this->methods[$controller_method]['limit']) === FALSE )
11571154
{
11581155
// Everything is fine
11591156
return TRUE;
11601157
}
11611158

11621159
// How many times can you get to this method in a defined time_limit (default: 1 hour)?
1163-
$limit = $this->methods[$limited_method_name]['limit'];
1160+
$limit = $this->methods[$controller_method]['limit'];
11641161

1165-
$time_limit = (isset($this->methods[$limited_method_name]['time']) ? $this->methods[$limited_method_name]['time'] : 3600); // 3600 = 60 * 60
1162+
$time_limit = (isset($this->methods[$controller_method]['time']) ? $this->methods[$controller_method]['time'] : 3600); // 3600 = 60 * 60
11661163

11671164
// Get data about a keys' usage and limit to one row
11681165
$result = $this->rest->db

0 commit comments

Comments
 (0)