Files
2024-10-29 14:04:59 +08:00

31 lines
610 B
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\admin\behavior;
use think\Request;
use think\Config;
load_trait('controller/Jump');
/**
* Description of CheckIp
* 检测用户访问的ip
*/
class CheckIp {
use \traits\controller\Jump;
/**
* 检测用户IP
*/
public function run() {
$allow_ip = Config::get('admin_allow_ip');
$ip = Request::instance()->ip();
if (!is_administrator() && $allow_ip) {
!in_array($ip, explode(',', $allow_ip)) && $this->error('禁止访问'); // 检查IP地址访问
}
\think\Log::record("[ 访问者IP ]" . $ip);
}
}