Merge pull request '推广后台访问限制' (#297) from hotfix/shift_repeat_bug into master

Reviewed-on: http://8.136.139.249:3000/wmtx/platform/pulls/297
master
廖金灵 4 years ago
commit 834a4128d0

@ -5,6 +5,8 @@ namespace Home\Controller;
use Base\Service\PromoteCompanyService;
use Think\Controller;
use Base\Service\PromoteService;
use Base\Tool\Redis;
use Think\Log;
class BaseController extends HomeController
{
@ -30,6 +32,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 +437,22 @@ class BaseController extends HomeController
->group('relation_game_id')
->select();
}
public function accessLimit($loginer)
{
$url = MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME;
$urlKey = substr(md5($url), 8, 16);
$key = $loginer['id'] . ':' . $urlKey;
$check = Redis::exists($key);
if ($check) {
$count = Redis::incr($key);
if ($count > 60) {
Log::write('user_access_limit:' . date('Y-m-d H:i:s') . ' ' . $key . '[' . $url . ']', 'INFO');
die('请求太频繁,请稍后再试!');
}
} else {
Redis::incr($key);
Redis::expire($key, 60);
}
}
}

Loading…
Cancel
Save