更新安装方法,无需手动创建数据库即可完整系统安装

This commit is contained in:
hdm 2022-05-27 16:32:18 +08:00
parent 76886227c4
commit c984dd4f1c
5 changed files with 24 additions and 27 deletions

View File

@ -78,6 +78,7 @@ class Index
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$dbName = $data['DB_NAME'];
// 连接数据库
$link = @new mysqli("{$data['DB_HOST']}:{$data['DB_PORT']}", $data['DB_USER'], $data['DB_PWD']);
// 获取错误信息
@ -88,15 +89,17 @@ class Index
return to_assign(1, '数据库链接失败:' . $error);die;
}
// 设置字符集
$link->query("SET NAMES 'utf8'");
$link->query("SET NAMES 'utf8mb4'");
if ($link->server_info < 5.0) {
return to_assign(1, '请将您的mysql升级到5.0以上');die;
}
// 创建数据库并选中
if (!$link->select_db($data['DB_NAME'])) {
return to_assign(1, '未找到数据库' . $data['DB_NAME'] . ',请先自行创建数据库');die;
if (!$link->select_db($dbName)) {
//创建数据库
$sql = "CREATE DATABASE IF NOT EXISTS `{$dbName}` DEFAULT CHARACTER SET utf8mb4";
$link->query($sql);
}
$link->select_db($data['DB_NAME']);
$link->select_db($dbName);
// 导入sql数据并创建表
$fqcms_sql = file_get_contents(CMS_ROOT . '/app/install/data/gougucms.sql');
$sql_array = preg_split("/;[\r\n]+/", str_replace("cms_", $data['DB_PREFIX'], $fqcms_sql));
@ -105,10 +108,13 @@ class Index
$link->query($v);
}
}
$isTable = $link->query('SHOW TABLES LIKE "'.$data['DB_PREFIX'] . 'admin"');
if(!$isTable){
return to_assign(1, '创建数据库表失败,请检查是否有创建权限!');
}
//插入管理员信息
$username = get_params('username');
$password = get_params('password');
$username = $data['username'];
$password = $data['password'];
$nickname = '超级管理员';
$thumb = '/static/admin/images/icon.png';
$salt = set_salt(20);
@ -121,7 +127,7 @@ class Index
. "VALUES "
. "('$username','$password','$nickname','$thumb','$salt','$create_time','$update_time')";
if (!$link->query($create_admin_sql)) {
return to_assign(1, '创建管理员信息失败');
return to_assign(1, '创建管理员信息失败,请重试安装');
}
$link->close();
$db_str = "<?php

View File

@ -12,13 +12,10 @@
body {
width: 100%;
height: 100%;
background: url("/themes/admin_themes/lib/cms/images/bg.jpg");
background-size: cover;
background: url("/static/admin/images/bg_pattern.png"), #7b4397;
background: url("/static/admin/images/bg_pattern.png"), -webkit-linear-gradient(to left, #34a853, #4285f4);
/* Chrome 10-25, Safari 5.1-6 */
background: url("/static/admin/images/bg_pattern.png"), linear-gradient(to left, #34a853, #4285f4);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
</style>
</head>
@ -34,7 +31,7 @@
</ul>
</div>
<div style="padding:20px; background-color:#fff;line-height: 27px; border-radius:0 0 6px 6px">
<p>勾股CMS是一套基于ThinkPHP{$TP_VERSION} + Layui{:LAYUI_VERSION} + MySql打造的轻量级、高性能快速建站的内容管理系统。后台管理模块,一目了然,操作简单,通用型后台权限管理框架,紧随潮流、开箱即用让WEB开发更简单<br><br>
<p>勾股CMS是一套基于ThinkPHP{$TP_VERSION} + Layui{:LAYUI_VERSION} + MySql打造的轻量级、高性能快速建站的内容管理系统通用型后台权限管理框架开箱即用让WEB开发更简单<br><br>
<strong>开源协议:</strong><br>
本系统遵循Apache Lisense 2.0开源协议发布,并提供免费使用。<br>
Apache Licence是著名的非盈利开源组织Apache采用的协议。该协议和BSD类似鼓励代码共享和尊重原作者的著作权允许代码修改再作为开源或商业软件发布。需要满足的条件<br>

View File

@ -12,13 +12,10 @@
body {
width: 100%;
height: 100%;
background: url("/themes/admin_themes/lib/cms/images/bg.jpg");
background-size: cover;
background: url("/static/admin/images/bg_pattern.png"), #7b4397;
background: url("/static/admin/images/bg_pattern.png"), -webkit-linear-gradient(to left, #34a853, #4285f4);
/* Chrome 10-25, Safari 5.1-6 */
background: url("/static/admin/images/bg_pattern.png"), linear-gradient(to left, #34a853, #4285f4);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
</style>
</head>

View File

@ -12,19 +12,16 @@
body {
width: 100%;
height: 100%;
background: url("{__IMG__}/bg.jpg");
background-size: cover;
background: url("{__IMG__}/bg_pattern.png"), #7b4397;
background: url("{__IMG__}/bg_pattern.png"), -webkit-linear-gradient(to left, #34a853, #4285f4);
/* Chrome 10-25, Safari 5.1-6 */
background: url("{__IMG__}/bg_pattern.png"), linear-gradient(to left, #34a853, #4285f4);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
background: url("/static/admin/images/bg_pattern.png"), #7b4397;
background: url("/static/admin/images/bg_pattern.png"), -webkit-linear-gradient(to left, #34a853, #4285f4);
background: url("/static/admin/images/bg_pattern.png"), linear-gradient(to left, #34a853, #4285f4);
}
</style>
</head>
<body>
<div style="width:200px;margin: 20px auto;"><img src="{__IMG__}/login_logo.png" alt="勾股CMS安装"
<div style="width:200px;margin: 20px auto;"><img src="/static/admin/images/login_logo.png" alt="勾股CMS安装"
width="200"></div>
<div style="width:888px;margin:0 auto 30px;">
<div class="layui-layout layui-layout-admin">
@ -65,9 +62,9 @@
<label class="layui-form-label">数据库名</label>
<div class="layui-input-inline">
<input type="text" name="DB_NAME" required lay-verify="required" autocomplete="off"
class="layui-input" value="" lay-reqText="请输入数据库名">
class="layui-input" value="gougucms" lay-reqText="请输入数据库名">
</div>
<div class="layui-form-mid layui-word-aux">系统数据库名,必须包含字母,不能有"-"等特殊符号</div>
<div class="layui-form-mid layui-word-aux">系统数据库名,必须包含字母,不能有"-"等特殊符号,最好是小写字母</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">用户名</label>
@ -86,7 +83,7 @@
<div class="layui-form-mid layui-word-aux">连接数据库的密码</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">表前缀</label>
<label class="layui-form-label">数据表前缀</label>
<div class="layui-input-inline">
<input type="text" name="DB_PREFIX" required lay-verify="required" autocomplete="off"
class="layui-input" value="cms_" lay-reqText="请输入数据库表前缀">
@ -95,7 +92,7 @@
</div>
<hr>
<h3>管理员配置</h3><br>
<h3>创始人信息</h3><br>
<div class="layui-form-item">
<label class="layui-form-label">管理员账号</label>
<div class="layui-input-block" style="max-width: 500px;">

View File

@ -18,7 +18,7 @@ return [
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
'database' => 'cms',
'database' => 'gougucms',
// 用户名
'username' => 'root',
// 密码