Explorar el Código

Merge pull request #2078 from sspanel-uim/dev

Dev 20230712
M1Screw hace 2 años
padre
commit
6bddfb85c1

+ 18 - 18
composer.lock

@@ -123,16 +123,16 @@
         },
         {
             "name": "aws/aws-sdk-php",
-            "version": "3.275.5",
+            "version": "3.275.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/aws/aws-sdk-php.git",
-                "reference": "d46961b82e857f77059c0c78160719ecb26f6cc6"
+                "reference": "a048b1d7110f62fb67cc69b93efc24e62ea8b64b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d46961b82e857f77059c0c78160719ecb26f6cc6",
-                "reference": "d46961b82e857f77059c0c78160719ecb26f6cc6",
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/a048b1d7110f62fb67cc69b93efc24e62ea8b64b",
+                "reference": "a048b1d7110f62fb67cc69b93efc24e62ea8b64b",
                 "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.275.5"
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.275.6"
             },
-            "time": "2023-07-07T18:20:11+00:00"
+            "time": "2023-07-11T04:45:11+00:00"
         },
         {
             "name": "bacon/bacon-qr-code",
@@ -2834,16 +2834,16 @@
         },
         {
             "name": "php-http/discovery",
-            "version": "1.19.0",
+            "version": "1.19.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/php-http/discovery.git",
-                "reference": "1856a119a0b0ba8da8b5c33c080aa7af8fac25b4"
+                "reference": "57f3de01d32085fea20865f9b16fb0e69347c39e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/php-http/discovery/zipball/1856a119a0b0ba8da8b5c33c080aa7af8fac25b4",
-                "reference": "1856a119a0b0ba8da8b5c33c080aa7af8fac25b4",
+                "url": "https://api.github.com/repos/php-http/discovery/zipball/57f3de01d32085fea20865f9b16fb0e69347c39e",
+                "reference": "57f3de01d32085fea20865f9b16fb0e69347c39e",
                 "shasum": ""
             },
             "require": {
@@ -2906,9 +2906,9 @@
             ],
             "support": {
                 "issues": "https://github.com/php-http/discovery/issues",
-                "source": "https://github.com/php-http/discovery/tree/1.19.0"
+                "source": "https://github.com/php-http/discovery/tree/1.19.1"
             },
