From b0008444cd4930470b1d852ee3f30c8d5a81e21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Tue, 22 Nov 2022 01:07:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=B9=E6=80=A7=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BA=BF=E4=B8=8A=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- README.md | 79 +- app/Console/Commands/Panel.php | 45 +- app/Http/Controllers/Api/InfosController.php | 4 + .../Controllers/Api/PluginsController.php | 53 +- app/Models/Setting.php | 3 + app/Models/User.php | 1 + app/Providers/PluginServiceProvider.php | 2 +- composer.json | 1 - composer.lock | 263 +- config/app.php | 2 +- config/panel.php | 4 +- .../2014_10_12_000000_create_users_table.php | 2 +- ...2022_10_14_232217_create_plugins_table.php | 1 - .../Controllers/OpenrestyController.php | 362 +-- plugins/Openresty/plugin.json | 8 +- plugins/Openresty/plugin.php | 64 +- plugins/Openresty/vendor/autoload.php | 12 - .../Openresty/vendor/composer/ClassLoader.php | 572 ---- plugins/Openresty/vendor/composer/LICENSE | 21 - .../vendor/composer/autoload_classmap.php | 11 - .../vendor/composer/autoload_namespaces.php | 9 - .../vendor/composer/autoload_psr4.php | 10 - .../vendor/composer/autoload_real.php | 36 - .../vendor/composer/autoload_static.php | 37 - plugins/Openresty/views/index.blade.php | 560 ++-- public/panel/config.js | 316 +-- public/panel/index.js | 78 +- public/panel/modules/common.js | 70 +- public/panel/modules/console.js | 646 ++--- public/panel/modules/contlist.js | 318 +-- public/panel/modules/forum.js | 238 +- .../panel/modules/layim/res/html/chatlog.html | 192 +- public/panel/modules/layim/res/html/find.html | 88 +- .../panel/modules/layim/res/html/getmsg.json | 142 +- .../panel/modules/layim/res/html/msgbox.html | 440 ++-- public/panel/modules/sample.js | 584 ++--- public/panel/modules/senior.js | 2292 ++++++++--------- public/panel/modules/set.js | 302 +-- public/panel/modules/user.js | 92 +- public/panel/modules/useradmin.js | 356 +-- public/panel/modules/workorder.js | 128 +- public/panel/style/template.css | 356 +-- public/panel/ui/src/css/admin.css | 1042 ++++---- public/panel/ui/src/css/login.css | 100 +- public/panel/ui/src/modules/admin.js | 1732 ++++++------- public/panel/ui/src/modules/index.js | 396 +-- public/panel/ui/src/modules/view.js | 692 ++--- resources/views/plugin.blade.php | 20 +- resources/views/setting.blade.php | 246 +- resources/views/ui/404.blade.php | 28 +- resources/views/ui/error.blade.php | 24 +- routes/api.php | 1 + 53 files changed, 6067 insertions(+), 7016 deletions(-) delete mode 100644 plugins/Openresty/vendor/autoload.php delete mode 100644 plugins/Openresty/vendor/composer/ClassLoader.php delete mode 100644 plugins/Openresty/vendor/composer/LICENSE delete mode 100644 plugins/Openresty/vendor/composer/autoload_classmap.php delete mode 100644 plugins/Openresty/vendor/composer/autoload_namespaces.php delete mode 100644 plugins/Openresty/vendor/composer/autoload_psr4.php delete mode 100644 plugins/Openresty/vendor/composer/autoload_real.php delete mode 100644 plugins/Openresty/vendor/composer/autoload_static.php diff --git a/.gitignore b/.gitignore index 976a5880..bb91596a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .idea .DS_Store -.vendor +vendor/ diff --git a/README.md b/README.md index bf0ddd92..f1e1f780 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,29 @@ -
+耗子Linux面板 +=============== - +#### 这是耗子Linux面板的开源仓库,基于AGPLv3协议进行开源,目前处于积极开发状态。 -## About Laravel +## 运行环境 -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: +| 系统 | 版本 | +|---------------|-----| +| CentOS Stream | 9 | +| CentOS Stream | 8 | +| RockyLinux | 9 | +| RockyLinux | 8 | +| AlmaLinux | 9 | +| AlmaLinux | 8 | -- [Simple, fast routing engine](https://laravel.com/docs/routing). -- [Powerful dependency injection container](https://laravel.com/docs/container). -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). -- [Robust background job processing](https://laravel.com/docs/queues). -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). +广告: [`WeAvatar` —统一头像服务](https://weavatar.com) -Laravel is accessible, powerful, and provides tools required for large, robust applications. +## 安装说明 -## Learning Laravel +```shell +wget -O install_panel.sh https://dl.panel.haozi.xyz/shell/install_panel.sh && bash install_panel.sh +``` -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. +## 更新说明 -You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. - -If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. - -## Laravel Sponsors - -We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). - -### Premium Partners - -- **[Vehikl](https://vehikl.com/)** -- **[Tighten Co.](https://tighten.co)** -- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** -- **[64 Robots](https://64robots.com)** -- **[Cubet Techno Labs](https://cubettech.com)** -- **[Cyber-Duck](https://cyber-duck.co.uk)** -- **[Many](https://www.many.co.uk)** -- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** -- **[DevSquad](https://devsquad.com)** -- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** -- **[OP.GG](https://op.gg)** -- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)** -- **[Lendio](https://lendio.com)** - -## Contributing - -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). - -## Code of Conduct - -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). - -## Security Vulnerabilities - -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. - -## License - -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). +```shell +panel update +``` diff --git a/app/Console/Commands/Panel.php b/app/Console/Commands/Panel.php index 1df6dcce..84d2b43e 100644 --- a/app/Console/Commands/Panel.php +++ b/app/Console/Commands/Panel.php @@ -49,6 +49,9 @@ class Panel extends Command case 'writePluginUnInstall': $this->writePluginUnInstall(); break; + case 'writeMysqlPassword': + $this->writeMysqlPassword(); + break; default: $this->error('错误的操作'); break; @@ -67,6 +70,12 @@ class Panel extends Command Setting::query()->updateOrCreate(['name' => 'monitor_days'], ['value' => '30']); Setting::query()->updateOrCreate(['name' => 'mysql_root_password'], ['value' => '']); Setting::query()->updateOrCreate(['name' => 'postgresql_root_password'], ['value' => '']); + User::query()->create([ + 'id' => 1, + 'username' => 'admin', + 'email' => 'panel@haozi.net', + 'password' => Hash::make(Str::random()), + ]); } /** @@ -113,20 +122,11 @@ class Panel extends Command // 生成唯一信息 $username = Str::random(6); $password = Str::random(12); - // 判空 - if (empty($user)) { - User::query()->create([ - 'id' => 1, - 'username' => $username, - 'password' => Hash::make($password), - ]); - } else { - // 入库 - $user->update([ - 'username' => $username, - 'password' => Hash::make($password), - ]); - } + // 入库 + $user->update([ + 'username' => $username, + 'password' => Hash::make($password), + ]); $this->info('面板用户名:'.$username); $this->info('面板密码:'.$password); @@ -175,4 +175,21 @@ class Panel extends Command Plugin::query()->where('slug', $pluginSlug)->delete(); $this->info('成功'); } + + /** + * 写入MySQL密码 + */ + private function writeMysqlPassword(): void + { + $password = $this->argument('a1'); + + // 判空 + if (empty($password)) { + $this->error('参数错误'); + return; + } + // 入库 + Setting::query()->where('name', 'mysql_root_password')->update(['value' => $password]); + $this->info('成功'); + } } diff --git a/app/Http/Controllers/Api/InfosController.php b/app/Http/Controllers/Api/InfosController.php index 8e045a45..63a4f190 100644 --- a/app/Http/Controllers/Api/InfosController.php +++ b/app/Http/Controllers/Api/InfosController.php @@ -249,6 +249,10 @@ class InfosController extends Controller $res['data'] = []; } else { $plugins = $plugins->toArray(); + $plugins = array_map(function ($item) { + $item['name'] = PLUGINS[$item['slug']]['name']; + return $item; + }, $plugins); $res['code'] = 0; $res['msg'] = 'success'; $res['data'] = $plugins; diff --git a/app/Http/Controllers/Api/PluginsController.php b/app/Http/Controllers/Api/PluginsController.php index 8095db3d..5db15a6d 100644 --- a/app/Http/Controllers/Api/PluginsController.php +++ b/app/Http/Controllers/Api/PluginsController.php @@ -47,7 +47,8 @@ class PluginsController extends Controller $data['data'][$k]['control']['installed'] = true; $data['data'][$k]['control']['allow_uninstall'] = true; // 判断是否有更新 - $data['data'][$k]['control']['update'] = version_compare($v['version'], $data['data'][$k]['install_version'], '>'); + $data['data'][$k]['control']['update'] = version_compare($v['version'], + $data['data'][$k]['install_version'], '>'); if ($v['slug'] == 'openresty') { $data['data'][$k]['control']['allow_uninstall'] = false; } @@ -92,7 +93,7 @@ class PluginsController extends Controller } // 判断有无任务记录 - $task_check = Task::query()->where('name', '安装' . $plugin_data['name'])->first(); + $task_check = Task::query()->where('name', '安装'.$plugin_data['name'])->first(); if ($task_check) { $data['code'] = 1; $data['msg'] = '此插件已存在安装记录,请先删除!'; @@ -108,10 +109,10 @@ class PluginsController extends Controller // 入库等待安装 $task = new Task(); - $task->name = '安装' . $plugin_data['name']; + $task->name = '安装'.$plugin_data['name']; $task->shell = $plugin_data['install']; $task->status = 'waiting'; - $task->log = '/tmp/' . $plugin_data['slug'] . '.log'; + $task->log = '/tmp/'.$plugin_data['slug'].'.log'; $task->save(); // 塞入队列 ProcessShell::dispatch($task->id)->delay(1); @@ -156,19 +157,12 @@ class PluginsController extends Controller } // 判断有无任务记录 - $task_check = Task::query()->where('name', '卸载' . $plugin_data['name'])->first(); + $task_check = Task::query()->where('name', '卸载'.$plugin_data['name'])->first(); if ($task_check) { $data['code'] = 1; $data['msg'] = '此插件已存在卸载记录,请先删除!'; return response()->json($data); } - // 判断插件是否未安装 - /*$installed = Task::query()->where('slug', $slug)->first(); - if (!$installed) { - $data['code'] = 1; - $data['msg'] = '插件未安装,无需卸载!'; - return response()->json($data); - }*/ // 判断是否是操作openresty if ($slug == 'openresty') { @@ -179,10 +173,10 @@ class PluginsController extends Controller // 入库等待卸载 $task = new Task(); - $task->name = '卸载' . $plugin_data['name']; + $task->name = '卸载'.$plugin_data['name']; $task->shell = $plugin_data['uninstall']; $task->status = 'waiting'; - $task->log = '/tmp/' . $plugin_data['slug'] . '.log'; + $task->log = '/tmp/'.$plugin_data['slug'].'.log'; $task->save(); // 塞入队列 ProcessShell::dispatch($task->id)->delay(1); @@ -196,12 +190,13 @@ class PluginsController extends Controller /** * 读取插件列表 */ - public function pluginList($cache = true) { + public function pluginList($cache = true) + { // 判断刷新缓存 if (!$cache) { Cache::forget('pluginList'); } - if ( ! Cache::has('pluginList')) { + if (!Cache::has('pluginList')) { return Cache::remember('pluginList', 3600, function () { $response = Http::get('https://api.panel.haozi.xyz/api/plugin/list'); // 判断请求是否成功,如果不成功则抛出异常 @@ -209,7 +204,7 @@ class PluginsController extends Controller throw new Exception('获取插件列表失败,请求错误'); } // 判断返回的JSON数据中code是否为0,如果不为0则抛出异常 - if ( ! $response->json('code') == 0) { + if (!$response->json('code') == 0) { throw new Exception('获取插件列表失败,服务器未返回正确的状态码'); } @@ -220,4 +215,28 @@ class PluginsController extends Controller return Cache::get('pluginList'); } } + + /** + * 设置插件首页显示 + */ + public function setShowHome(Request $request): JsonResponse + { + // 消毒 + try { + $credentials = $this->validate($request, [ + 'slug' => 'required|max:255', + 'show' => 'required|boolean', + ]); + $slug = $credentials['slug']; + $show = $credentials['show']; + } catch (Exception $e) { + return response()->json(['code' => 1, 'msg' => $e->getMessage()]); + } + + Plugin::query()->where('slug', $slug)->update(['show' => $show]); + $res['code'] = 0; + $res['msg'] = 'success'; + $res['data'] = '设置成功'; + return response()->json($res); + } } diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 0fe60afd..0e104773 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -8,4 +8,7 @@ use Illuminate\Database\Eloquent\Model; class Setting extends Model { use HasFactory; + + // 白名单 + protected $fillable = ['name', 'value', 'created_at', 'updated_at']; } diff --git a/app/Models/User.php b/app/Models/User.php index 33fc0c96..cdab044b 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -20,6 +20,7 @@ class User extends Authenticatable protected $fillable = [ 'username', 'password', + 'email' ]; /** diff --git a/app/Providers/PluginServiceProvider.php b/app/Providers/PluginServiceProvider.php index dd7b6502..843cc9a7 100644 --- a/app/Providers/PluginServiceProvider.php +++ b/app/Providers/PluginServiceProvider.php @@ -63,7 +63,7 @@ class PluginServiceProvider extends ServiceProvider { $this->app->singleton('plugins', Plugin::class); // 设置面板名称 - $name = DB::table('settings')->where('name', 'name')->value('value'); + $name = @DB::table('settings')->where('name', 'name')->value('value'); $this->app['config']['panel.name'] = !empty($name) ? $name : config('panel.name'); } } \ No newline at end of file diff --git a/composer.json b/composer.json index 9d94a788..00024ac0 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,6 @@ "php": "^8.1.9", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^9.19", - "laravel/octane": "^1.3", "laravel/sanctum": "^3.0", "laravel/tinker": "^2.7", "overtrue/laravel-lang": "^6.0" diff --git a/composer.lock b/composer.lock index 5680703f..cdaf39d0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e04515c415a76e849e40b5659911865a", + "content-hash": "efb63260d6e5ee652c84bfee6f458ada", "packages": [ { "name": "brick/math", @@ -897,103 +897,6 @@ ], "time": "2022-10-26T14:07:24+00:00" }, - { - "name": "laminas/laminas-diactoros", - "version": "2.20.0", - "source": { - "type": "git", - "url": "https://github.com/laminas/laminas-diactoros.git", - "reference": "10696c809866bebd9d71dca14de6c0d6c1cac2f8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/10696c809866bebd9d71dca14de6c0d6c1cac2f8", - "reference": "10696c809866bebd9d71dca14de6c0d6c1cac2f8", - "shasum": "" - }, - "require": { - "php": "~8.0.0 || ~8.1.0 || ~8.2.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.0" - }, - "conflict": { - "zendframework/zend-diactoros": "*" - }, - "provide": { - "psr/http-factory-implementation": "1.0", - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "ext-curl": "*", - "ext-dom": "*", - "ext-gd": "*", - "ext-libxml": "*", - "http-interop/http-factory-tests": "^0.9.0", - "laminas/laminas-coding-standard": "^2.4.0", - "php-http/psr7-integration-tests": "^1.1.1", - "phpunit/phpunit": "^9.5.25", - "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.28" - }, - "type": "library", - "extra": { - "laminas": { - "config-provider": "Laminas\\Diactoros\\ConfigProvider", - "module": "Laminas\\Diactoros" - } - }, - "autoload": { - "files": [ - "src/functions/create_uploaded_file.php", - "src/functions/marshal_headers_from_sapi.php", - "src/functions/marshal_method_from_sapi.php", - "src/functions/marshal_protocol_version_from_sapi.php", - "src/functions/marshal_uri_from_sapi.php", - "src/functions/normalize_server.php", - "src/functions/normalize_uploaded_files.php", - "src/functions/parse_cookie_header.php", - "src/functions/create_uploaded_file.legacy.php", - "src/functions/marshal_headers_from_sapi.legacy.php", - "src/functions/marshal_method_from_sapi.legacy.php", - "src/functions/marshal_protocol_version_from_sapi.legacy.php", - "src/functions/marshal_uri_from_sapi.legacy.php", - "src/functions/normalize_server.legacy.php", - "src/functions/normalize_uploaded_files.legacy.php", - "src/functions/parse_cookie_header.legacy.php" - ], - "psr-4": { - "Laminas\\Diactoros\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "PSR HTTP Message implementations", - "homepage": "https://laminas.dev", - "keywords": [ - "http", - "laminas", - "psr", - "psr-17", - "psr-7" - ], - "support": { - "chat": "https://laminas.dev/chat", - "docs": "https://docs.laminas.dev/laminas-diactoros/", - "forum": "https://discourse.laminas.dev", - "issues": "https://github.com/laminas/laminas-diactoros/issues", - "rss": "https://github.com/laminas/laminas-diactoros/releases.atom", - "source": "https://github.com/laminas/laminas-diactoros" - }, - "funding": [ - { - "url": "https://funding.communitybridge.org/projects/laminas-project", - "type": "community_bridge" - } - ], - "time": "2022-10-25T13:35:54+00:00" - }, { "name": "laravel-lang/lang", "version": "10.9.5", @@ -1258,82 +1161,6 @@ }, "time": "2022-11-01T14:05:55+00:00" }, - { - "name": "laravel/octane", - "version": "v1.3.6", - "source": { - "type": "git", - "url": "https://github.com/laravel/octane.git", - "reference": "1e9b86366068a40d59343d400228a5cc6db9e906" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/octane/zipball/1e9b86366068a40d59343d400228a5cc6db9e906", - "reference": "1e9b86366068a40d59343d400228a5cc6db9e906", - "shasum": "" - }, - "require": { - "laminas/laminas-diactoros": "^2.5", - "laravel/framework": "^8.83.26|^9.38.0", - "laravel/serializable-closure": "^1.0", - "nesbot/carbon": "^2.60", - "php": "^8.0", - "symfony/psr-http-message-bridge": "^2.0" - }, - "require-dev": { - "guzzlehttp/guzzle": "^7.2", - "mockery/mockery": "^1.4", - "nunomaduro/collision": "^5.10|^6.0", - "orchestra/testbench": "^6.16|^7.0", - "phpunit/phpunit": "^9.3", - "spiral/roadrunner": "^2.8.2" - }, - "bin": [ - "bin/roadrunner-worker", - "bin/swoole-server" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - }, - "laravel": { - "providers": [ - "Laravel\\Octane\\OctaneServiceProvider" - ], - "aliases": { - "Octane": "Laravel\\Octane\\Facades\\Octane" - } - } - }, - "autoload": { - "psr-4": { - "Laravel\\Octane\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "Supercharge your Laravel application's performance.", - "keywords": [ - "laravel", - "octane", - "roadrunner", - "swoole" - ], - "support": { - "issues": "https://github.com/laravel/octane/issues", - "source": "https://github.com/laravel/octane" - }, - "time": "2022-11-01T14:55:59+00:00" - }, { "name": "laravel/sanctum", "version": "v3.0.1", @@ -4816,94 +4643,6 @@ ], "time": "2022-06-27T17:24:16+00:00" }, - { - "name": "symfony/psr-http-message-bridge", - "version": "v2.1.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/psr-http-message-bridge.git", - "reference": "d444f85dddf65c7e57c58d8e5b3a4dbb593b1840" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/d444f85dddf65c7e57c58d8e5b3a4dbb593b1840", - "reference": "d444f85dddf65c7e57c58d8e5b3a4dbb593b1840", - "shasum": "" - }, - "require": { - "php": ">=7.1", - "psr/http-message": "^1.0", - "symfony/http-foundation": "^4.4 || ^5.0 || ^6.0" - }, - "require-dev": { - "nyholm/psr7": "^1.1", - "psr/log": "^1.1 || ^2 || ^3", - "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0", - "symfony/config": "^4.4 || ^5.0 || ^6.0", - "symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0", - "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", - "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", - "symfony/phpunit-bridge": "^5.4@dev || ^6.0" - }, - "suggest": { - "nyholm/psr7": "For a super lightweight PSR-7/17 implementation" - }, - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-main": "2.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Bridge\\PsrHttpMessage\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "PSR HTTP message bridge", - "homepage": "http://symfony.com", - "keywords": [ - "http", - "http-message", - "psr-17", - "psr-7" - ], - "support": { - "issues": "https://github.com/symfony/psr-http-message-bridge/issues", - "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.1.3" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-09-05T10:34:54+00:00" - }, { "name": "symfony/routing", "version": "v6.1.7", diff --git a/config/app.php b/config/app.php index 3c3772aa..8722d61d 100644 --- a/config/app.php +++ b/config/app.php @@ -28,7 +28,7 @@ return [ | */ - 'env' => 'production', + 'env' => 'local', /* |-------------------------------------------------------------------------- diff --git a/config/panel.php b/config/panel.php index 16169321..8014f5ae 100644 --- a/config/panel.php +++ b/config/panel.php @@ -1,8 +1,6 @@ '耗子Linux面板', - 'version' => '20221120', + 'version' => '20221121', 'plugin_dir' => '/www/panel/plugins', ]; \ No newline at end of file diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index cf6b7766..0154c490 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -15,7 +15,7 @@ return new class extends Migration { Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('username'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); diff --git a/database/migrations/2022_10_14_232217_create_plugins_table.php b/database/migrations/2022_10_14_232217_create_plugins_table.php index 9a412e70..0dbb4b7d 100644 --- a/database/migrations/2022_10_14_232217_create_plugins_table.php +++ b/database/migrations/2022_10_14_232217_create_plugins_table.php @@ -16,7 +16,6 @@ return new class extends Migration Schema::create('plugins', function (Blueprint $table) { $table->id(); $table->string('slug')->unique()->comment('插件标识'); - $table->string('name')->comment('插件名称'); $table->boolean('show')->comment('是否首页显示')->nullable(); $table->timestamps(); }); diff --git a/plugins/Openresty/Controllers/OpenrestyController.php b/plugins/Openresty/Controllers/OpenrestyController.php index 052f4665..5f64dc67 100755 --- a/plugins/Openresty/Controllers/OpenrestyController.php +++ b/plugins/Openresty/Controllers/OpenrestyController.php @@ -1,181 +1,181 @@ -json($res); - } - - public function restart() - { - $command = 'nginx -t 2>&1'; - $result = shell_exec($command); - - $res['code'] = 0; - $res['msg'] = 'success'; - if (str_contains($result, 'test failed')) { - // 测试失败,则不允许重启 - $res['msg'] = 'error'; - $res['data'] = 'OpenResty配置有误,请修正后再重启:'.$result; - return response()->json($res); - } - - $command2 = 'systemctl restart nginx'; - $result2 = shell_exec($command2); - if (str_contains($result2, 'done')) { - $res['data'] = 'OpenResty已重启'; - return response()->json($res); - } - return response()->json($res); - } - - public function reload() - { - $command = 'nginx -t 2>&1'; - $result = shell_exec($command); - $res['code'] = 0; - $res['msg'] = 'success'; - if (str_contains($result, 'test failed')) { - // 测试失败,则不允许重载 - $res['msg'] = 'error'; - $res['data'] = 'OpenResty配置有误,请修正后再重载:'.$result; - return response()->json($res); - } - - $command2 = 'systemctl reload nginx'; - $result2 = shell_exec($command2); - if (str_contains($result2, 'done')) { - $res['data'] = 'OpenResty已重载'; - } else { - $res['msg'] = 'error'; - $res['data'] = 'OpenResty重载失败'; - } - return response()->json($res); - } - - public function getConfig() - { - $res['code'] = 0; - $res['msg'] = 'success'; - $res['data'] = file_get_contents('/www/server/nginx/conf/nginx.conf'); - return response()->json($res); - } - - public function saveConfig() - { - $res['code'] = 0; - $res['msg'] = 'success'; - // 获取配置内容 - $config = Request::post('config'); - // 备份一份旧配置 - $old_config = file_get_contents('/www/server/nginx/conf/nginx.conf'); - // 写入配置 - $result = file_put_contents('/www/server/nginx/conf/nginx.conf', $config); - // 测试配置是否正确 - $test = shell_exec('nginx -t 2>&1'); - // 判断结果 - if (!str_contains($test, 'test is successful')) { - // 测试失败,则不允许保存 - $res['msg'] = 'error'; - $res['data'] = 'OpenResty配置有误,请修正后再保存:'.$test; - // 恢复旧配置 - file_put_contents('/www/server/nginx/conf/nginx.conf', $old_config); - return response()->json($res); - } else { - // 测试成功,则重载OpenResty - shell_exec('systemctl reload nginx'); - $res['data'] = 'OpenResty主配置已保存'; - return response()->json($res); - } - } - - public function load() - { - $raw_status = HTTP::get('http://127.0.0.1/nginx_status')->body(); - - $res['code'] = 0; - $res['msg'] = 'success'; - $res['data'][0]['name'] = '工作进程'; - $res['data'][0]['value'] = (int) shell_exec("ps aux|grep nginx|grep 'worker process'|wc -l"); - $res['data'][1]['name'] = '内存占用'; - $res['data'][1]['value'] = round(shell_exec("ps aux|grep nginx|grep 'worker process'|awk '{memsum+=$6};END {print memsum}'") / 1024, - 2).'MB'; - - // 使用正则匹配Active connections: 的值 - preg_match('/Active connections:\s+(\d+)/', $raw_status, $matches); - $res['data'][2]['name'] = '活跃连接数'; - $res['data'][2]['value'] = $matches[1] ?? 0; - // 使用正则分别匹配server accepts handled requests的三个值 - preg_match('/server accepts handled requests\s+(\d+)\s+(\d+)\s+(\d+)/', $raw_status, $matches2); - $res['data'][3]['name'] = '总连接次数'; - $res['data'][3]['value'] = $matches2[1] ?? 0; - $res['data'][4]['name'] = '总握手次数'; - $res['data'][4]['value'] = $matches2[2] ?? 0; - $res['data'][5]['name'] = '总请求次数'; - $res['data'][5]['value'] = $matches2[3] ?? 0; - // 使用正则匹配Reading: 的值 - preg_match('/Reading:\s+(\d+)/', $raw_status, $matches3); - $res['data'][6]['name'] = '请求数'; - $res['data'][6]['value'] = $matches3[1] ?? 0; - // 使用正则匹配Writing: 的值 - preg_match('/Writing:\s+(\d+)/', $raw_status, $matches4); - $res['data'][7]['name'] = '响应数'; - $res['data'][7]['value'] = $matches4[1] ?? 0; - // 使用正则匹配Waiting: 的值 - preg_match('/Waiting:\s+(\d+)/', $raw_status, $matches5); - $res['data'][8]['name'] = '驻留进程'; - $res['data'][8]['value'] = $matches5[1] ?? 0; - - return response()->json($res); - } - - public function errorLog() - { - $res['code'] = 0; - $res['msg'] = 'success'; - $res['data'] = file_get_contents('/www/wwwlogs/nginx_error.log'); - //如果data为换行符,则令返回空 - if ($res['data'] == "\n") { - $res['data'] = ''; - } - return response()->json($res); - } - - public function cleanErrorLog() - { - $res['code'] = 0; - $res['msg'] = 'success'; - shell_exec('echo "" > /www/wwwlogs/nginx_error.log'); - return response()->json($res); - } - -} +json($res); + } + + public function restart() + { + $command = 'nginx -t 2>&1'; + $result = shell_exec($command); + + $res['code'] = 0; + $res['msg'] = 'success'; + if (str_contains($result, 'test failed')) { + // 测试失败,则不允许重启 + $res['msg'] = 'error'; + $res['data'] = 'OpenResty配置有误,请修正后再重启:'.$result; + return response()->json($res); + } + + $command2 = 'systemctl restart nginx'; + $result2 = shell_exec($command2); + if (str_contains($result2, 'done')) { + $res['data'] = 'OpenResty已重启'; + return response()->json($res); + } + return response()->json($res); + } + + public function reload() + { + $command = 'nginx -t 2>&1'; + $result = shell_exec($command); + $res['code'] = 0; + $res['msg'] = 'success'; + if (str_contains($result, 'test failed')) { + // 测试失败,则不允许重载 + $res['msg'] = 'error'; + $res['data'] = 'OpenResty配置有误,请修正后再重载:'.$result; + return response()->json($res); + } + + $command2 = 'systemctl reload nginx'; + $result2 = shell_exec($command2); + if (str_contains($result2, 'done')) { + $res['data'] = 'OpenResty已重载'; + } else { + $res['msg'] = 'error'; + $res['data'] = 'OpenResty重载失败'; + } + return response()->json($res); + } + + public function getConfig() + { + $res['code'] = 0; + $res['msg'] = 'success'; + $res['data'] = file_get_contents('/www/server/nginx/conf/nginx.conf'); + return response()->json($res); + } + + public function saveConfig() + { + $res['code'] = 0; + $res['msg'] = 'success'; + // 获取配置内容 + $config = Request::post('config'); + // 备份一份旧配置 + $old_config = file_get_contents('/www/server/nginx/conf/nginx.conf'); + // 写入配置 + $result = file_put_contents('/www/server/nginx/conf/nginx.conf', $config); + // 测试配置是否正确 + $test = shell_exec('nginx -t 2>&1'); + // 判断结果 + if (!str_contains($test, 'test is successful')) { + // 测试失败,则不允许保存 + $res['msg'] = 'error'; + $res['data'] = 'OpenResty配置有误,请修正后再保存:'.$test; + // 恢复旧配置 + file_put_contents('/www/server/nginx/conf/nginx.conf', $old_config); + return response()->json($res); + } else { + // 测试成功,则重载OpenResty + shell_exec('systemctl reload nginx'); + $res['data'] = 'OpenResty主配置已保存'; + return response()->json($res); + } + } + + public function load() + { + $raw_status = HTTP::get('http://127.0.0.1/nginx_status')->body(); + + $res['code'] = 0; + $res['msg'] = 'success'; + $res['data'][0]['name'] = '工作进程'; + $res['data'][0]['value'] = (int) shell_exec("ps aux|grep nginx|grep 'worker process'|wc -l"); + $res['data'][1]['name'] = '内存占用'; + $res['data'][1]['value'] = round(shell_exec("ps aux|grep nginx|grep 'worker process'|awk '{memsum+=$6};END {print memsum}'") / 1024, + 2).'MB'; + + // 使用正则匹配Active connections: 的值 + preg_match('/Active connections:\s+(\d+)/', $raw_status, $matches); + $res['data'][2]['name'] = '活跃连接数'; + $res['data'][2]['value'] = $matches[1] ?? 0; + // 使用正则分别匹配server accepts handled requests的三个值 + preg_match('/server accepts handled requests\s+(\d+)\s+(\d+)\s+(\d+)/', $raw_status, $matches2); + $res['data'][3]['name'] = '总连接次数'; + $res['data'][3]['value'] = $matches2[1] ?? 0; + $res['data'][4]['name'] = '总握手次数'; + $res['data'][4]['value'] = $matches2[2] ?? 0; + $res['data'][5]['name'] = '总请求次数'; + $res['data'][5]['value'] = $matches2[3] ?? 0; + // 使用正则匹配Reading: 的值 + preg_match('/Reading:\s+(\d+)/', $raw_status, $matches3); + $res['data'][6]['name'] = '请求数'; + $res['data'][6]['value'] = $matches3[1] ?? 0; + // 使用正则匹配Writing: 的值 + preg_match('/Writing:\s+(\d+)/', $raw_status, $matches4); + $res['data'][7]['name'] = '响应数'; + $res['data'][7]['value'] = $matches4[1] ?? 0; + // 使用正则匹配Waiting: 的值 + preg_match('/Waiting:\s+(\d+)/', $raw_status, $matches5); + $res['data'][8]['name'] = '驻留进程'; + $res['data'][8]['value'] = $matches5[1] ?? 0; + + return response()->json($res); + } + + public function errorLog() + { + $res['code'] = 0; + $res['msg'] = 'success'; + $res['data'] = file_get_contents('/www/wwwlogs/nginx_error.log'); + //如果data为换行符,则令返回空 + if ($res['data'] == "\n") { + $res['data'] = ''; + } + return response()->json($res); + } + + public function cleanErrorLog() + { + $res['code'] = 0; + $res['msg'] = 'success'; + shell_exec('echo "" > /www/wwwlogs/nginx_error.log'); + return response()->json($res); + } + +} diff --git a/plugins/Openresty/plugin.json b/plugins/Openresty/plugin.json index a7931235..ba46b391 100755 --- a/plugins/Openresty/plugin.json +++ b/plugins/Openresty/plugin.json @@ -1,5 +1,5 @@ -{ - "name": "OpenResty-1.21.4", - "slug": "openresty", - "version": "1.21.4.1" +{ + "name": "OpenResty-1.21.4", + "slug": "openresty", + "version": "1.21.4.1" } \ No newline at end of file diff --git a/plugins/Openresty/plugin.php b/plugins/Openresty/plugin.php index faeba08b..044e7d0d 100755 --- a/plugins/Openresty/plugin.php +++ b/plugins/Openresty/plugin.php @@ -1,32 +1,32 @@ -group([ - 'prefix' => 'panel/views/plugin/openresty', - //'middleware' => ['auth:sanctum'], -], function () { - Route::view('/', 'openresty::index'); -}); -// 控制器 -app('router')->group([ - 'prefix' => 'api/plugin/openresty', - 'middleware' => ['auth:sanctum'], -], function () { - Route::get('status', [OpenrestyController::class, 'status']); - Route::get('load', [OpenrestyController::class, 'load']); - Route::get('errorLog', [OpenrestyController::class, 'errorLog']); - Route::get('config', [OpenrestyController::class, 'getConfig']); - Route::post('config', [OpenrestyController::class, 'saveConfig']); - Route::get('cleanErrorLog', [OpenrestyController::class, 'cleanErrorLog']); - Route::get('restart', [OpenrestyController::class, 'restart']); - Route::get('reload', [OpenrestyController::class, 'reload']); -}); - +group([ + 'prefix' => 'panel/views/plugin/openresty', + //'middleware' => ['auth:sanctum'], +], function () { + Route::view('/', 'openresty::index'); +}); +// 控制器 +app('router')->group([ + 'prefix' => 'api/plugin/openresty', + 'middleware' => ['auth:sanctum'], +], function () { + Route::get('status', [OpenrestyController::class, 'status']); + Route::get('load', [OpenrestyController::class, 'load']); + Route::get('errorLog', [OpenrestyController::class, 'errorLog']); + Route::get('config', [OpenrestyController::class, 'getConfig']); + Route::post('config', [OpenrestyController::class, 'saveConfig']); + Route::get('cleanErrorLog', [OpenrestyController::class, 'cleanErrorLog']); + Route::get('restart', [OpenrestyController::class, 'restart']); + Route::get('reload', [OpenrestyController::class, 'reload']); +}); + diff --git a/plugins/Openresty/vendor/autoload.php b/plugins/Openresty/vendor/autoload.php deleted file mode 100644 index eb2d0e62..00000000 --- a/plugins/Openresty/vendor/autoload.php +++ /dev/null @@ -1,12 +0,0 @@ - - * Jordi Boggiano当前状态:获取中-
此处修改的是OpenResty主配置文件,如果你不了解各参数的含义,请不要随意修改!- -
- 提示:Ctrl+F 搜索关键字,Ctrl+S 保存,Ctrl+H 查找替换! -
- 获取中... --
- 通过 find 参数指向的自定义页面 --
+ 通过 find 参数指向的自定义页面 ++
- 注意:该页面为 msgbox 参数指向的自定义页面。 --
此页为消息盒子的模拟数据,实际使用时请进行相应修改。 -
+ 注意:该页面为 msgbox 参数指向的自定义页面。 ++
此页为消息盒子的模拟数据,实际使用时请进行相应修改。 +