dkanavis

limiter

Nov 10th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. /* config/limiter.php */
  2.  
  3. // Limiter (redis-based) config
  4. // [max => X, in => Y] - max X actions in Y seconds for $namespace
  5. // [global => true, max => X, in => Y] - max X actions in Y seconds global on server
  6. // ban arg - if exists, ban for this number of seconds after limit reached.
  7. //          Otherwise, disallow action only if it exceeds the limit.
  8. //          Ban applies if max val reached, not max exceeded, but that time action is allowed.
  9.  
  10. // SMS limits namespace
  11. $config['limiter_sms'] = [
  12.     ['max' => 1, 'in' => 60],
  13.     ['global' => true, 'max' => 50, 'in' => 100, 'ban' => 600]
  14. ];
  15.  
  16. // Email limits namespace
  17. $config['limiter_email'] = [
  18.     ['max' => 3, 'in' => 60],
  19.     ['max' => 20, 'in' => 300, 'ban' => 300],
  20.     ['global' => true, 'max' => 50, 'in' => 100, 'ban' => 600]
  21. ];
  22.  
  23.  
  24.  
  25.  
  26.  
  27. /* class Anything extends LK_Controller */
  28. if (($r = $this->limit('sms')) !== true) return ['waitSeconds' => $r];
Advertisement
Add Comment
Please, Sign In to add comment