init
This commit is contained in:
30
app/admin/behavior/CheckIp.php
Executable file
30
app/admin/behavior/CheckIp.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user