Explorar o código

feat: next panel specific update checker

Cat hai 1 ano
pai
achega
db6853ea0e

+ 1 - 1
LICENSE

@@ -1,6 +1,6 @@
 MIT License
 
-Copyright (c) 2023 NeXT Panel Team
+Copyright (c) 2024 NeXT Panel Team
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal

+ 1 - 2
README.md

@@ -5,8 +5,7 @@
 ![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/SSPanel-NeXT_NeXT-Panel-Dev/dev?server=https%3A%2F%2Fsonarcloud.io&style=flat-square)
 ![Sonar Coverage](https://img.shields.io/sonar/coverage/SSPanel-NeXT_NeXT-Panel-Dev/dev?server=https%3A%2F%2Fsonarcloud.io&style=flat-square)
 
-[![Main](https://img.shields.io/badge/Telegram-Release-blue?style=flat-square)](https://t.me/sspanel_next)
-[![Dev](https://img.shields.io/badge/Telegram-Dev-blue?style=flat-square)](https://t.me/sspanel_next_dev)
+[![X (formerly Twitter)](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FSSPanel_NeXT)](https://twitter.com/SSPanel_NeXT)
 [![Discord](https://img.shields.io/discord/1049692075085549600?color=5865F2&label=Discord&style=flat-square)](https://discord.gg/A7uFKCvf8V)
 
 ## TL;DR

+ 1 - 1
app/predefine.php

@@ -4,4 +4,4 @@ declare(strict_types=1);
 
 // Global constants
 const BASE_PATH = __DIR__ . '/..';
-const VERSION = '2024.1';
+const VERSION = '24.0.0';

+ 24 - 24
composer.lock

@@ -622,16 +622,16 @@
         },
         {
             "name": "aws/aws-sdk-php",
-            "version": "3.305.8",
+            "version": "3.306.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/aws/aws-sdk-php.git",
-                "reference": "aa08a9fd78c1091c7d9e1e3aff01204208ba8729"
+                "reference": "dc228b55a4224fe3160a0a2ca430b80c5348d943"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/aa08a9fd78c1091c7d9e1e3aff01204208ba8729",
-                "reference": "aa08a9fd78c1091c7d9e1e3aff01204208ba8729",
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/dc228b55a4224fe3160a0a2ca430b80c5348d943",
+                "reference": "dc228b55a4224fe3160a0a2ca430b80c5348d943",
                 "shasum": ""
             },
             "require": {
@@ -711,9 +711,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.305.8"
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.306.0"
             },
-            "time": "2024-05-02T18:25:26+00:00"
+            "time": "2024-05-06T18:11:49+00:00"
         },
         {
             "name": "bacon/bacon-qr-code",
@@ -7152,16 +7152,16 @@
         },
         {
             "name": "composer/xdebug-handler",
-            "version": "3.0.4",
+            "version": "3.0.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/composer/xdebug-handler.git",
-                "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255"
+                "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/4f988f8fdf580d53bdb2d1278fe93d1ed5462255",
-                "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255",
+                "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef",
+                "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef",
                 "shasum": ""
             },
             "require": {
@@ -7198,7 +7198,7 @@
             "support": {
                 "irc": "ircs://irc.libera.chat:6697/composer",
                 "issues": "https://github.com/composer/xdebug-handler/issues",
-                "source": "https://github.com/composer/xdebug-handler/tree/3.0.4"
+                "source": "https://github.com/composer/xdebug-handler/tree/3.0.5"
             },
             "funding": [
                 {
@@ -7214,7 +7214,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-03-26T18:29:49+00:00"
+            "time": "2024-05-06T16:37:16+00:00"
         },
         {
             "name": "dealerdirect/phpcodesniffer-composer-installer",
@@ -7349,16 +7349,16 @@
         },
         {
             "name": "friendsofphp/php-cs-fixer",
-            "version": "v3.54.0",
+            "version": "v3.55.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
-                "reference": "2aecbc8640d7906c38777b3dcab6f4ca79004d08"
+                "reference": "c9eeacb559bfa0bcc7f778cfb7b42715c83d2c7e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2aecbc8640d7906c38777b3dcab6f4ca79004d08",
-                "reference": "2aecbc8640d7906c38777b3dcab6f4ca79004d08",
+                "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/c9eeacb559bfa0bcc7f778cfb7b42715c83d2c7e",
+                "reference": "c9eeacb559bfa0bcc7f778cfb7b42715c83d2c7e",
                 "shasum": ""
             },
             "require": {
@@ -7430,7 +7430,7 @@
             ],
             "support": {
                 "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
-                "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.54.0"
+                "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.55.0"
             },
             "funding": [
                 {
@@ -7438,7 +7438,7 @@
                     "type": "github"
                 }
             ],
-            "time": "2024-04-17T08:12:13+00:00"
+            "time": "2024-05-06T00:10:15+00:00"
         },
         {
             "name": "justinrainbow/json-schema",
@@ -7996,16 +7996,16 @@
         },
         {
             "name": "phpstan/phpdoc-parser",
-            "version": "1.28.0",
+            "version": "1.29.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/phpstan/phpdoc-parser.git",
-                "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb"
+                "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb",
-                "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb",
+                "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/536889f2b340489d328f5ffb7b02bb6b183ddedc",
+                "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc",
                 "shasum": ""
             },
             "require": {
@@ -8037,9 +8037,9 @@
             "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.28.0"
+                "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.0"
             },
-            "time": "2024-04-03T18:51:33+00:00"
+            "time": "2024-05-06T12:04:23+00:00"
         },
         {
             "name": "phpunit/php-code-coverage",

+ 1 - 8
resources/views/tabler/admin/footer.tpl

@@ -93,18 +93,11 @@
             <div class="col-lg-auto ms-lg-auto">
                 <ul class="list-inline list-inline-dots mb-0">
                     <li class="list-inline-item">
-                        Powered by <a href="/staff" class="link-secondary">SSPanel-UIM</a>
+                        Powered by <a href="/staff" class="link-secondary">NeXT Panel</a>
                         <!-- 删除staff是不尊重每一位开发者的行为 -->
                     </li>
                 </ul>
             </div>
-            <div class="col-12 col-lg-auto mt-3 mt-lg-0">
-                <ul class="list-inline list-inline-dots mb-0">
-                    <li class="list-inline-item">
-                        Theme by <a href="https://tabler.io/" class="link-secondary">Tabler</a>
-                    </li>
-                </ul>
-            </div>
         </div>
     </div>
 </footer>

+ 11 - 6
resources/views/tabler/admin/system.tpl

@@ -23,7 +23,7 @@
                         <div class="card-body">
                             <table class="table table-transparent table-responsive">
                                 <tr>
-                                    <td>SSPanel-UIM 版本</td>
+                                    <td>NeXT Panel 版本</td>
                                     <td class="text-end" id="version"><a href="#" id="version_check">{$version} </a>
                                     </td>
                                 </tr>
@@ -50,12 +50,17 @@
                 type: 'POST',
                 dataType: "json",
                 success: function (data) {
-                    if (data.is_upto_date) {
-                        $('.badge').remove();
-                        $('#version').append('<span class="badge bg-green text-green-fg">已是最新版本</span>');
+                    if (data.ret === 1) {
+                        if (data.is_up_to_date) {
+                            $('.badge').remove();
+                            $('#version').append('<span class="badge bg-green text-green-fg">已是最新版本</span>');
+                        } else {
+                            $('.badge').remove();
+                            $('#version').append('<span class="badge bg-red text-red-fg">有新版本 ' + data.latest_version + ' 可用</span>');
+                        }
                     } else {
-                        $('.badge').remove();
-                        $('#version').append('<span class="badge bg-red text-red-fg">有新版本 ' + data.latest_version + ' 可用</span>');
+                        $('#fail-message').text(data.msg);
+                        $('#fail-dialog').modal('show');
                     }
                 }
             })

+ 3 - 5
resources/views/tabler/staff.tpl

@@ -5,7 +5,7 @@
     <div class="container-tight my-auto">
         <div class="empty">
             <p class="empty-title">MIT License</p>
-            <p class="empty-subtitle">&copy;2019 SSPanel UIM</p>
+            <p class="empty-subtitle">&copy;2024 NeXT Panel Team</p>
             <p>Permission is hereby granted, free of charge, to any person obtaining a copy
                 of this software and associated documentation files (the "Software"), to deal
                 in the Software without restriction, including without limitation the rights
@@ -24,11 +24,9 @@
                 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
                 SOFTWARE.</p>
             <br>
-            <p class="empty-title"><a href="https://wiki.sspanel.org/#/contributors">贡献者清单</a></p>
+            <p class="empty-title"><a href="https://github.com/SSPanel-NeXT/NeXT-Panel">GitHub Project</a></p>
             <br>
-            <p class="empty-title"><a href="https://github.com/SSPanel-UIM">GitHub Project</a></p>
-            <br>
-            <p class="empty-title">SSPanel-UIM 的存在离不开以下开源项目</p>
+            <p class="empty-title">NeXT Panel 的存在离不开以下开源项目</p>
             <p><a href="https://github.com/illuminate/database">Eloquent ORM</a></p>
             <p><a href="https://github.com/slimphp/Slim">Slim Framework</a></p>
             <p><a href="https://github.com/tabler/tabler">Tabler</a></p>

+ 1 - 8
resources/views/tabler/user/footer.tpl

@@ -52,18 +52,11 @@
             <div class="col-lg-auto ms-lg-auto">
                 <ul class="list-inline list-inline-dots mb-0">
                     <li class="list-inline-item">
-                        Powered by <a href="/staff" class="link-secondary">SSPanel-UIM</a>
+                        Powered by <a href="/staff" class="link-secondary">NeXT Panel</a>
                         <!-- 删除staff是不尊重每一位开发者的行为 -->
                     </li>
                 </ul>
             </div>
-            <div class="col-12 col-lg-auto mt-3 mt-lg-0">
-                <ul class="list-inline list-inline-dots mb-0">
-                    <li class="list-inline-item">
-                        Theme by <a href="https://tabler.io/" class="link-secondary">Tabler</a>
-                    </li>
-                </ul>
-            </div>
         </div>
     </div>
 </footer>

+ 22 - 13
src/Controllers/Admin/SystemController.php

@@ -6,13 +6,14 @@ namespace App\Controllers\Admin;
 
 use App\Controllers\BaseController;
 use App\Models\Config;
+use App\Utils\ResponseHelper;
 use App\Utils\Tools;
 use Exception;
+use GuzzleHttp\Client;
+use GuzzleHttp\Exception\GuzzleException;
 use Psr\Http\Message\ResponseInterface;
 use Slim\Http\Response;
 use Slim\Http\ServerRequest;
-use function file_get_contents;
-use function stream_context_create;
 use function version_compare;
 use const VERSION;
 
@@ -25,14 +26,11 @@ final class SystemController extends BaseController
      */
     public function index(ServerRequest $request, Response $response, array $args): ResponseInterface
     {
-        $last_daily_job_time = Tools::toDateTime(Config::obtain('last_daily_job_time'));
-        $db_version = Config::obtain('db_version');
-
         return $response->write(
             $this->view()
                 ->assign('version', VERSION)
-                ->assign('last_daily_job_time', $last_daily_job_time)
-                ->assign('db_version', $db_version)
+                ->assign('last_daily_job_time', Tools::toDateTime(Config::obtain('last_daily_job_time')))
+                ->assign('db_version', Config::obtain('db_version'))
                 ->fetch('admin/system.tpl')
         );
     }
@@ -42,15 +40,26 @@ final class SystemController extends BaseController
      */
     public function checkUpdate(ServerRequest $request, Response $response, array $args): ResponseInterface
     {
-        $latest_version = file_get_contents('https://ota.sspanel.org/get-latest-version', false, stream_context_create([
-            'http' => [
+        $client = new Client();
+
+        $headers = [
+            'User-Agent' => 'NeXT-Panel/' . VERSION,
+            'Panel-Type' => 'NeXT',
+            'Accept' => 'application/json',
+        ];
+
+        try {
+            $latest_version = $client->get('https://ota.sspanel.org/get-latest-version', [
+                'headers' => $headers,
                 'timeout' => 3,
-            ],
-        ]));
-        $is_upto_date = version_compare($latest_version, VERSION, '<=');
+            ])->getBody()->getContents();
+        } catch (GuzzleException $e) {
+            return ResponseHelper::error($response, '检查更新失败:' . $e->getMessage());
+        }
 
         return $response->withJson([
-            'is_upto_date' => $is_upto_date,
+            'ret' => 1,
+            'is_up_to_date' => version_compare($latest_version, VERSION, '<='),
             'latest_version' => $latest_version,
         ]);
     }