From 32ccd0e367484ed6130e6bda44edffda0adfcc3d Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Fri, 14 Mar 2025 15:21:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/v1/System.php | 83 ++++++++++++++++++++++++++++++ app/admin/route/v1.php | 5 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 app/admin/controller/v1/System.php diff --git a/app/admin/controller/v1/System.php b/app/admin/controller/v1/System.php new file mode 100644 index 00000000..eab99543 --- /dev/null +++ b/app/admin/controller/v1/System.php @@ -0,0 +1,83 @@ + '操作系统', + 'value' => PHP_OS + ], + [ + 'name' => '运行环境', + 'value' => $_SERVER["SERVER_SOFTWARE"] + ], + [ + 'name' => 'PHP版本', + 'value' => PHP_VERSION + ], + [ + 'name' => '上传附件限制', + 'value' => ini_get('upload_max_filesize') + ], + [ + 'name' => 'MySQL版本', + 'value' => !empty($mysql_version) ? $mysql_version[0]['version'] : '未知' + ], + [ + 'name' => '最大执行时间', + 'value' => ini_get('max_execution_time') . 's' + ], + [ + 'name' => 'GD版本', + 'value' => function_exists('gd_info') ? (gd_info()['GD Version']) : '未知' + ], + [ + 'name' => '最大占用内存', + 'value' => ini_get('memory_limit') + ], + [ + 'name' => '当前时间', + 'value' => date('Y-m-d H:i:s') + ], + [ + 'name' => '服务器时区', + 'value' => function_exists("date_default_timezone_get") ? date_default_timezone_get() : '未知' + ], + [ + 'name' => '是否开启安全模式', + 'value' => ini_get('safe_mode') ? 'YES' : 'NO' + ], + [ + 'name' => '允许打开远程连接', + 'value' => ini_get("allow_url_fopen") ? 'YES' : 'NO' + ], + [ + 'name' => 'CURL支持', + 'value' => function_exists('curl_init') ? 'YES' : 'NO' + ], + [ + 'name' => 'Zlib支持', + 'value' => function_exists('gzclose') ? 'YES' : 'NO' + ], + [ + 'name' => '自身版本', + 'value' => '1.0.0' + ], + [ + 'name' => '服务器域名/IP', + 'value' => $_SERVER['HTTP_HOST'] . '[' . gethostbyname($_SERVER['SERVER_NAME']) . ']' + ] + ]; + + return success('获取成功', $info); + } +} diff --git a/app/admin/route/v1.php b/app/admin/route/v1.php index 55f7a8ab..34abcbec 100644 --- a/app/admin/route/v1.php +++ b/app/admin/route/v1.php @@ -12,11 +12,14 @@ use think\facade\Route; // v1版本路由定义 Route::group('v1', function () { + // 获取系统信息 + Route::get('system/info', 'System/info'); + // 用户模块 Route::group('user', function () { // 获取验证码 Route::get('captcha', 'Captcha/index')->middleware(\think\middleware\Throttle::class, [ - 'visit_rate' => '5/m', + 'visit_rate' => '5/m', 'visit_fail_response' => function (\think\middleware\Throttle $throttle, \think\Request $request, int $wait_seconds) { return \think\Response::create('您的操作过于频繁, 请在 ' . $wait_seconds . ' 秒后再试。')->code(429); },