Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
add781ff
ShopXO
项目概览
starsw001
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
add781ff
编写于
12月 28, 2018
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
安装程序
上级
68a2360e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
52 addition
and
16 deletion
+52
-16
application/install/controller/Index.php
application/install/controller/Index.php
+49
-13
application/install/view/index/create.html
application/install/view/index/create.html
+1
-1
application/install/view/index/successful.html
application/install/view/index/successful.html
+1
-1
public/static/common/js/common.js
public/static/common/js/common.js
+1
-1
未找到文件。
application/install/controller/Index.php
浏览文件 @
add781ff
...
...
@@ -26,6 +26,23 @@ class Index extends Common
parent
::
__construct
();
}
/**
* 是否已安装
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-28
* @desc description
*/
private
function
IsInstall
()
{
// 是否已安装
if
(
file_exists
(
ROOT
.
'public/install/install.lock'
))
{
exit
(
'你已经安装过该系统,重新安装需要先删除 ./public/install/install.lock 文件'
);
}
}
/**
* 协议
* @author Devil
...
...
@@ -36,6 +53,7 @@ class Index extends Common
*/
public
function
Index
()
{
$this
->
IsInstall
();
return
$this
->
fetch
();
}
...
...
@@ -49,6 +67,7 @@ class Index extends Common
*/
public
function
Check
()
{
$this
->
IsInstall
();
return
$this
->
fetch
();
}
...
...
@@ -62,6 +81,7 @@ class Index extends Common
*/
public
function
Create
()
{
$this
->
IsInstall
();
return
$this
->
fetch
();
}
...
...
@@ -137,7 +157,7 @@ class Index extends Common
}
// 创建数据表
$ret
=
$this
->
CreateTable
(
$db
);
$ret
=
$this
->
CreateTable
(
$db
,
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
...
...
@@ -229,7 +249,7 @@ php;
{
return
DataReturn
(
'配置文件创建失败'
,
-
1
);
}
return
DataReturn
(
'
success
'
,
0
);
return
DataReturn
(
'
安装成功
'
,
0
);
}
/**
...
...
@@ -239,28 +259,41 @@ php;
* @date 2018-12-28
* @desc description
* @param [object] $db [db对象]
* @param [array] $params [输入参数]
*/
private
function
CreateTable
(
$db
)
private
function
CreateTable
(
$db
,
$params
)
{
if
(
!
file_exists
(
ROOT
.
'public/install/shopxo.sql'
))
{
return
DataReturn
(
'数据库sql文件不存在'
,
-
1
);
}
// 导入sql数据并创建表
$sql_array
=
preg_split
(
"/;[
\r\n
]+/"
,
str_replace
(
'`s_'
,
'`'
.
$params
[
'DB_PREFIX'
],
file_get_contents
(
ROOT
.
'public/install/shopxo.sql'
)));
// sql文件
$sql
=
file_get_contents
(
ROOT
.
'public/install/shopxo.sql'
);
//替换表前缀
$sql
=
str_replace
(
"`s_"
,
" `
{
$params
[
'DB_PREFIX'
]
}
"
,
$sql
);
// 转为数组
$sql_all
=
preg_split
(
"/;[
\r\n
]+/"
,
$sql
);
$success
=
0
;
$failure
=
0
;
foreach
(
$sql_a
rray
as
$v
)
foreach
(
$sql_a
ll
as
$v
)
{
if
(
!
empty
(
$v
))
{
if
(
$db
->
query
(
$v
)
)
if
(
substr
(
$v
,
0
,
12
)
==
'CREATE TABLE'
)
{
$success
++
;
if
(
$db
->
execute
(
$v
)
!==
false
)
{
$success
++
;
}
else
{
$failure
++
;
}
}
else
{
$
failure
++
;
}
$
db
->
execute
(
$v
)
;
}
}
}
...
...
@@ -274,7 +307,7 @@ php;
}
// 创建成功标记文件
@
file_put_contents
(
ROOT
.
'public/install/install.lock'
);
@
touch
(
ROOT
.
'public/install/install.lock'
);
return
DataReturn
(
'success'
,
0
,
$result
);
}
...
...
@@ -366,9 +399,12 @@ php;
// 数据库连接端口
'hostport'
=>
$params
[
'DB_PORT'
],
// 数据库连接参数
'params'
=>
[],
'params'
=>
[
\
PDO
::
ATTR_CASE
=>
\
PDO
::
CASE_LOWER
,
\
PDO
::
ATTR_EMULATE_PREPARES
=>
true
,
],
// 数据库编码默认采用utf8
'charset'
=>
'utf8'
,
'charset'
=>
'utf8
mb4
'
,
// 数据库表前缀
'prefix'
=>
$params
[
'DB_PREFIX'
],
]);
...
...
application/install/view/index/create.html
浏览文件 @
add781ff
...
...
@@ -6,7 +6,7 @@
<!-- conntent start -->
<div
class=
"am-g inside create"
>
<h2>
数据库信息
</h2>
<form
class=
"am-form am-form-horizontal form-validation"
method=
"post"
action=
"{{:MyUrl('install/index/add')}}"
request-type=
"ajax-url"
request-value=
"{{:MyUrl('install/index/success
')}}
"
>
<form
class=
"am-form am-form-horizontal form-validation"
method=
"post"
action=
"{{:MyUrl('install/index/add')}}"
request-type=
"ajax-url"
request-value=
"{{:MyUrl('install/index/success
ful')}}"
timeout=
"60000
"
>
<div
class=
"am-form-group"
>
<label
class=
"am-u-sm-2 am-form-label"
>
数据库类型
</label>
<div
class=
"am-u-sm-10"
>
...
...
application/install/view/index/successful.html
浏览文件 @
add781ff
...
...
@@ -5,7 +5,7 @@
<!-- conntent start -->
<div
class=
"am-g inside success"
>
<
a
href=
"javascript:;"
class=
"am-icon-btn am-success am-icon-sm am-icon-check"
></a
>
<
i
class=
"am-icon-btn am-success am-icon-sm am-icon-check"
></i
>
<h2>
恭喜您安装成功
</h2>
<div
class=
"box"
>
<a
href=
"{{$Think.__MY_URL__}}index.php?s=/admin/index/index"
target=
"_blank"
>
后台管理
</a><br
/>
...
...
public/static/common/js/common.js
浏览文件 @
add781ff
...
...
@@ -379,7 +379,7 @@ function FromInit(form_name)
url
:
action
,
type
:
method
,
dataType
:
"
json
"
,
timeout
:
10000
,
timeout
:
$form
.
attr
(
'
timeout
'
)
||
10000
,
data
:
GetFormVal
(
form_name
),
processData
:
false
,
contentType
:
false
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录