Browse Source

feat: collect invalid user login

M1Screw 2 years ago
parent
commit
8a6f294362

+ 57 - 57
composer.lock

@@ -123,16 +123,16 @@
         },
         {
             "name": "aws/aws-sdk-php",
-            "version": "3.281.8",
+            "version": "3.281.11",
             "source": {
                 "type": "git",
                 "url": "https://github.com/aws/aws-sdk-php.git",
-                "reference": "eb349b9f31502a05c70362f57913b9fed6b65b1f"
+                "reference": "9d466efae67d5016ed132fd4ffa1566a7d4cab98"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/eb349b9f31502a05c70362f57913b9fed6b65b1f",
-                "reference": "eb349b9f31502a05c70362f57913b9fed6b65b1f",
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/9d466efae67d5016ed132fd4ffa1566a7d4cab98",
+                "reference": "9d466efae67d5016ed132fd4ffa1566a7d4cab98",
                 "shasum": ""
             },
             "require": {
@@ -212,9 +212,9 @@
             "support": {
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
-                "source": "https://github.com/aws/aws-sdk-php/tree/3.281.8"
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.281.11"
             },
-            "time": "2023-09-15T18:34:59+00:00"
+            "time": "2023-09-20T19:16:24+00:00"
         },
         {
             "name": "bacon/bacon-qr-code",
@@ -1237,16 +1237,16 @@
         },
         {
             "name": "illuminate/collections",
-            "version": "v10.23.1",
+            "version": "v10.24.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/illuminate/collections.git",
-                "reference": "72c3cc6d44416db499d2ad11b8b27ae22e60a661"
+                "reference": "939a975daa8a5f77974ffa6a24067f5e947683f4"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/illuminate/collections/zipball/72c3cc6d44416db499d2ad11b8b27ae22e60a661",
-                "reference": "72c3cc6d44416db499d2ad11b8b27ae22e60a661",
+                "url": "https://api.github.com/repos/illuminate/collections/zipball/939a975daa8a5f77974ffa6a24067f5e947683f4",
+                "reference": "939a975daa8a5f77974ffa6a24067f5e947683f4",
                 "shasum": ""
             },
             "require": {
@@ -1288,11 +1288,11 @@
                 "issues": "https://github.com/laravel/framework/issues",
                 "source": "https://github.com/laravel/framework"
             },
-            "time": "2023-09-07T14:13:46+00:00"
+            "time": "2023-09-18T18:32:31+00:00"
         },
         {
             "name": "illuminate/conditionable",
-            "version": "v10.23.1",
+            "version": "v10.24.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/illuminate/conditionable.git",
@@ -1338,7 +1338,7 @@
         },
         {
             "name": "illuminate/container",
-            "version": "v10.23.1",
+            "version": "v10.24.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/illuminate/container.git",
@@ -1389,7 +1389,7 @@
         },
         {
             "name": "illuminate/contracts",
-            "version": "v10.23.1",
+            "version": "v10.24.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/illuminate/contracts.git",
@@ -1437,16 +1437,16 @@
         },
         {
             "name": "illuminate/database",
-            "version": "v10.23.1",
+            "version": "v10.24.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/illuminate/database.git",
-                "reference": "41511347b8b74ef80b4e01d2b64d2b4a4263658a"
+                "reference": "dbf15dca652e25f2bd9607e78dc527464edbec1d"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/illuminate/database/zipball/41511347b8b74ef80b4e01d2b64d2b4a4263658a",
-                "reference": "41511347b8b74ef80b4e01d2b64d2b4a4263658a",
+                "url": "https://api.github.com/repos/illuminate/database/zipball/dbf15dca652e25f2bd9607e78dc527464edbec1d",
+                "reference": "dbf15dca652e25f2bd9607e78dc527464edbec1d",
                 "shasum": ""
             },
             "require": {
@@ -1502,11 +1502,11 @@
                 "issues": "https://github.com/laravel/framework/issues",
                 "source": "https://github.com/laravel/framework"
             },
