feat: 添加获取系统信息接口
This commit is contained in:
83
app/admin/controller/v1/System.php
Normal file
83
app/admin/controller/v1/System.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app\admin\controller\v1;
|
||||||
|
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
class System
|
||||||
|
{
|
||||||
|
// 系统信息
|
||||||
|
public function info()
|
||||||
|
{
|
||||||
|
$mysql_version = Db::query('select version() as version');
|
||||||
|
$info = [
|
||||||
|
[
|
||||||
|
'name' => '操作系统',
|
||||||
|
'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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,11 +12,14 @@ use think\facade\Route;
|
|||||||
|
|
||||||
// v1版本路由定义
|
// v1版本路由定义
|
||||||
Route::group('v1', function () {
|
Route::group('v1', function () {
|
||||||
|
// 获取系统信息
|
||||||
|
Route::get('system/info', 'System/info');
|
||||||
|
|
||||||
// 用户模块
|
// 用户模块
|
||||||
Route::group('user', function () {
|
Route::group('user', function () {
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
Route::get('captcha', 'Captcha/index')->middleware(\think\middleware\Throttle::class, [
|
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) {
|
'visit_fail_response' => function (\think\middleware\Throttle $throttle, \think\Request $request, int $wait_seconds) {
|
||||||
return \think\Response::create('您的操作过于频繁, 请在 ' . $wait_seconds . ' 秒后再试。')->code(429);
|
return \think\Response::create('您的操作过于频繁, 请在 ' . $wait_seconds . ' 秒后再试。')->code(429);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user