-            "time": "2023-06-19T08:45:36+00:00"
+            "time": "2023-07-11T07:02:26+00:00"
         },
         {
             "name": "php-http/guzzle7-adapter",
@@ -8363,16 +8363,16 @@
         },
         {
             "name": "phpunit/phpunit",
-            "version": "10.2.3",
+            "version": "10.2.4",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "35c8cac1734ede2ae354a6644f7088356ff5b08e"
+                "reference": "68484779b5a2ed711fbdeba6ca01910d87acdff2"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/35c8cac1734ede2ae354a6644f7088356ff5b08e",
-                "reference": "35c8cac1734ede2ae354a6644f7088356ff5b08e",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/68484779b5a2ed711fbdeba6ca01910d87acdff2",
+                "reference": "68484779b5a2ed711fbdeba6ca01910d87acdff2",
                 "shasum": ""
             },
             "require": {
@@ -8444,7 +8444,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.2.3"
+                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.2.4"
             },
             "funding": [
                 {
@@ -8460,7 +8460,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2023-06-30T06:17:38+00:00"
+            "time": "2023-07-10T04:06:08+00:00"
         },
         {
             "name": "psr/cache",

+ 0 - 0
db/update.sql → db/2022.12_to_2022.12.1.sql


+ 0 - 1
db/migrations/2023060300-add_user_locale_and_update_data_type.php

@@ -14,7 +14,6 @@ return new class() implements MigrationInterface {
         ALTER TABLE user MODIFY COLUMN `email` varchar(255) NOT NULL COMMENT 'Email';
         ALTER TABLE user MODIFY COLUMN `pass` varchar(255) NOT NULL COMMENT '登录密码';
         ALTER TABLE user MODIFY COLUMN `passwd` varchar(255) NOT NULL COMMENT '节点密码';
-        ALTER TABLE user MODIFY COLUMN `t` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '最后使用时间';
         ALTER TABLE user MODIFY COLUMN `u` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前上传流量';
         ALTER TABLE user MODIFY COLUMN `d` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前下载流量';
         ALTER TABLE user MODIFY COLUMN `transfer_today` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户今日所用流量';

+ 0 - 12
db/migrations/2023061800-update_new_shop_data_type.php

@@ -43,11 +43,6 @@ return new class() implements MigrationInterface {
         ALTER TABLE email_queue MODIFY COLUMN `template` varchar(255) NOT NULL DEFAULT '' COMMENT '邮件模板';
         ALTER TABLE email_queue MODIFY COLUMN `array` longtext NOT NULL DEFAULT '{}' COMMENT '模板参数' CHECK (json_valid(`array`));
         ALTER TABLE email_queue MODIFY COLUMN `time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '添加时间';
-        ALTER TABLE email_verify MODIFY COLUMN `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID';
-        ALTER TABLE email_verify MODIFY COLUMN `email` varchar(255) NOT NULL DEFAULT '' COMMENT '邮箱';
-        ALTER TABLE email_verify MODIFY COLUMN `ip` varchar(255) NOT NULL DEFAULT '' COMMENT 'IP';
-        ALTER TABLE email_verify MODIFY COLUMN `code` varchar(255) NOT NULL DEFAULT '' COMMENT '验证码';
-        ALTER TABLE email_verify MODIFY COLUMN `expire_in` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '过期时间';
         ALTER TABLE gift_card MODIFY COLUMN `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '礼品卡ID';
         ALTER TABLE gift_card MODIFY COLUMN `card` text NOT NULL DEFAULT '' COMMENT '卡号';
         ALTER TABLE gift_card MODIFY COLUMN `balance` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '余额';
@@ -177,13 +172,6 @@ return new class() implements MigrationInterface {
         ALTER TABLE user_invite_code MODIFY COLUMN `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '创建时间';
         ALTER TABLE user_invite_code MODIFY COLUMN `updated_at` timestamp NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '更新时间';
         ALTER TABLE user_money_log MODIFY COLUMN `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID';
-        ALTER TABLE user_password_reset MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '记录ID';
-        ALTER TABLE user_password_reset MODIFY COLUMN `email` varchar(255) NOT NULL DEFAULT '' COMMENT '用户邮箱';
-        ALTER TABLE user_password_reset MODIFY COLUMN `token` varchar(255) NOT NULL DEFAULT '' COMMENT '重置密码的 token';
-        ALTER TABLE user_password_reset MODIFY COLUMN `init_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间';
-        ALTER TABLE user_password_reset MODIFY COLUMN `expire_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '过期时间';
-        ALTER TABLE user_password_reset ADD KEY IF NOT EXISTS `email` (`email`);
-        ALTER TABLE user_password_reset ADD KEY IF NOT EXISTS `token` (`token`);
         ALTER TABLE user_subscribe_log MODIFY COLUMN `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID';
         ALTER TABLE user_subscribe_log MODIFY COLUMN `user_name` varchar(255) NOT NULL DEFAULT '' COMMENT '用户名';
         ALTER TABLE user_subscribe_log MODIFY COLUMN `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID';

+ 85 - 81
public/assets/js/fuck.js

@@ -1,100 +1,104 @@
 (function (window, navigator) {
-  var userAgent = navigator.userAgent;
-  var is360 = false;
+    const userAgent = navigator.userAgent;
+    let is360 = false;
 
-  var hasMime = function (option, value) {
-    var mimeTypes = navigator.mimeTypes;
-    for (var mt in mimeTypes) {
-      if (mimeTypes[mt][option] == value) {
-        return true;
-      }
+    const hasMime = function (option, value) {
+        const mimeTypes = navigator.mimeTypes;
+        for (const mt in mimeTypes) {
+            if (mimeTypes[mt][option] == value) {
+                return true;
+            }
+        }
+        return false;
+    };
+
+    const matchUserAgent = function (string) {
+        return userAgent.indexOf(string) > -1;
+    };
+
+    if (
+        matchUserAgent('QihooBrowser') ||
+        matchUserAgent('QHBrowser') ||
+        matchUserAgent('Qihoo') ||
+        matchUserAgent('QIHU') ||
+        matchUserAgent('360browser') ||
+        matchUserAgent('360EE') ||
+        matchUserAgent('360SE')
+    ) {
+        is360 = true;
     }
-    return false;
-  };
 
-  var matchUserAgent = function (string) {
-    return userAgent.indexOf(string) > -1;
-  };
+    if (
+        hasMime('type', 'application/gameplugin') ||
+        hasMime('type', 'application/360softmgrplugin') ||
+        hasMime('type', 'application/mozilla-npqihooquicklogin')
+    ) {
+        is360 = true;
+    }
 
-  if (
-    matchUserAgent('QihooBrowser') ||
-    matchUserAgent('QHBrowser') ||
-    matchUserAgent('Qihoo') ||
-    matchUserAgent('QIHU') ||
-    matchUserAgent('360browser') ||
-    matchUserAgent('360EE') ||
-    matchUserAgent('360SE')
-  ) {
-    is360 = true;
-  }
+    if (window.chrome) {
+        const chrome_version = userAgent.replace(/^.*Chrome\/([\d]+).*$/, '$1');
 
-  if (
-    hasMime('type', 'application/gameplugin') ||
-    hasMime('type', 'application/360softmgrplugin') ||
-    hasMime('type', 'application/mozilla-npqihooquicklogin')
-  ) {
-    is360 = true;
-  }
+        if (chrome_version > 36 && window.showModalDialog) {
+            is360 = true;
+        }
 
-  if (window.chrome) {
-    var chrome_version = userAgent.replace(/^.*Chrome\/([\d]+).*$/, '$1');
+        if (chrome_version > 45) {
+            if (hasMime('type', 'application/vnd.chromium.remoting-viewer')) {
+                is360 = true;
+            }
+        }
 
-    if (chrome_version > 36 && window.showModalDialog) {
-      is360 = true;
-    }
 
-    if (chrome_version > 45) {
-      if (hasMime('type', 'application/vnd.chromium.remoting-viewer')) {
-        is360 = true;
-      }
+        if (!is360 && chrome_version > 69) {
+            if (
+                hasMime('type', 'application/hwepass2001.installepass2001') ||
+                hasMime('type', 'application/asx')
+            ) {
+                is360 = true;
+            }
+        }
     }
 
-
-    if (!is360 && chrome_version > 69) {
-      if (
-        hasMime('type', 'application/hwepass2001.installepass2001') ||
-        hasMime('type', 'application/asx')
-      ) {
+    if (
+        navigator &&
+        typeof navigator['connection'] !== 'undefined' &&
+        typeof navigator['connection']['saveData'] == 'undefined'
+    ) {
         is360 = true;
-      }
     }
-  }
 
-  if (
-    navigator &&
-    typeof navigator['connection'] !== 'undefined' &&
-    typeof navigator['connection']['saveData'] == 'undefined'
-  ) {
-    is360 = true;
-  }
+    for (const key in navigator.plugins) {
+        if (navigator.plugins[key].filename == 'internal-nacl-plugin') {
+            is360 = true;
+        }
+    }
 
-  if (
-    matchUserAgent('MSIE') ||
-    matchUserAgent('Trident') ||
-    matchUserAgent('Edge') ||
-    matchUserAgent('Edg/')
-  ) {
-    var navigator_top = window.screenTop - window.screenY;
-    switch (navigator_top) {
-      case 71: // 无收藏栏 贴边
-      case 99: // 有收藏栏 贴边
-      case 102: // 有收藏栏 非贴边
-        is360 = true;
-        break;
-      case 75: // 无收藏栏 贴边
-      case 105: // 有收藏栏 贴边
-      case 104: // 有收藏栏 非贴边
-        is360 = true;
-        break;
+    if (
+        matchUserAgent('MSIE') ||
+        matchUserAgent('Trident') ||
+        matchUserAgent('Edge') ||
+        matchUserAgent('Edg/')
+    ) {
+        const navigator_top = window.screenTop - window.screenY;
+        switch (navigator_top) {
+            case 71: // 无收藏栏 贴边
+            case 75: // 无收藏栏 贴边
+            case 99: // 有收藏栏 贴边
+            case 102: // 有收藏栏 非贴边
+            case 104: // 有收藏栏 非贴边
+            case 105: // 有收藏栏 贴边
+                is360 = true;
+            break;
+        }
     }
-  }
 
-  var redirectUrl = "https://www.mozilla.org/en-US/firefox/new/";
+    const redirectUrl = "https://www.mozilla.org/en-US/firefox/new/";
 
-  if (is360) {
-    setTimeout(function() {
-        window.alert('检测到 360 浏览器访问\n请使用 Firefox 浏览器');
-        window.location.href = redirectUrl;
-    }, 0);
-  }
+    if (is360) {
+        setTimeout(function () {
+            window.alert('检测到 360 浏览器访问\n请使用 Firefox 浏览器');
+            window.location.href = redirectUrl;
+        }, 0);
+    }
 })(window, navigator);

+ 1 - 1
public/assets/js/fuck.min.js

@@ -1 +1 @@
-(function(a,b){var c=b.userAgent,d=!1,e=function(a,c){var d=b.mimeTypes;for(var e in d)if(d[e][a]==c)return!0;return!1},f=function(a){return-1<c.indexOf(a)};if((f("QihooBrowser")||f("QHBrowser")||f("Qihoo")||f("QIHU")||f("360browser")||f("360EE")||f("360SE"))&&(d=!0),(e("type","application/gameplugin")||e("type","application/360softmgrplugin")||e("type","application/mozilla-npqihooquicklogin"))&&(d=!0),a.chrome){var g=c.replace(/^.*Chrome\/([\d]+).*$/,"$1");36<g&&a.showModalDialog&&(d=!0),45<g&&e("type","application/vnd.chromium.remoting-viewer")&&(d=!0),!d&&69<g&&(e("type","application/hwepass2001.installepass2001")||e("type","application/asx"))&&(d=!0)}if(b&&"undefined"!=typeof b.connection&&"undefined"==typeof b.connection.saveData&&(d=!0),f("MSIE")||f("Trident")||f("Edge")||f("Edg/")){var h=a.screenTop-a.screenY;71==h||99===h||102===h?d=!0:75===h||105===h||104===h?d=!0:void 0}d&&setTimeout(function(){a.alert("\u68C0\u6D4B\u5230 360 \u6D4F\u89C8\u5668\u8BBF\u95EE\n\u8BF7\u4F7F\u7528 Firefox \u6D4F\u89C8\u5668"),a.location.href="https://www.mozilla.org/en-US/firefox/new/"},0)})(window,navigator);
+(function(a,b){const c=b.userAgent;let d=!1;const e=function(a,c){const d=b.mimeTypes;for(const b in d)if(d[b][a]==c)return!0;return!1},f=function(a){return-1<c.indexOf(a)};if((f("QihooBrowser")||f("QHBrowser")||f("Qihoo")||f("QIHU")||f("360browser")||f("360EE")||f("360SE"))&&(d=!0),(e("type","application/gameplugin")||e("type","application/360softmgrplugin")||e("type","application/mozilla-npqihooquicklogin"))&&(d=!0),a.chrome){const b=c.replace(/^.*Chrome\/([\d]+).*$/,"$1");36<b&&a.showModalDialog&&(d=!0),45<b&&e("type","application/vnd.chromium.remoting-viewer")&&(d=!0),!d&&69<b&&(e("type","application/hwepass2001.installepass2001")||e("type","application/asx"))&&(d=!0)}for(const c in b&&"undefined"!=typeof b.connection&&"undefined"==typeof b.connection.saveData&&(d=!0),b.plugins)"internal-nacl-plugin"==b.plugins[c].filename&&(d=!0);if(f("MSIE")||f("Trident")||f("Edge")||f("Edg/")){const b=a.screenTop-a.screenY;71==b||75===b||99===b||102===b||104===b||105===b?d=!0:void 0}d&&setTimeout(function(){a.alert("\u68C0\u6D4B\u5230 360 \u6D4F\u89C8\u5668\u8BBF\u95EE\n\u8BF7\u4F7F\u7528 Firefox \u6D4F\u89C8\u5668"),a.location.href="https://www.mozilla.org/en-US/firefox/new/"},0)})(window,navigator);

+ 0 - 90
src/Services/DB.php

@@ -4,99 +4,9 @@ declare(strict_types=1);
 
 namespace App\Services;
 
-use Closure;
 use Exception;
-use Generator;
-use Illuminate\Contracts\Events\Dispatcher;
 use Illuminate\Database\Capsule\Manager;
-use Illuminate\Database\Connection;
-use Illuminate\Database\DatabaseTransactionsManager;
-use Illuminate\Database\Grammar;
-use Illuminate\Database\Query\Builder;
-use Illuminate\Database\Query\Expression;
-use Illuminate\Database\Query\Grammars\Grammar as QueryGrammar;
-use Illuminate\Database\Query\Processors\Processor;
-use Illuminate\Database\Schema\Builder as SchemaBuilder;
-use PDO;
-use PDOStatement;
 
-/**
- * @codingStandardsIgnoreStart
- *
- * @see Connection
- *
- * @method static void              useDefaultQueryGrammar()                                                Set the query grammar to the default implementation.
- * @method static void              useDefaultSchemaGrammar()                                               Set the schema grammar to the default implementation.
- * @method static void              useDefaultPostProcessor()                                               Set the query post processor to the default implementation.
- * @method static SchemaBuilder     getSchemaBuilder()                                                      Get a schema builder instance for the connection.
- * @method static Builder           table(Closure|Builder|string $table, string|null $as = null)            Begin a fluent query against a database table.
- * @method static Builder           query()                                                                 Get a new query builder instance.
- * @method static mixed             selectOne(string $query, array $bindings = [], bool $useReadPdo = true) Run a select statement and return a single result.
- * @method static array             selectFromWriteConnection(string $query, array $bindings = [])          Run a select statement against the database.
- * @method static array             select(string $query, array $bindings = [], bool $useReadPdo = true)    Run a select statement against the database.
- * @method static Generator        cursor(string $query, array $bindings = [], bool $useReadPdo = true)    Run a select statement against the database and returns a generator.
- * @method static bool              insert(string $query, array $bindings = [])                             Run an insert statement against the database.
- * @method static int               update(string $query, array $bindings = [])                             Run an update statement against the database.
- * @method static int               delete(string $query, array $bindings = [])                             Run a delete statement against the database.
- * @method static bool              statement(string $query, array $bindings = [])                          Execute an SQL statement and return the boolean result.
- * @method static int               affectingStatement(string $query, array $bindings = [])                 Run an SQL statement and get the number of rows affected.
- * @method static bool              unprepared($query)                                                      Run a raw, unprepared query against the PDO connection.
- * @method static array             pretend(Closure $callback)                                              Execute the given callback in "dry run" mode.
- * @method static void              bindValues(PDOStatement $statement, array $bindings)                   Bind values to their parameters in the given statement.
- * @method static array             prepareBindings(array $bindings)                                        Prepare the query bindings for execution.
- * @method static void              logQuery(string $query, array $bindings, float|null $time = null)       Log a query in the connection's query log.
- * @method static void              reconnect()                                                             Reconnect to the database.
- * @method static void              disconnect()                                                            Disconnect from the underlying PDO connection.
- * @method static void              listen(Closure $callback)                                               Register a database query listener with the connection.
- * @method static Expression        raw($value)                                                             Get a new raw query expression.
- * @method static void              recordsHaveBeenModified(bool $value = true)                             Indicate if any records have been modified.
- * @method static void              forgetRecordModificationState()                                         Reset the record modification state.
- * ---- Method about Doctrine which is not available should be here. -----
- * @method static PDO               getPdo()                                                                Get the current PDO connection.
- * @method static PDO|Closure|null  getRawPdo()                                                             Get the current PDO connection parameter without executing any reconnect logic.
- * @method static PDO               getReadPdo()                                                            Get the current PDO connection used for reading.
- * @method static PDO|Closure|null  getRawReadPdo()                                                         Get the current read PDO connection parameter without executing any reconnect logic.
- * @method static Connection        setPdo(PDO|Closure|null $pdo)                                           Set the PDO connection.
- * @method static Connection        setReconnector(callable $reconnector)                                   Set the reconnect instance on the connection.
- * @method static string|null       getName()                                                               Get the database connection name.
- * @method static mixed             getConfig(string|null $option = null)                                   Get an option from the configuration options.
- * @method static string            getDriverName()                                                         Get the PDO driver name.
- * @method static QueryGrammar      getQueryGrammar()                                                       Get the query grammar used by the connection.
- * @method static Connection        setQueryGrammar(QueryGrammar $grammar)                                  Set the query grammar used by the connection.
- * @method static QueryGrammar      getSchemaGrammar()                                                      Get the schema grammar used by the connection.
- * @method static Connection        setSchemaGrammar(QueryGrammar $grammar)                                 Set the schema grammar used by the connection.
- * @method static Processor         getPostProcessor()                                                      Get the query post processor used by the connection.
- * @method static Connection        setPostProcessor(Processor $processor)                                  Set the query post processor used by the connection.
- * @method static Dispatcher        getEventDispatcher()                                                    Get the event dispatcher used by the connection.
- * @method static Connection        setEventDispatcher(Dispatcher $events)                                  Set the event dispatcher instance on the connection.
- * @method static void              unsetEventDispatcher()                                                  Unset the event dispatcher for this connection.
- * @method static Connection        setTransactionManager(DatabaseTransactionsManager $manager)             Set the transaction manager instance on the connection.
- * @method static void              unsetTransactionManager()                                               Unset the transaction manager for this connection.
- * @method static bool              pretending()                                                            Determine if the connection is in a "dry run".
- * @method static array             getQueryLog()                                                           Get the connection query log.
- * @method static void              flushQueryLog()                                                         Clear the query log.
- * @method static void              enableQueryLog()                                                        Enable the query log on the connection.
- * @method static void              disableQueryLog()                                                       Disable the query log on the connection.
- * @method static bool              logging()                                                               Determine whether we're logging queries.
- * @method static string            getDatabaseName()                                                       Get the name of the connected database.
- * @method static Connection        setDatabaseName(string $database)                                       Set the name of the connected database.
- * @method static string            getTablePrefix()                                                        Get the table prefix for the connection.
- * @method static Connection        setTablePrefix(string $prefix)                                          Set the table prefix in use by the connection.
- * @method static Grammar           withTablePrefix(Grammar $grammar)                                       Set the table prefix and return the grammar.
- * @method static void              resolverFor(string $driver, Closure $callback)                          Register a connection resolver.
- * @method static mixed             getResolver(string $driver) Get the connection                          resolver for the given driver.
- *
- * @see \Illuminate\Database\Concerns\ManagesTransactions
- *
- * @method static mixed             transaction(Closure $callback, int $attempts = 1)                       Execute a Closure within a transaction.
- * @method static void              beginTransaction()                                                      Start a new database transaction.
- * @method static void              commit()                                                                Commit the active database transaction.
- * @method static void              rollBack(int|null $toLevel = null)                                      Rollback the active database transaction.
- * @method static int               transactionLevel()                                                      Get the number of active transactions.
- * @method static void              afterCommit(callable $callback)                                         Execute the callback after a transaction commits.
- *
- * @codingStandardsIgnoreEnd
- */
 final class DB extends Manager
 {
     public static function init(): void

+ 16 - 3
src/Utils/QRcode.php

@@ -4,7 +4,9 @@ declare(strict_types=1);
 
 namespace App\Utils;
 
+use Exception;
 use Zxing\QrReader;
+use function file_get_contents;
 
 final class QRcode
 {
@@ -17,12 +19,23 @@ final class QRcode
      */
     public static function decode(string $source): ?string
     {
+        if (! file_exists($source)) {
+            return null;
+        }
+
         $img = file_get_contents($source);
-        $qrcode = new QrReader($img, QrReader::SOURCE_TYPE_BLOB);
-        $text = $qrcode->text();
-        if ($text === false || $text === '') {
+
+        try {
+            $qrcode = new QrReader($img, QrReader::SOURCE_TYPE_BLOB);
+            $text = $qrcode->text();
+        } catch (Exception $e) {
+            $text = '';
+        }
+
+        if ($text === '') {
             return null;
         }
+
         return $text;
     }
 }

+ 161 - 0
tests/App/Services/ConfigTest.php

@@ -0,0 +1,161 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Services;
+
+use PHPUnit\Framework\TestCase;
+use App\Services\Config;
+
+class ConfigTest extends TestCase
+{
+    /**
+     * @covers App\Services\Config::getPublicConfig
+     */
+    public function testGetPublicConfig(): void
+    {
+        $_ENV = [
+            'appName' => 'My App',
+            'baseUrl' => 'https://example.com',
+            'enable_checkin' => true,
+            'checkinMin' => 10,
+            'checkinMax' => 20,
+            'jump_delay' => 5,
+            'enable_analytics_code' => false,
+            'enable_kill' => true,
+            'enable_change_email' => false,
+            'enable_telegram' => true,
+            'telegram_bot' => 'my_bot',
+            'subscribeLog' => true,
+            'subscribeLog_keep_days' => 30,
+            'enable_r2_client_download' => true,
+        ];
+
+        $mockEnv = [
+            'appName' => 'My App',
+            'baseUrl' => 'https://example.com',
+            'enable_checkin' => true,
+            'checkinMin' => 10,
+            'checkinMax' => 20,
+            'jump_delay' => 5,
+            'enable_analytics_code' => false,
+            'enable_kill' => true,
+            'enable_change_email' => false,
+            'enable_telegram' => true,
+            'telegram_bot' => 'my_bot',
+            'subscribeLog' => true,
+            'subscribeLog_keep_days' => 30,
+            'enable_r2_client_download' => true,
+        ];
+
+        $config = Config::getPublicConfig();
+
+        $this->assertSame($mockEnv['appName'], $config['appName']);
+        $this->assertSame($mockEnv['baseUrl'], $config['baseUrl']);
+        $this->assertSame($mockEnv['enable_checkin'], $config['enable_checkin']);
+        $this->assertSame($mockEnv['checkinMin'], $config['checkinMin']);
+        $this->assertSame($mockEnv['checkinMax'], $config['checkinMax']);
+        $this->assertSame($mockEnv['jump_delay'], $config['jump_delay']);
+        $this->assertSame($mockEnv['enable_analytics_code'], $config['enable_analytics_code']);
+        $this->assertSame($mockEnv['enable_kill'], $config['enable_kill']);
+        $this->assertSame($mockEnv['enable_change_email'], $config['enable_change_email']);
+        $this->assertSame($mockEnv['enable_telegram'], $config['enable_telegram']);
+        $this->assertSame($mockEnv['telegram_bot'], $config['telegram_bot']);
+        $this->assertSame($mockEnv['subscribeLog'], $config['subscribeLog']);
+        $this->assertSame($mockEnv['subscribeLog_keep_days'], $config['subscribeLog_keep_days']);
+        $this->assertSame($mockEnv['enable_r2_client_download'], $config['enable_r2_client_download']);
+    }
+
+    /**
+     * @covers App\Services\Config::getRedisConfig
+     */
+    public function testGetRedisConfig(): void
+    {
+        $_ENV = [
+            'redis_host' => 'localhost',
+            'redis_port' => 6379,
+            'redis_timeout' => 10,
+            'redis_username' => 'myuser',
+            'redis_password' => 'mypassword',
+            'redis_ssl' => false,
+        ];
+
+        $mockEnv = [
+            'redis_host' => 'localhost',
+            'redis_port' => 6379,
+            'redis_timeout' => 10,
+            'redis_username' => 'myuser',
+            'redis_password' => 'mypassword',
+            'redis_ssl' => false,
+        ];
+
+        $config = Config::getRedisConfig();
+
+        $this->assertSame($mockEnv['redis_host'], $config['host']);
+        $this->assertSame($mockEnv['redis_port'], $config['port']);
+        $this->assertSame($mockEnv['redis_timeout'], $config['connectTimeout']);
+        $this->assertSame([$mockEnv['redis_username'], $mockEnv['redis_password']], $config['auth']);
+        $this->assertSame(['verify_peer' => $mockEnv['redis_ssl']], $config['ssl']);
+    }
+
+    /**
+     * @covers App\Services\Config::getDbConfig
+     */
+    public function testGetDbConfig(): void
+    {
+        $_ENV = [
+            'db_driver' => 'mysql',
+            'db_host' => 'localhost',
+            'db_socket' => '/var/run/mysqld/mysqld.sock',
+            'db_database' => 'mydb',
+            'db_username' => 'myuser',
+            'db_password' => 'mypassword',
+            'db_charset' => 'utf8mb4',
+            'db_collation' => 'utf8mb4_unicode_ci',
+            'db_prefix' => '',
+            'db_port' => 3306,
+        ];
+
+        $mockEnv = [
+            'db_driver' => 'mysql',
+            'db_host' => 'localhost',
+            'db_socket' => '/var/run/mysqld/mysqld.sock',
+            'db_database' => 'mydb',
+            'db_username' => 'myuser',
+            'db_password' => 'mypassword',
+            'db_charset' => 'utf8mb4',
+            'db_collation' => 'utf8mb4_unicode_ci',
+            'db_prefix' => '',
+            'db_port' => 3306,
+        ];
+
+        $config = Config::getDbConfig();
+
+        $this->assertSame($mockEnv['db_driver'], $config['driver']);
+        $this->assertSame($mockEnv['db_host'], $config['host']);
+        $this->assertSame($mockEnv['db_socket'], $config['unix_socket']);
+        $this->assertSame($mockEnv['db_database'], $config['database']);
+        $this->assertSame($mockEnv['db_username'], $config['username']);
+        $this->assertSame($mockEnv['db_password'], $config['password']);
+        $this->assertSame($mockEnv['db_charset'], $config['charset']);
+        $this->assertSame($mockEnv['db_collation'], $config['collation']);
+        $this->assertSame($mockEnv['db_prefix'], $config['prefix']);
+        $this->assertSame($mockEnv['db_port'], $config['port']);
+    }
+
+    /**
+     * @covers App\Services\Config::getSupportParam
+     */
+    public function testGetSupportParam(): void
+    {
+        $params = Config::getSupportParam('ss_aead_method');
+
+        $this->assertIsArray($params);
+        $this->assertContains('aes-128-gcm', $params);
+        $this->assertContains('aes-192-gcm', $params);
+        $this->assertContains('aes-256-gcm', $params);
+        $this->assertContains('chacha20-ietf-poly1305', $params);
+        $this->assertContains('xchacha20-ietf-poly1305', $params);
+    }
+}
+

+ 36 - 0
tests/App/Utils/QRcodeTest.php

@@ -0,0 +1,36 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Utils;
+
+use App\Utils\QRcode;
+use PHPUnit\Framework\TestCase;
+
+class QRcodeTest extends TestCase
+{
+    /**
+     * @covers App\Utils\QRcode::decode
+     */
+    public function testDecodeWithValidData(): void
+    {
+        $qrCodeImg = __DIR__ . '/qrcode.png';
+        $expectedText = 'https://www.example.com';
+
+        $result = QRcode::decode($qrCodeImg);
+
+        $this->assertSame($expectedText, $result);
+    }
+
+    /**
+     * @covers App\Utils\QRcode::decode
+     */
+    public function testDecodeWithInvalidData(): void
+    {
+        $invalidImg = __DIR__ . '/invalid.png';
+
+        $result = QRcode::decode($invalidImg);
+
+        $this->assertNull($result);
+    }
+}

BIN
tests/App/Utils/qrcode.png