-            "time": "2023-09-04T14:22:40+00:00"
+            "time": "2023-09-19T14:11:01+00:00"
         },
         {
             "name": "illuminate/macroable",
-            "version": "v10.23.1",
+            "version": "v10.24.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/illuminate/macroable.git",
@@ -1552,7 +1552,7 @@
         },
         {
             "name": "illuminate/pagination",
-            "version": "v10.23.1",
+            "version": "v10.24.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/illuminate/pagination.git",
@@ -1602,16 +1602,16 @@
         },
         {
             "name": "illuminate/support",
-            "version": "v10.23.1",
+            "version": "v10.24.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/illuminate/support.git",
-                "reference": "c21d327c2392eccd93748a2c9f1069a283a62d37"
+                "reference": "f3ac48a059e3f1a0cb72c926f83a77af77d7a7f3"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/illuminate/support/zipball/c21d327c2392eccd93748a2c9f1069a283a62d37",
-                "reference": "c21d327c2392eccd93748a2c9f1069a283a62d37",
+                "url": "https://api.github.com/repos/illuminate/support/zipball/f3ac48a059e3f1a0cb72c926f83a77af77d7a7f3",
+                "reference": "f3ac48a059e3f1a0cb72c926f83a77af77d7a7f3",
                 "shasum": ""
             },
             "require": {
@@ -1669,7 +1669,7 @@
                 "issues": "https://github.com/laravel/framework/issues",
                 "source": "https://github.com/laravel/framework"
             },
