Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hexbee
Cloudreve
提交
956deac8
C
Cloudreve
项目概览
hexbee
/
Cloudreve
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cloudreve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
956deac8
编写于
3月 11, 2018
作者:
H
HFO4
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
数据库升级逻辑
上级
4964f53d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
1 deletion
+44
-1
application/index/controller/Admin.php
application/index/controller/Admin.php
+32
-0
application/index/model/AdminHandler.php
application/index/model/AdminHandler.php
+11
-0
application/version.json
application/version.json
+1
-1
未找到文件。
application/index/controller/Admin.php
浏览文件 @
956deac8
...
...
@@ -29,12 +29,44 @@ class Admin extends Controller{
}
public
function
index
(){
if
(
$this
->
adminObj
->
checkDbVersion
()){
$this
->
redirect
(
url
(
'/Admin/UpdateDb'
,
''
,
''
));
exit
();
}
return
view
(
'admin_index'
,
[
'options'
=>
$this
->
siteOptions
,
'statics'
=>
$this
->
adminObj
->
getStatics
(),
]);
}
public
function
UpdateDb
(){
if
(
!
$this
->
adminObj
->
checkDbVersion
()){
$this
->
redirect
(
url
(
'/Admin'
,
''
,
''
));
exit
();
}
echo
"<meta charset='utf-8'>"
;
echo
"准备升级数据库,当前数据库版本:"
.
$this
->
adminObj
->
dbVerInfo
[
"now"
];
echo
", 目标数据库版本:"
.
$this
->
adminObj
->
dbVerInfo
[
"require"
]
.
";<br>"
;
$updatePath
=
ROOT_PATH
.
"update_"
.
$this
->
adminObj
->
dbVerInfo
[
"now"
]
.
"to"
.
$this
->
adminObj
->
dbVerInfo
[
"require"
]
.
".sql"
;
if
(
!
file_exists
(
$updatePath
)){
die
(
"数据库更新文件("
.
$updatePath
.
")不存在,升级中止."
);
}
echo
"获取升级SQL文件("
.
$updatePath
.
")<br>"
;
$updateContent
=
file_get_contents
(
$updatePath
);
echo
"将执行以下指令:<br>"
;
echo
"<code>"
.
htmlspecialchars
(
$updateContent
)
.
"</code><br>"
;
$sqlSingle
=
explode
(
";"
,
$updateContent
);
foreach
(
$sqlSingle
as
$key
=>
$value
){
if
(
empty
(
$value
)){
continue
;
}
if
(
!
Db
::
execute
(
$value
)){
echo
"<strong>执行
$value
时出现错误</strong><br>"
;
}
}
echo
"<strong>升级完成,<a href='/Admin'>返回管理面板</a></strong>"
;
}
public
function
Setting
(){
return
view
(
'basic_setting'
,
[
'options'
=>
$this
->
siteOptions
,
...
...
application/index/model/AdminHandler.php
浏览文件 @
956deac8
...
...
@@ -14,11 +14,22 @@ class AdminHandler extends Model{
public
$pageNow
;
public
$pageTotal
;
public
$dataTotal
;
public
$dbVerInfo
;
public
function
__construct
(
$options
){
$this
->
siteOptions
=
$options
;
}
public
function
checkDbVersion
(){
$versionInfo
=
json_decode
(
@
file_get_contents
(
ROOT_PATH
.
"application/version.json"
),
true
);
$dbVerNow
=
Option
::
getValue
(
"database_version"
);
if
(
!
isset
(
$versionInfo
[
"db_version"
])
||
$dbVerNow
<
(
int
)
$versionInfo
[
"db_version"
]){
$this
->
dbVerInfo
=
array
(
'now'
=>
$dbVerNow
,
'require'
=>
$versionInfo
[
"db_version"
]);
return
true
;
}
return
false
;
}
public
function
getStatics
(){
$statics
[
"fileNum"
]
=
Db
::
name
(
'files'
)
->
count
();
$statics
[
"privateShareNum"
]
=
Db
::
name
(
'shares'
)
->
where
(
"type"
,
"private"
)
->
count
();
...
...
application/version.json
浏览文件 @
956deac8
{
"type"
:
""
,
"version"
:
"1.0.2"
,
"version_id"
:
3
}
\ No newline at end of file
{
"type"
:
""
,
"version"
:
"1.0.2"
,
"version_id"
:
3
,
"db_version"
:
2
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录