程序安装引导优化
This commit is contained in:
parent
e309828d42
commit
00a9cbf129
@ -14,7 +14,7 @@ class Index extends BaseController
|
||||
*/
|
||||
// 检测是否安装过
|
||||
protected function initialize(){
|
||||
if(is_file('../install.lock')){
|
||||
if(file_exists('../install.lock')){
|
||||
echo "<script>alert('已经成功安装了TaoLer社区系统,安装系统已锁定。如需重新安装,请删除根目录下的install.lock文件')</script>";
|
||||
die();
|
||||
}
|
||||
@ -38,7 +38,7 @@ class Index extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
//test
|
||||
//create
|
||||
public function create(){
|
||||
if(Session::get('install') == 2){
|
||||
Session::set('install',3);
|
||||
@ -48,17 +48,18 @@ class Index extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// 安装成功页面
|
||||
public function complete(){
|
||||
// 安装
|
||||
public function install(){
|
||||
|
||||
if(Session::get('install') != 3){
|
||||
return redirect('./create.html');
|
||||
}
|
||||
//if(Session::get('install') != 3){
|
||||
// return redirect('./create.html');
|
||||
//}
|
||||
|
||||
// 判断是否为post
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
||||
$data = $_POST;
|
||||
//if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if(Request::isAjax()){
|
||||
$data = Request::param();
|
||||
//$data = $_POST;
|
||||
//var_dump($data);
|
||||
if (!preg_match("/^[a-zA-Z]{1}([0-9a-zA-Z]|[._]){4,19}$/", $data['admin_user'])) {
|
||||
die("<script>alert('后台管理用户名不符合规范:至少包含4个字符,需以字母开头');history.go(-1)</script>");
|
||||
@ -194,10 +195,11 @@ php;
|
||||
//安装上锁
|
||||
file_put_contents('../install.lock', 'lock');
|
||||
Session::clear();
|
||||
return View::fetch('complete');
|
||||
//return View::fetch('complete');
|
||||
return json(['code' => 0,'msg'=>'安装成功','url'=>'/install.php/success/complete']);
|
||||
} else {
|
||||
return '安装失败';
|
||||
}
|
||||
return '请求失败!';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
14
app/install/controller/Success.php
Normal file
14
app/install/controller/Success.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace app\install\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use think\facade\View;
|
||||
|
||||
class Success extends BaseController
|
||||
{
|
||||
// 安装成功页面
|
||||
public function complete(){
|
||||
return View::fetch('complete');
|
||||
}
|
||||
|
||||
}
|
@ -22,3 +22,6 @@ $response = $http->run();
|
||||
$response->send();
|
||||
|
||||
$http->end($response);
|
||||
if(file_exists('../install.lock') != 'true'){
|
||||
header('Location: http://www.tp6.com/install.php');
|
||||
}
|
24
public/install.php
Normal file
24
public/install.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// [ 应用入口文件 ]
|
||||
namespace think;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// 执行HTTP应用并响应
|
||||
$http = (new App())->http;
|
||||
|
||||
$response = $http->run();
|
||||
|
||||
$response->send();
|
||||
|
||||
$http->end($response);
|
@ -18,7 +18,7 @@
|
||||
<a>拒绝安装</a>
|
||||
</div>
|
||||
<div class="inout2">
|
||||
<a href="{:url('install/index/test')}">同意安装</a>
|
||||
<a href="{:url('/index/test')}">同意安装</a>
|
||||
</div>
|
||||
</div>
|
||||
</br>
|
||||
|
@ -3,7 +3,7 @@
|
||||
{block name="body"}
|
||||
<div class="inside2">
|
||||
<div class="inwp cl">
|
||||
<form class="layui-form layui-form-pane" action="/install/index/complete" method="post">
|
||||
<form class="layui-form layui-form-pane" >
|
||||
<h2>创建数据库:</h2>
|
||||
|
||||
<input type="hidden" name="DB_TYPE" value="mysql">
|
||||
@ -85,7 +85,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="inout1">
|
||||
<a href="/install/index/test">上一步</a>
|
||||
<a href="{:url('/index/test')}">上一步</a>
|
||||
</div>
|
||||
<div class="inout2">
|
||||
<input type="submit" lay-submit lay-filter="formDemo" value="确认安装">
|
||||
@ -93,7 +93,45 @@
|
||||
</form>
|
||||
<script>
|
||||
layui.use('form', function() {
|
||||
var form = layui.form;
|
||||
var $ = layui.jquery,
|
||||
form = layui.form;
|
||||
|
||||
form.on('submit(formDemo)', function(data){
|
||||
var field = data.field;
|
||||
//console.log(field); //当前容器的全部表单字段,名值对形式:{name: value}
|
||||
loading = layer.load(2, {
|
||||
shade: [0.2, '#000'],
|
||||
time: 2000,
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type:"post",
|
||||
url:"{:url('/index/install')}",
|
||||
data:{"DB_TYPE":field.DB_TYPE,"DB_HOST":field.DB_HOST,"DB_USER":field.DB_USER,"DB_PWD":field.DB_PWD,"DB_PORT":field.DB_PORT,"DB_NAME":field.DB_NAME,"DB_PREFIX":field.DB_PREFIX,"webname":field.webname,"webtitle":field.webtitle,"admin_user":field.admin_user,"admin_email":field.admin_email,"admin_pass":field.admin_pass,"admin_pass2":field.admin_pass2},
|
||||
daType:"json",
|
||||
success:function (data){
|
||||
if (data.code == 0) {
|
||||
layer.close(loading);
|
||||
layer.msg(data.msg,{
|
||||
icon:6,
|
||||
time:2000
|
||||
}, function(){
|
||||
location.href = data.url;
|
||||
});
|
||||
} else {
|
||||
layer.open({
|
||||
tiele:'安装失败',
|
||||
content:data.msg,
|
||||
icon:5,
|
||||
anim:6
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
@ -85,7 +85,7 @@
|
||||
</tr>
|
||||
</table>
|
||||
<div class="inout1">
|
||||
<a href="/install/index/index">上一步</a>
|
||||
<a href="{:url('/index/index')}">上一步</a>
|
||||
</div>
|
||||
<div class="inout2">
|
||||
<a href="javascript:;" onclick="testClick()">下一步</a>
|
||||
@ -97,7 +97,7 @@
|
||||
if ($('.yes').length != 5) {
|
||||
alert('您的配置或权限不符合要求');
|
||||
} else {
|
||||
location.href = '{:url('install/index/create')}';
|
||||
location.href = '{:url('/index/create')}';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user