-            "time": "2023-09-12T18:56:44+00:00"
+            "time": "2023-09-19T14:13:21+00:00"
         },
         {
             "name": "irazasyed/telegram-bot-sdk",
@@ -6319,16 +6319,16 @@
         },
         {
             "name": "tronovav/geoip2-update",
-            "version": "v2.2.2",
+            "version": "v2.2.4",
             "source": {
                 "type": "git",
                 "url": "https://github.com/tronovav/geoip2-update.git",
-                "reference": "35ea93da5784740ffe308be0888131efa94a0e0b"
+                "reference": "60dc374c21e97ca16cadfbb418a4bbd6045b581e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/tronovav/geoip2-update/zipball/35ea93da5784740ffe308be0888131efa94a0e0b",
-                "reference": "35ea93da5784740ffe308be0888131efa94a0e0b",
+                "url": "https://api.github.com/repos/tronovav/geoip2-update/zipball/60dc374c21e97ca16cadfbb418a4bbd6045b581e",
+                "reference": "60dc374c21e97ca16cadfbb418a4bbd6045b581e",
                 "shasum": ""
             },
             "require": {
@@ -6366,9 +6366,9 @@
             "support": {
                 "email": "[email protected]",
                 "issues": "https://github.com/tronovav/geoip2-update/issues",
-                "source": "https://github.com/tronovav/geoip2-update/tree/v2.2.2"
+                "source": "https://github.com/tronovav/geoip2-update/tree/v2.2.4"
             },
-            "time": "2023-09-15T22:25:45+00:00"
+            "time": "2023-09-21T16:52:07+00:00"
         },
         {
             "name": "vectorface/googleauthenticator",
@@ -7746,16 +7746,16 @@
         },
         {
             "name": "phpstan/phpdoc-parser",
-            "version": "1.24.0",
+            "version": "1.24.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/phpstan/phpdoc-parser.git",
-                "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6"
+                "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6",
-                "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6",
+                "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01",
+                "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01",
                 "shasum": ""
             },
             "require": {
@@ -7787,22 +7787,22 @@
             "description": "PHPDoc parser with support for nullable, intersection and generic types",
             "support": {
                 "issues": "https://github.com/phpstan/phpdoc-parser/issues",
-                "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0"
+                "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.1"
             },
-            "time": "2023-09-07T20:46:32+00:00"
+            "time": "2023-09-18T12:18:02+00:00"
         },
         {
             "name": "phpunit/php-code-coverage",
-            "version": "10.1.5",
+            "version": "10.1.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
-                "reference": "1df504e42a88044c27a90136910f0b3fe9e91939"
+                "reference": "56f33548fe522c8d82da7ff3824b42829d324364"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1df504e42a88044c27a90136910f0b3fe9e91939",
-                "reference": "1df504e42a88044c27a90136910f0b3fe9e91939",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/56f33548fe522c8d82da7ff3824b42829d324364",
+                "reference": "56f33548fe522c8d82da7ff3824b42829d324364",
                 "shasum": ""
             },
             "require": {
@@ -7859,7 +7859,7 @@
             "support": {
                 "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
                 "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
-                "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.5"
+                "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.6"
             },
             "funding": [
                 {
@@ -7867,7 +7867,7 @@
                     "type": "github"
                 }
             ],
-            "time": "2023-09-12T14:37:22+00:00"
+            "time": "2023-09-19T04:59:03+00:00"
         },
         {
             "name": "phpunit/php-file-iterator",
@@ -8114,16 +8114,16 @@
         },
         {
             "name": "phpunit/phpunit",
-            "version": "10.3.4",
+            "version": "10.3.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "b8d59476f19115c9774b3b447f78131781c6c32b"
+                "reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b8d59476f19115c9774b3b447f78131781c6c32b",
-                "reference": "b8d59476f19115c9774b3b447f78131781c6c32b",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/747c3b2038f1139e3dcd9886a3f5a948648b7503",
+                "reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503",
                 "shasum": ""
             },
             "require": {
@@ -8147,7 +8147,7 @@
                 "sebastian/comparator": "^5.0",
                 "sebastian/diff": "^5.0",
                 "sebastian/environment": "^6.0",
-                "sebastian/exporter": "^5.0",
+                "sebastian/exporter": "^5.1",
                 "sebastian/global-state": "^6.0.1",
                 "sebastian/object-enumerator": "^5.0",
                 "sebastian/recursion-context": "^5.0",
@@ -8195,7 +8195,7 @@
             "support": {
                 "issues": "https://github.com/sebastianbergmann/phpunit/issues",
                 "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
-                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.4"
+                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.5"
             },
             "funding": [
                 {
@@ -8211,7 +8211,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2023-09-12T14:42:28+00:00"
+            "time": "2023-09-19T05:42:37+00:00"
         },
         {
             "name": "psr/cache",
@@ -8697,16 +8697,16 @@
         },
         {
             "name": "sebastian/exporter",
-            "version": "5.0.1",
+            "version": "5.1.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/exporter.git",
-                "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480"
+                "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/32ff03d078fed1279c4ec9a407d08c5e9febb480",
-                "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480",
+                "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c3fa8483f9539b190f7cd4bfc4a07631dd1df344",
+                "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344",
                 "shasum": ""
             },
             "require": {
@@ -8763,7 +8763,7 @@
             "support": {
                 "issues": "https://github.com/sebastianbergmann/exporter/issues",
                 "security": "https://github.com/sebastianbergmann/exporter/security/policy",
-                "source": "https://github.com/sebastianbergmann/exporter/tree/5.0.1"
+                "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.0"
             },
             "funding": [
                 {
@@ -8771,7 +8771,7 @@
                     "type": "github"
                 }
             ],
-            "time": "2023-09-08T04:46:58+00:00"
+            "time": "2023-09-18T07:15:37+00:00"
         },
         {
             "name": "sebastian/global-state",

+ 3 - 2
src/Controllers/AuthController.php

@@ -5,6 +5,7 @@ declare(strict_types=1);
 namespace App\Controllers;
 
 use App\Models\InviteCode;
+use App\Models\LoginIp;
 use App\Models\Setting;
 use App\Models\User;
 use App\Services\Auth;
@@ -69,16 +70,16 @@ final class AuthController extends BaseController
         }
 
         $antiXss = new AntiXSS();
-
         $code = $antiXss->xss_clean($request->getParam('code'));
         $passwd = $request->getParam('passwd');
         $rememberMe = $request->getParam('remember_me') === 'true' ? 1 : 0;
         $email = strtolower(trim($antiXss->xss_clean($request->getParam('email'))));
         $redir = Cookie::get('redir') === '' ? $antiXss->xss_clean(Cookie::get('redir')) : '/user';
-
         $user = User::where('email', $email)->first();
 
         if ($user === null) {
+            (new LoginIp())->collectInvalidUserLoginIP($_SERVER['REMOTE_ADDR'], 1);
+
             return $response->withJson([
                 'ret' => 0,
                 'msg' => '邮箱或者密码错误',

+ 1 - 0
src/Controllers/PasswordController.php

@@ -54,6 +54,7 @@ final class PasswordController extends BaseController
     {
         if (Setting::obtain('enable_reset_password_captcha')) {
             $ret = Captcha::verify($request->getParams());
+
             if (! $ret) {
                 return ResponseHelper::error($response, '系统无法接受你的验证结果,请刷新页面后重试');
             }

+ 2 - 2
src/Controllers/SubController.php

@@ -66,7 +66,7 @@ final class SubController extends BaseController
         . '; expire=' . strtotime($user->class_expire);
 
         if ($_ENV['subscribeLog']) {
-            SubscribeLog::add($user, $subtype, $request->getHeaderLine('User-Agent'));
+            (new SubscribeLog())->add($user, $subtype, $request->getHeaderLine('User-Agent'));
         }
 
         return $response->withHeader('Subscription-Userinfo', $sub_details)
@@ -127,7 +127,7 @@ final class SubController extends BaseController
 
         // 记录订阅日志
         if ($_ENV['subscribeLog']) {
-            SubscribeLog::add($user, $sub_type, $request->getHeaderLine('User-Agent'));
+            (new SubscribeLog())->add($user, $sub_type, $request->getHeaderLine('User-Agent'));
         }
 
         $sub_details = ' upload=' . $user->u

+ 2 - 0
src/Controllers/UserController.php

@@ -141,6 +141,7 @@ final class UserController extends BaseController
     public function logout(ServerRequest $request, Response $response, array $args): Response
     {
         Auth::logout();
+
         return $response->withStatus(302)->withHeader('Location', '/');
     }
 
@@ -152,6 +153,7 @@ final class UserController extends BaseController
 
         if (Setting::obtain('enable_checkin_captcha')) {
             $ret = Captcha::verify($request->getParams());
+
             if (! $ret) {
                 return ResponseHelper::error($response, '系统无法接受你的验证结果,请刷新页面后重试');
             }

+ 1 - 1
src/Controllers/WebAPI/FuncController.php

@@ -25,7 +25,7 @@ final class FuncController extends BaseController
     {
         $rules = DetectRule::all();
 
-        return ResponseHelper::etagJson($request, $response, [
+        return ResponseHelper::successWithDataEtag($request, $response, [
             'ret' => 1,
             'data' => $rules,
         ]);

+ 1 - 1
src/Controllers/WebAPI/NodeController.php

@@ -40,7 +40,7 @@ final class NodeController extends BaseController
             'version' => VERSION,
         ];
 
-        return ResponseHelper::etagJson($request, $response, [
+        return ResponseHelper::successWithDataEtag($request, $response, [
             'ret' => 1,
             'data' => $data,
         ]);

+ 1 - 1
src/Controllers/WebAPI/UserController.php

@@ -124,7 +124,7 @@ final class UserController extends BaseController
             $users[] = $user_raw;
         }
 
-        return ResponseHelper::etagJson($request, $response, [
+        return ResponseHelper::successWithDataEtag($request, $response, [
             'ret' => 1,
             'data' => $users,
         ]);

+ 20 - 1
src/Models/LoginIp.php

@@ -4,6 +4,8 @@ declare(strict_types=1);
 
 namespace App\Models;
 
+use function time;
+
 /**
  * Ip Model
  */
@@ -21,7 +23,7 @@ final class LoginIp extends Model
     }
 
     /**
-     * 登录用户
+     * 登录用户
      */
     public function userName(): string
     {
@@ -35,4 +37,21 @@ final class LoginIp extends Model
     {
         return $this->type === 0 ? '成功' : '失败';
     }
+
+    /**
+     * 记录登录 IP
+     *
+     * @param string $ip   IP 地址
+     * @param int    $type 登录失败为 1
+     *
+     * @return void
+     */
+    public function collectInvalidUserLoginIP(string $ip, int $type = 0): void
+    {
+        $this->ip = $ip;
+        $this->userid = 0;
+        $this->datetime = time();
+        $this->type = $type;
+        $this->save();
+    }
 }

+ 1 - 0
src/Models/Model.php

@@ -17,6 +17,7 @@ abstract class Model extends EloquentModel
     public static function getTableName(): string
     {
         $class = static::class;
+
         return (new $class())->getTable();
     }
 }

+ 16 - 16
src/Models/Payback.php

@@ -33,23 +33,23 @@ final class Payback extends Model
             User::where('id', $this->ref_by)->first()->user_name;
     }
 
-    public static function rebate($user_id, $order_amount): void
+    public function rebate($user_id, $order_amount): void
     {
         $configs = Setting::getClass('invite');
         $user = User::where('id', $user_id)->first();
         $gift_user_id = $user->ref_by;
-
         // 判断
         $invite_rebate_mode = (string) $configs['invite_rebate_mode'];
 
         if ($invite_rebate_mode === 'continued') {
             // 不设限制
-            self::executeRebate($user_id, $gift_user_id, $order_amount);
+            $this->execute($user_id, $gift_user_id, $order_amount);
         } elseif ($invite_rebate_mode === 'limit_frequency') {
             // 限制返利次数
             $rebate_frequency = self::where('userid', $user_id)->count();
+
             if ($rebate_frequency < $configs['rebate_frequency_limit']) {
-                self::executeRebate($user_id, $gift_user_id, $order_amount);
+                $this->execute($user_id, $gift_user_id, $order_amount);
             }
         } elseif ($invite_rebate_mode === 'limit_amount') {
             // 限制返利金额
@@ -61,20 +61,21 @@ final class Payback extends Model
                 && $total_rebate_amount <= $configs['rebate_amount_limit']
             ) {
                 $adjust_rebate = $configs['rebate_amount_limit'] - $total_rebate_amount;
+
                 if ($adjust_rebate > 0) {
-                    self::executeRebate($user_id, $gift_user_id, $order_amount, $adjust_rebate);
+                    $this->execute($user_id, $gift_user_id, $order_amount, $adjust_rebate);
                 }
             } else {
-                self::executeRebate($user_id, $gift_user_id, $order_amount);
+                $this->execute($user_id, $gift_user_id, $order_amount);
             }
         } elseif ($invite_rebate_mode === 'limit_time_range') {
             if (strtotime($user->reg_date) + $configs['rebate_time_range_limit'] * 86400 > time()) {
-                self::executeRebate($user_id, $gift_user_id, $order_amount);
+                $this->execute($user_id, $gift_user_id, $order_amount);
             }
         }
     }
 
-    public static function executeRebate($user_id, $gift_user_id, $order_amount, $adjust_rebate = null): void
+    public function execute($user_id, $gift_user_id, $order_amount, $adjust_rebate = null): void
     {
         $gift_user = User::where('id', $gift_user_id)->first();
 
@@ -92,14 +93,13 @@ final class Payback extends Model
                 $adjust_rebate ?? $rebate_amount,
                 '邀请用户 #' . $user_id . ' 返利',
             );
-            // 记录
-            $payback = new Payback();
-            $payback->total = $order_amount;
-            $payback->userid = $user_id;
-            $payback->ref_by = $gift_user_id;
-            $payback->ref_get = $adjust_rebate ?? $rebate_amount;
-            $payback->datetime = time();
-            $payback->save();
+            // 添加记录
+            $this->total = $order_amount;
+            $this->userid = $user_id;
+            $this->ref_by = $gift_user_id;
+            $this->ref_get = $adjust_rebate ?? $rebate_amount;
+            $this->datetime = time();
+            $this->save();
         }
     }
 }

+ 9 - 9
src/Models/SubscribeLog.php

@@ -5,6 +5,7 @@ declare(strict_types=1);
 namespace App\Models;
 
 use App\Utils\Tools;
+use Exception;
 use MaxMind\Db\Reader\InvalidDatabaseException;
 use voku\helper\AntiXSS;
 use function time;
@@ -29,7 +30,7 @@ final class SubscribeLog extends Model
     {
         try {
             return Tools::getIpLocation($this->request_ip);
-        } catch (InvalidDatabaseException $e) {
+        } catch (InvalidDatabaseException|Exception $e) {
             return '未知';
         }
     }
@@ -37,15 +38,14 @@ final class SubscribeLog extends Model
     /**
      * 记录订阅日志
      */
-    public static function add(User $user, string $type, string $ua): void
+    public function add(User $user, string $type, string $ua): void
     {
-        $log = new SubscribeLog();
         $antiXss = new AntiXSS();
-        $log->user_id = $user->id;
-        $log->type = $antiXss->xss_clean($type);
-        $log->request_ip = $_SERVER['REMOTE_ADDR'];
-        $log->request_user_agent = $antiXss->xss_clean($ua);
-        $log->request_time = time();
-        $log->save();
+        $this->user_id = $user->id;
+        $this->type = $antiXss->xss_clean($type);
+        $this->request_ip = $_SERVER['REMOTE_ADDR'];
+        $this->request_user_agent = $antiXss->xss_clean($ua);
+        $this->request_time = time();
+        $this->save();
     }
 }

+ 3 - 0
src/Models/User.php

@@ -393,7 +393,10 @@ final class User extends Model
     /**
      * 记录登录 IP
      *
+     * @param string $ip   IP 地址
      * @param int    $type 登录失败为 1
+     *
+     * @return bool
      */
     public function collectLoginIP(string $ip, int $type = 0): bool
     {

+ 1 - 1
src/Services/Gateway/AbstractPayment.php

@@ -78,7 +78,7 @@ abstract class AbstractPayment
 
         // 返利
         if ($user->ref_by > 0 && Setting::obtain('invitation_mode') === 'after_paid') {
-            Payback::rebate($user->id, $paylist->total);
+            (new Payback())->rebate($user->id, $paylist->total);
         }
 
         return 0;

+ 4 - 0
src/Utils/Hash.php

@@ -25,12 +25,14 @@ final class Hash
         if (in_array($_ENV['pwdMethod'], ['bcrypt', 'argon2i', 'argon2id'])) {
             return password_verify($password, $hashedPassword);
         }
+
         return $hashedPassword === self::passwordHash($password);
     }
 
     public static function passwordHash($pass): string
     {
         $method = $_ENV['pwdMethod'];
+
         return match ($method) {
             'md5' => self::md5WithSalt($pass),
             'sha256' => self::sha256WithSalt($pass),
@@ -43,12 +45,14 @@ final class Hash
     public static function md5WithSalt($pwd): string
     {
         $salt = $_ENV['salt'];
+
         return md5($pwd . $salt);
     }
 
     public static function sha256WithSalt($pwd): string
     {
         $salt = $_ENV['salt'];
+
         return hash('sha256', $pwd . $salt);
     }
 }

+ 15 - 1
src/Utils/ResponseHelper.php

@@ -20,6 +20,13 @@ final class ResponseHelper
         ]);
     }
 
+    /**
+     * @param Response $response
+     * @param string $msg
+     * @param array $data
+     *
+     * @return ResponseInterface
+     */
     public static function successWithData(Response $response, string $msg, array $data): ResponseInterface
     {
         return $response->withJson([
@@ -37,6 +44,13 @@ final class ResponseHelper
         ]);
     }
 
+    /**
+     * @param Response $response
+     * @param string $msg
+     * @param array $data
+     *
+     * @return ResponseInterface
+     */
     public static function errorWithData(Response $response, string $msg, array $data): ResponseInterface
     {
         return $response->withJson([
@@ -57,7 +71,7 @@ final class ResponseHelper
      *
      * @return ResponseInterface
      */
-    public static function etagJson(
+    public static function successWithDataEtag(
         RequestInterface $request,
         ResponseInterface $response,
         mixed $data