master
ELF 4 years ago
parent 9904d85516
commit c72229e6aa

@ -6,6 +6,7 @@ use Base\Service\PromoteCompanyService;
use Think\Controller;
use Base\Service\PromoteService;
use Base\Tool\Redis;
use Think\Log;
class BaseController extends HomeController
{
@ -439,12 +440,14 @@ class BaseController extends HomeController
public function accessLimit($loginer)
{
$urlKey = substr(md5(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME), 8, 16);
$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) {
if ($count > 3) {
Log::write('user_access_limit:' . date('Y-m-d H:i:s') . ' ' . $key . '[' . $url . ']', 'INFO');
die('请求太频繁,请稍后再试!');
}
} else {

Loading…
Cancel
Save