modified 完成安装脚本

This commit is contained in:
zhaoxiang 2016-11-21 00:15:45 +08:00
parent 583e4490bb
commit 64aeeffa04
3 changed files with 53 additions and 16 deletions

View File

@ -96,11 +96,11 @@ class Index extends Controller {
$this->error('环境检测没有通过,请调整环境后重试!', url('step3')); $this->error('环境检测没有通过,请调整环境后重试!', url('step3'));
}else{ }else{
$step = session('step'); $step = session('step');
// if( $step != 3){ if( $step != 3){
// $this->error("请按顺序安装", url('index')); $this->error("请按顺序安装", url('index'));
// }else{ }else{
session('step', 4);
session('error', false); session('error', false);
echo $this->fetch();
$dbConfig = session('dbConfig'); $dbConfig = session('dbConfig');
$cacheConfig = session('cacheConfig'); $cacheConfig = session('cacheConfig');
$adminConfig = session('adminConfig'); $adminConfig = session('adminConfig');
@ -140,9 +140,18 @@ class Index extends Controller {
$this->writeConfig($cacheConfig, 'cache', $extraConfPath); $this->writeConfig($cacheConfig, 'cache', $extraConfPath);
} }
$this->writeConfig($baseConfig, 'base', $extraConfPath); $this->writeConfig($baseConfig, 'base', $extraConfPath);
return $this->fetch(); if(session('error')){
$this->error('安装出错', url('index'));
}else{
session('step', 4);
$this->redirect('complete');
}
} }
// } }
}
public function complete(){
return $this->fetch();
} }
/** /**
@ -154,7 +163,7 @@ class Index extends Controller {
*/ */
private function writeConfig($config, $type, $path){ private function writeConfig($config, $type, $path){
if(is_array($config)){ if(is_array($config)){
showMsg('开始写入'.$type.'配置文件'); showMsg('开始写入配置文件...', 'info');
//读取配置内容 //读取配置内容
$conf = file_get_contents(APP_PATH . $this->request->module(). DS . 'data'. DS .$type.'.tpl'); $conf = file_get_contents(APP_PATH . $this->request->module(). DS . 'data'. DS .$type.'.tpl');
//替换配置项 //替换配置项
@ -163,9 +172,9 @@ class Index extends Controller {
} }
//写入应用配置文件 //写入应用配置文件
if(file_put_contents($path.$type.'.php', $conf)){ if(file_put_contents($path.$type.'.php', $conf)){
showMsg('配置文件'.$type.'写入成功', 'bg-success'); showMsg('写入配置文件'.$type.'...成功', 'success');
}else{ }else{
showMsg('配置文件'.$type.'写入失败!', 'bg-danger'); showMsg('写入配置文件'.$type.'...失败!', 'danger');
session('error', true); session('error', true);
} }
return true; return true;
@ -184,7 +193,7 @@ class Index extends Controller {
$sql = explode(";\n", $sql); $sql = explode(";\n", $sql);
//开始安装 //开始安装
showMsg('开始安装数据库...'); showMsg('开始安装数据库...', 'info');
foreach ($sql as $value) { foreach ($sql as $value) {
$value = trim($value); $value = trim($value);
if (empty($value)) continue; if (empty($value)) continue;
@ -193,9 +202,9 @@ class Index extends Controller {
$value = str_replace(" `{$name}", " `{$prefix}{$name}", $value); $value = str_replace(" `{$name}", " `{$prefix}{$name}", $value);
$msg = "创建数据表{$name}"; $msg = "创建数据表{$name}";
if (false !== $db->exec($value)) { if (false !== $db->exec($value)) {
showMsg($msg . '...成功'); showMsg($msg . '...成功', 'success');
} else { } else {
showMsg($msg . '...失败!', 'error'); showMsg($msg . '...失败!', 'danger');
session('error', true); session('error', true);
} }
} else { } else {

View File

@ -0,0 +1,20 @@
{extend name="public/base" /}
{block name="title"}系统安装Step4{/block}
{block name="nav"}
<li><a href="javascript:;">安装协议</a></li>
<li><a href="javascript:;">参数设置</a></li>
<li><a href="javascript:;">环境检测</a></li>
<li class="active"><a href="javascript:;">开始安装</a></li>
<li><a href="javascript:;">安装完成</a></li>
{/block}
{block name="main"}
<div class="panel panel-default">
<div class="panel-heading">恭喜您,{:config('PRODUCT_NAME')} 安装完成!</div>
<div class="panel-body" style="font-size: 14px">
<div class="alert alert-success" role="alert">
<h4 align="center">{:config('PRODUCT_NAME')}提示您您的系统已经成功安装为了系统安全请删除Install模块</h4>
</div>
<a class="btn btn-primary btn-block" target="_blank" href="http://{:$_SERVER['HTTP_HOST']}">进入系统</a>
</div>
</div>
{/block}

View File

@ -8,6 +8,16 @@
<li><a href="javascript:;">安装完成</a></li> <li><a href="javascript:;">安装完成</a></li>
{/block} {/block}
{block name="main"} {block name="main"}
<style>
.install-database {
height: 500px;
max-height: 500px;
overflow-y: scroll;
}
.install-database p{
padding: 15px;
}
</style>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">{:config('PRODUCT_NAME')} 开始安装</div> <div class="panel-heading">{:config('PRODUCT_NAME')} 开始安装</div>
<div class="panel-body" style="font-size: 14px"> <div class="panel-body" style="font-size: 14px">
@ -18,14 +28,12 @@
function showMsg(msg, classname){ function showMsg(msg, classname){
var li = document.createElement('p'); var li = document.createElement('p');
li.innerHTML = msg; li.innerHTML = msg;
classname && li.setAttribute('class', classname); classname && li.setAttribute('class', 'bg-' + classname);
list.appendChild(li); list.appendChild(li);
document.scrollTop += 30; document.scrollTop += 30;
} }
</script> </script>
<button class="am-radius am-btn am-btn-warning am-disabled">正在安装,请稍后...</button> <button class="btn btn-warning btn-block" disabled>正在安装,请稍后...</button>
<a type="button" href="{:url('step4')}" class="btn btn-primary btn-block">下一步</a>
<a type="button" href="{:url('step2')}" class="btn btn-default btn-block">上一步</a>
</div> </div>
</div> </div>
{/block} {/block}