From f9831aad9ede5e1c316e445d439adaef7709da8c Mon Sep 17 00:00:00 2001 From: Ying Date: Tue, 23 Aug 2022 11:11:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=8D=E5=90=91=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=9C=9F=E5=AE=9EIPbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Login.php | 4 ++-- app/admin/controller/system/Admin.php | 2 +- app/admin/middleware/system/AdminPermissions.php | 2 +- app/common/exception/ExceptionHandle.php | 2 +- app/common/library/Auth.php | 4 ++-- app/index/controller/Third.php | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index b4064b7..bf09f9c 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -91,7 +91,7 @@ class Login extends AdminController return $this->error($error); } - $result->login_ip = request()->getRemoteIp(); + $result->login_ip = request()->getRealIp(); $result->login_time = time(); $result->count = $result->count + 1; @@ -136,7 +136,7 @@ class Login extends AdminController $user_browser = preg_replace('/[^(]+\((.*?)[^)]+\) .*?/','$1',$userAgent); $data = [ - 'user_ip' => request()->getRemoteIp(), + 'user_ip' => request()->getRealIp(), 'user_agent' => $userAgent, 'user_os' => $user_os, 'user_browser' => $user_browser, diff --git a/app/admin/controller/system/Admin.php b/app/admin/controller/system/Admin.php index 4efefa8..ed0e32d 100644 --- a/app/admin/controller/system/Admin.php +++ b/app/admin/controller/system/Admin.php @@ -154,7 +154,7 @@ class Admin extends AdminController // 管理员加密 $post['pwd'] = encryptPwd($post['pwd']); - $post['create_ip'] = request()->getRemoteIp(); + $post['create_ip'] = request()->getRealIp(); $data = $this->model->create($post); if (!is_empty($data->id)) { $access['admin_id'] = $data->id; diff --git a/app/admin/middleware/system/AdminPermissions.php b/app/admin/middleware/system/AdminPermissions.php index 1d19a91..7900b38 100644 --- a/app/admin/middleware/system/AdminPermissions.php +++ b/app/admin/middleware/system/AdminPermissions.php @@ -116,7 +116,7 @@ class AdminPermissions implements MiddlewareInterface 'method' => request()->method(), 'code' => 200, 'url' => request()->url(), - 'ip' => request()->getRemoteIp(), + 'ip' => request()->getRealIp(), 'name' => session('AdminLogin.name'), ]; diff --git a/app/common/exception/ExceptionHandle.php b/app/common/exception/ExceptionHandle.php index 7adce96..fc7a9f1 100644 --- a/app/common/exception/ExceptionHandle.php +++ b/app/common/exception/ExceptionHandle.php @@ -29,7 +29,7 @@ class ExceptionHandle extends \Webman\Exception\ExceptionHandler 'params' => serialize(request()->all()), 'method' => request()->method(), 'url' => request()->url(), - 'ip' => request()->getRemoteIp(), + 'ip' => request()->getRealIp(), 'name' => session('AdminLogin.name'), ]; diff --git a/app/common/library/Auth.php b/app/common/library/Auth.php index 8de0c07..2ed78a9 100644 --- a/app/common/library/Auth.php +++ b/app/common/library/Auth.php @@ -92,7 +92,7 @@ class Auth /** * 禁止批量注册 */ - $where[] = ['create_ip', '=', ip2long(request()->getRemoteIp())]; + $where[] = ['create_ip', '=', ip2long(request()->getRealIp())]; $where[] = ['create_time', '>', linux_extime(1)]; $totalMax = UserModel::where($where)->count(); @@ -173,7 +173,7 @@ class Auth $userUpdate = [ 'id' => $this->userInfo['id'], 'login_time' => time(), - 'login_ip' => request()->getRemoteIp(), + 'login_ip' => request()->getRealIp(), 'login_count' => $this->userInfo['login_count'] + 1, ]; diff --git a/app/index/controller/Third.php b/app/index/controller/Third.php index b1e2731..b101d50 100644 --- a/app/index/controller/Third.php +++ b/app/index/controller/Third.php @@ -125,7 +125,7 @@ class Third extends HomeController if (!empty($userInfo)) { $array['id'] = $userInfo['id']; $array['login_time'] = time(); - $array['login_ip'] = request()->getRemoteIp(); + $array['login_ip'] = request()->getRealIp(); $array['login_count'] = $userInfo['login_count'] + 1; if (User::update($array)) { @@ -142,7 +142,7 @@ class Third extends HomeController $data['nickname'] .= Random::alpha(3); } $data['group_id'] = 1; - $data['create_ip'] = request()->getRemoteIp(); + $data['create_ip'] = request()->getRealIp(); $result = $this->auth->register($data); // 封装第三方数据