This commit is contained in:
2024-10-29 14:04:59 +08:00
commit 48bf3e6f33
2839 changed files with 762707 additions and 0 deletions

30
app/admin/behavior/CheckIp.php Executable file
View 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);
}
}