modified 完成安装步骤的第三步,检测数据库和缓存的状态

This commit is contained in:
zhaoxiang 2016-11-20 19:22:52 +08:00
parent 69e8b7139c
commit c0191452f1
2 changed files with 27 additions and 17 deletions

View File

@ -2,6 +2,7 @@
namespace app\install\controller; namespace app\install\controller;
use think\Controller; use think\Controller;
use think\Db;
class Index extends Controller { class Index extends Controller {
public function index(){ public function index(){
@ -37,7 +38,7 @@ class Index extends Controller {
$data['cache']['ip'] = '127.0.0.1'; $data['cache']['ip'] = '127.0.0.1';
} }
if( empty($data['cache']['port']) ){ if( empty($data['cache']['port']) ){
$data['cache']['ip'] = 6379; $data['cache']['port'] = 6379;
} }
} }
if( empty($data['admin']['name']) ){ if( empty($data['admin']['name']) ){
@ -54,7 +55,7 @@ class Index extends Controller {
$this->success('参数正确开始安装', url('step3')); $this->success('参数正确开始安装', url('step3'));
}else{ }else{
$step = session('step'); $step = session('step');
if($step != 1){ if($step != 1 && $step != 4){
$this->error("请按顺序安装", url('index')); $this->error("请按顺序安装", url('index'));
}else{ }else{
session('error', false); session('error', false);
@ -68,12 +69,10 @@ class Index extends Controller {
if( $step != 2){ if( $step != 2){
$this->error("请按顺序安装", url('index')); $this->error("请按顺序安装", url('index'));
}else{ }else{
// session('step', 3); session('step', 3);
session('error', false); session('error', false);
$dbConfig = session('dbConfig'); $dbConfig = session('dbConfig');
$cacheConfig = session('cacheConfig'); $cacheConfig = session('cacheConfig');
$adminConfig = session('adminConfig');
$isCover = session('isCover');
//环境检测 //环境检测
$this->assign('checkEnv', checkEnv()); $this->assign('checkEnv', checkEnv());
//目录文件读写检测 //目录文件读写检测
@ -84,7 +83,7 @@ class Index extends Controller {
}else{ }else{
$this->assign('checkDB', checkMongoDB()); $this->assign('checkDB', checkMongoDB());
} }
if( $cacheConfig['type'] != 0 ){ if( $cacheConfig['type'] == 1 ){
$this->assign('checkCache', checkRedis()); $this->assign('checkCache', checkRedis());
} }
$this->assign('checkOther', checkOther()); $this->assign('checkOther', checkOther());
@ -102,15 +101,28 @@ class Index extends Controller {
}else{ }else{
session('step', 4); session('step', 4);
session('error', false); session('error', false);
$dbConfig = session('dbConfig');
$cacheConfig = session('cacheConfig');
$adminConfig = session('adminConfig');
$isCover = session('isCover');
//环境检测 //检测数据库连接
$this->assign('checkEnv', checkEnv()); if( $dbConfig['DB_TYPE'] == 0 ){
$dsn = "mysql:dbname={$dbConfig['DB_NAME']};host={$dbConfig['DB_HOST']};port={$dbConfig['DB_PORT']}";
//目录文件读写检测 try {
$this->assign('checkDirFile', checkDirFile()); new \PDO($dsn, $dbConfig['DB_USER'], $dbConfig['DB_PWD']);
} catch (\PDOException $e) {
//函数及扩展库检测 $this->error($e->getMessage(), url('step2'));
$this->assign('checkFuncAndExt', checkFuncAndExt()); }
}
//检测Redis链接状态
if( $cacheConfig['type'] == 1 ){
try {
(new \Redis())->connect($cacheConfig['ip'],$cacheConfig['port']);
} catch (\RedisException $e) {
$this->error($e->getMessage(), url('step2'));
}
}
return $this->fetch(); return $this->fetch();
} }

View File

@ -102,10 +102,8 @@
{/volist} {/volist}
</tbody> </tbody>
</table> </table>
<form action="{:url('step3')}" id="form-setup"> <a type="button" href="{:url('step4')}" class="btn btn-primary btn-block">下一步</a>
<a type="button" target-form="form-setup" class="ajax-post redirect btn btn-primary btn-block">下一步</a>
<a type="button" href="{:url('step2')}" class="btn btn-default btn-block">上一步</a> <a type="button" href="{:url('step2')}" class="btn btn-default btn-block">上一步</a>
</form>
</div> </div>
</div> </div>
{/block} {/block}