Merge pull request '推广后台每秒限制访问' (#295) from hotfix/shift_repeat_bug into release

Reviewed-on: http://8.136.139.249:3000/wmtx/platform/pulls/295
master
廖金灵 4 years ago
commit e270544df1

@ -5,6 +5,7 @@ namespace Home\Controller;
use Base\Service\PromoteCompanyService;
use Think\Controller;
use Base\Service\PromoteService;
use Base\Tool\Redis;
class BaseController extends HomeController
{
@ -30,6 +31,9 @@ class BaseController extends HomeController
$this->login();
$loginer = $this->getLoginPromote();
$this->accessLimit($loginer);
// $this->certifiCation();
$pid = is_login_promote();
define('PLEVEL', $loginer['parent_id']);
@ -432,4 +436,20 @@ class BaseController extends HomeController
->group('relation_game_id')
->select();
}
public function accessLimit($loginer)
{
$urlKey = substr(md5(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME), 8, 16);
$key = $loginer['id'] . ':' . $urlKey;
$check = Redis::exists($key);
if ($check) {
$count = Redis::incr($key);
if ($count > 60) {
die('请求太频繁,请稍后再试!');
}
} else {
Redis::incr($key);
Redis::expire($key, 60);
}
}
}

Loading…
Cancel
Save