mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-25 02:40:16 +08:00
modified 更加细化的环境检测
This commit is contained in:
parent
0654c7d9b4
commit
7a84c60f1f
@ -114,77 +114,146 @@ function checkDirFile(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 函数检测
|
* MySQL数据库依赖检测
|
||||||
* @return array 检测数据
|
* @return array 检测数据
|
||||||
*/
|
*/
|
||||||
function checkFuncAndExt(){
|
function checkMySQL(){
|
||||||
$items = [
|
$items = [
|
||||||
[
|
[
|
||||||
'type' => 'ext',
|
'type' => 'ext',
|
||||||
'name' => 'pdo',
|
'name' => 'pdo',
|
||||||
'title' => '支持',
|
'title' => '支持',
|
||||||
'current' => extension_loaded('pdo'),
|
'current' => extension_loaded('pdo'),
|
||||||
'icon' => 'fa fa-check',
|
'icon' => 'fa fa-check text-success',
|
||||||
'isMust' => true
|
'isMust' => true
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'type' => 'ext',
|
'type' => 'ext',
|
||||||
'name' => 'mongoDB(不必须)',
|
'name' => 'pdo_mysql',
|
||||||
|
'title' => '支持',
|
||||||
|
'current' => extension_loaded('pdo_mysql'),
|
||||||
|
'icon' => 'fa fa-check text-success',
|
||||||
|
'isMust' => true
|
||||||
|
]
|
||||||
|
];
|
||||||
|
return baseCheck($items);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MongoDB数据库依赖检测
|
||||||
|
* @return array 检测数据
|
||||||
|
*/
|
||||||
|
function checkMongoDB(){
|
||||||
|
$items = [
|
||||||
|
[
|
||||||
|
'type' => 'ext',
|
||||||
|
'name' => 'mongoDB',
|
||||||
'title' => '支持',
|
'title' => '支持',
|
||||||
'current' => extension_loaded('mongo'),
|
'current' => extension_loaded('mongo'),
|
||||||
'icon' => 'fa fa-check',
|
'icon' => 'fa fa-check text-success',
|
||||||
'isMust' => false
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'type' => 'ext',
|
|
||||||
'name' => 'Redis(不必须)',
|
|
||||||
'title' => '支持',
|
|
||||||
'current' => extension_loaded('redis'),
|
|
||||||
'icon' => 'fa fa-check',
|
|
||||||
'isMust' => false
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'type' => 'func',
|
|
||||||
'name' => 'file_get_contents',
|
|
||||||
'title' => '支持',
|
|
||||||
'icon' => 'fa fa-check',
|
|
||||||
'isMust' => true
|
'isMust' => true
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'type' => 'func',
|
'type' => 'ext',
|
||||||
'name' => 'mb_strlen',
|
'name' => 'ZipArchive',
|
||||||
'title' => '支持',
|
'title' => '支持',
|
||||||
'icon' => 'fa fa-check',
|
'current' => class_exists('ZipArchive'),
|
||||||
|
'icon' => 'fa fa-check text-success',
|
||||||
'isMust' => true
|
'isMust' => true
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'type' => 'func',
|
'type' => 'func',
|
||||||
'name' => 'shell_exec',
|
'name' => 'shell_exec',
|
||||||
'title' => '支持',
|
'title' => '支持',
|
||||||
'icon' => 'fa fa-check',
|
'icon' => 'fa fa-check text-success',
|
||||||
'isMust' => true
|
'isMust' => true
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'type' => 'com',
|
'type' => 'com',
|
||||||
'name' => 'mongodump(不必须)',
|
'name' => 'zip',
|
||||||
'title' => '支持',
|
'title' => '支持',
|
||||||
'icon' => 'fa fa-check',
|
'icon' => 'fa fa-check text-success',
|
||||||
'isMust' => false
|
'isMust' => true
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'type' => 'com',
|
'type' => 'com',
|
||||||
'name' => 'mongorestore(不必须)',
|
'name' => 'mongodump',
|
||||||
'title' => '支持',
|
'title' => '支持',
|
||||||
'icon' => 'fa fa-check',
|
'icon' => 'fa fa-check text-success',
|
||||||
'isMust' => false
|
'isMust' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'type' => 'com',
|
||||||
|
'name' => 'mongorestore',
|
||||||
|
'title' => '支持',
|
||||||
|
'icon' => 'fa fa-check text-success',
|
||||||
|
'isMust' => true
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
return baseCheck($items);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis缓存依赖检测
|
||||||
|
* @return array 检测数据
|
||||||
|
*/
|
||||||
|
function checkRedis(){
|
||||||
|
$items = [
|
||||||
|
[
|
||||||
|
'type' => 'ext',
|
||||||
|
'name' => 'Redis',
|
||||||
|
'title' => '支持',
|
||||||
|
'current' => extension_loaded('redis'),
|
||||||
|
'icon' => 'fa fa-check text-success',
|
||||||
|
'isMust' => true
|
||||||
|
]
|
||||||
|
];
|
||||||
|
return baseCheck($items);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 其他公共部分检测
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function checkOther(){
|
||||||
|
$items = [
|
||||||
|
[
|
||||||
|
'type' => 'func',
|
||||||
|
'name' => 'file_get_contents',
|
||||||
|
'title' => '支持',
|
||||||
|
'icon' => 'fa fa-check text-success',
|
||||||
|
'isMust' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'type' => 'func',
|
||||||
|
'name' => 'mb_strlen',
|
||||||
|
'title' => '支持',
|
||||||
|
'icon' => 'fa fa-check text-success',
|
||||||
|
'isMust' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'type' => 'func',
|
||||||
|
'name' => 'curl_init',
|
||||||
|
'title' => '支持',
|
||||||
|
'icon' => 'fa fa-check text-success',
|
||||||
|
'isMust' => true
|
||||||
|
],
|
||||||
|
];
|
||||||
|
return baseCheck($items);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础函数检测
|
||||||
|
* @param $items
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function baseCheck($items){
|
||||||
foreach($items as &$val){
|
foreach($items as &$val){
|
||||||
switch($val['type']){
|
switch($val['type']){
|
||||||
case 'ext':
|
case 'ext':
|
||||||
if(!$val['current']){
|
if(!$val['current']){
|
||||||
$val['title'] = '不支持';
|
$val['title'] = '不支持';
|
||||||
$val['icon'] = 'fa fa-close';
|
$val['icon'] = 'fa fa-close text-danger';
|
||||||
if( $val['isMust'] ){
|
if( $val['isMust'] ){
|
||||||
session('error', true);
|
session('error', true);
|
||||||
}
|
}
|
||||||
@ -193,7 +262,7 @@ function checkFuncAndExt(){
|
|||||||
case 'func':
|
case 'func':
|
||||||
if(!function_exists($val['name'])){
|
if(!function_exists($val['name'])){
|
||||||
$val['title'] = '不支持';
|
$val['title'] = '不支持';
|
||||||
$val['icon'] = 'fa fa-close';
|
$val['icon'] = 'fa fa-close text-danger';
|
||||||
if( $val['isMust'] ){
|
if( $val['isMust'] ){
|
||||||
session('error', true);
|
session('error', true);
|
||||||
}
|
}
|
||||||
@ -201,17 +270,22 @@ function checkFuncAndExt(){
|
|||||||
break;
|
break;
|
||||||
case 'com':
|
case 'com':
|
||||||
$com = 'which '.$val['name'];
|
$com = 'which '.$val['name'];
|
||||||
|
if( !function_exists('shell_exec') ){
|
||||||
|
$val['title'] = '不支持';
|
||||||
|
$val['icon'] = 'fa fa-close text-danger';
|
||||||
|
session('error', true);
|
||||||
|
}else{
|
||||||
if(shell_exec($com) == null){
|
if(shell_exec($com) == null){
|
||||||
$val['title'] = '不支持';
|
$val['title'] = '不支持';
|
||||||
$val['icon'] = 'fa fa-close';
|
$val['icon'] = 'fa fa-close text-danger';
|
||||||
if( $val['isMust'] ){
|
if( $val['isMust'] ){
|
||||||
session('error', true);
|
session('error', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user