Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
38c99ec8
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,发现更多精彩内容 >>
提交
38c99ec8
编写于
6月 24, 2019
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
应用管理优化
上级
e99c0eb6
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
388 addition
and
215 deletion
+388
-215
application/admin/controller/Pluginsadmin.php
application/admin/controller/Pluginsadmin.php
+41
-27
application/admin/view/default/pluginsadmin/index.html
application/admin/view/default/pluginsadmin/index.html
+12
-9
application/service/PluginsAdminService.php
application/service/PluginsAdminService.php
+163
-135
config/app.php
config/app.php
+1
-1
config/shopxo.sql
config/shopxo.sql
+171
-43
未找到文件。
application/admin/controller/Pluginsadmin.php
浏览文件 @
38c99ec8
...
...
@@ -62,33 +62,7 @@ class Pluginsadmin extends Common
// 页面类型
if
(
$this
->
view_type
==
'home'
)
{
// 分页
$number
=
12
;
// 条件
$where
=
PluginsAdminService
::
PluginsListWhere
(
$params
);
// 获取总数
$total
=
PluginsAdminService
::
PluginsTotal
(
$where
);
// 分页
$page_params
=
array
(
'number'
=>
$number
,
'total'
=>
$total
,
'where'
=>
$params
,
'page'
=>
isset
(
$params
[
'page'
])
?
intval
(
$params
[
'page'
])
:
1
,
'url'
=>
MyUrl
(
'admin/pluginsadmin/index'
),
);
$page
=
new
\
base\Page
(
$page_params
);
$this
->
assign
(
'page_html'
,
$page
->
GetPageHtml
());
// 获取列表
$data_params
=
array
(
'm'
=>
$page
->
GetPageStarNumber
(),
'n'
=>
$number
,
'where'
=>
$where
,
);
$data
=
PluginsAdminService
::
PluginsList
(
$data_params
);
$data
=
PluginsAdminService
::
PluginsList
();
$this
->
assign
(
'data_list'
,
$data
[
'data'
]);
$this
->
assign
(
'store_url'
,
StoreService
::
StoreUrl
());
...
...
@@ -250,5 +224,45 @@ class Pluginsadmin extends Common
return
$ret
;
}
}
/**
* 安装
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-17
* @desc description
*/
public
function
Install
()
{
// 是否ajax请求
if
(
!
IS_AJAX
)
{
$this
->
error
(
'非法访问'
);
}
// 开始操作
return
PluginsAdminService
::
PluginsInstall
(
input
());
}
/**
* 卸载
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-17
* @desc description
*/
public
function
Uninstall
()
{
// 是否ajax请求
if
(
!
IS_AJAX
)
{
$this
->
error
(
'非法访问'
);
}
// 开始操作
return
PluginsAdminService
::
PluginsUninstall
(
input
());
}
}
?>
\ No newline at end of file
application/admin/view/default/pluginsadmin/index.html
浏览文件 @
38c99ec8
...
...
@@ -34,9 +34,17 @@
<a
href=
"{{:MyUrl('admin/pluginsadmin/download', array('id'=>$v['id']))}}"
class=
"am-btn am-btn-default am-btn-xs am-radius am-icon-download"
title=
"打包"
></a>
{{/if}}
{{if isset($v['is_install']) and $v['is_install'] eq 1}}
<a
href=
"{{:PluginsAdminUrl($v['plugins'], 'admin', 'index')}}"
class=
"am-btn am-btn-default am-btn-xs am-radius am-icon-gear"
title=
"设置"
></a>
<button
class=
"am-btn am-btn-default am-btn-xs am-radius am-icon-remove submit-delete-modal"
data-url=
"{{:MyUrl('admin/pluginsadmin/delete')}}"
data-id=
"{{$v.id}}"
title=
"删除"
></button>
<a
href=
"javascript:;"
class=
"am-icon-btn am-icon-check submit-state {{if $v['is_enable'] eq 1}}am-success{{else /}}am-default{{/if}}"
data-url=
"{{:MyUrl('admin/pluginsadmin/statusupdate')}}"
data-id=
"{{$v.id}}"
data-state=
"{{$v['is_enable']}}"
data-is-update-status=
"1"
title=
"状态"
></a>
<button
class=
"am-btn am-btn-default am-btn-xs am-radius am-icon-circle-o submit-ajax"
data-url=
"{{:MyUrl('admin/pluginsadmin/uninstall')}}"
data-id=
"{{$v.plugins}}"
data-view=
"reload"
data-msg=
"卸载将删除基础数据不可恢复、确认操作吗?"
title=
"卸载"
></button>
<a
href=
"javascript:;"
class=
"am-icon-btn am-icon-check submit-state {{if $v['is_enable'] eq 1}}am-success{{else /}}am-default{{/if}}"
data-url=
"{{:MyUrl('admin/pluginsadmin/statusupdate')}}"
data-id=
"{{$v.plugins}}"
data-state=
"{{$v['is_enable']}}"
data-is-update-status=
"1"
title=
"状态"
></a>
{{else /}}
<button
class=
"am-btn am-btn-default am-btn-xs am-radius am-icon-remove submit-delete-modal"
data-url=
"{{:MyUrl('admin/pluginsadmin/delete')}}"
data-id=
"{{$v.plugins}}"
title=
"删除"
></button>
<button
class=
"am-btn am-btn-default am-btn-xs am-radius am-icon-cubes submit-ajax"
data-url=
"{{:MyUrl('admin/pluginsadmin/install')}}"
data-id=
"{{$v.plugins}}"
data-view=
"reload"
data-msg=
"进行安装操作、确认继续吗?"
title=
"安装"
></button>
{{/if}}
{{if isset($v['is_home']) and $v['is_home'] eq true}}
<a
href=
"{{:PluginsHomeUrl($v['plugins'], 'index', 'index')}}"
class=
"am-btn am-btn-default am-btn-xs am-radius am-icon-home"
title=
"首页"
target=
"_blank"
></a>
...
...
@@ -47,12 +55,7 @@
{{/foreach}}
</ul>
<!-- page start -->
{{if !empty($data_list)}}
{{$page_html|raw}}
{{/if}}
<!-- page end -->
<!-- 删除弹层 -->
<div
class=
"am-modal am-modal-no-btn"
tabindex=
"-1"
id=
"plugins-delete-modal"
>
<div
class=
"am-modal-dialog"
>
<div
class=
"am-modal-hd"
>
...
...
application/service/PluginsAdminService.php
浏览文件 @
38c99ec8
...
...
@@ -37,41 +37,30 @@ class PluginsAdminService
*/
public
static
function
PluginsList
(
$params
=
[])
{
$where
=
empty
(
$params
[
'where'
])
?
[]
:
$params
[
'where'
];
$m
=
isset
(
$params
[
'm'
])
?
intval
(
$params
[
'm'
])
:
0
;
$n
=
isset
(
$params
[
'n'
])
?
intval
(
$params
[
'n'
])
:
10
;
$order_by
=
empty
(
$params
[
'order_by'
])
?
'id desc'
:
$params
[
'order_by'
];
// 获取数据列表
$data
=
Db
::
name
(
'Plugins'
)
->
where
(
$where
)
->
limit
(
$m
,
$n
)
->
order
(
$order_by
)
->
select
();
return
DataReturn
(
'处理成功'
,
0
,
self
::
PluginsDataHandle
(
$data
));
}
/**
* 数据处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $data [数据]
*/
private
static
function
PluginsDataHandle
(
$data
)
$data
=
[];
$plugins_dir
=
APP_PATH
.
'plugins'
.
DS
;
if
(
is_dir
(
$plugins_dir
))
{
$result
=
[];
if
(
!
empty
(
$data
))
if
(
$dh
=
opendir
(
$plugins_dir
))
{
foreach
(
$data
as
$v
)
while
((
$temp_file
=
readdir
(
$dh
))
!==
false
)
{
$config
=
self
::
GetPluginsConfig
(
$v
[
'plugins'
]);
if
(
!
in_array
(
$temp_file
,
[
'.'
,
'..'
,
'/'
,
'view'
,
'index.html'
])
&&
substr
(
$temp_file
,
0
,
1
)
!=
'.'
)
{
// 获取插件配置信息
$config
=
self
::
GetPluginsConfig
(
$temp_file
);
if
(
$config
!==
false
)
{
// 获取数据库配置信息
$db_config
=
Db
::
name
(
'Plugins'
)
->
where
([
'plugins'
=>
$config
[
'base'
][
'plugins'
]])
->
find
();
// 数据组装
$base
=
$config
[
'base'
];
$result
[]
=
[
'id'
=>
$v
[
'id'
],
'plugins'
=>
$v
[
'plugins'
],
'is_enable'
=>
$v
[
'is_enable'
],
$data
[]
=
[
'id'
=>
date
(
'YmdHis'
)
.
GetNumberCode
(
8
),
'plugins'
=>
isset
(
$base
[
'plugins'
])
?
$base
[
'plugins'
]
:
''
,
'is_enable'
=>
isset
(
$db_config
[
'is_enable'
])
?
$db_config
[
'is_enable'
]
:
0
,
'is_install'
=>
empty
(
$db_config
)
?
0
:
1
,
'logo_old'
=>
$base
[
'logo'
],
'logo'
=>
ResourcesService
::
AttachmentPathViewHandle
(
$base
[
'logo'
]),
'is_home'
=>
isset
(
$base
[
'is_home'
])
?
$base
[
'is_home'
]
:
false
,
...
...
@@ -82,43 +71,114 @@ class PluginsAdminService
'desc'
=>
isset
(
$base
[
'desc'
])
?
$base
[
'desc'
]
:
''
,
'apply_version'
=>
isset
(
$base
[
'apply_version'
])
?
$base
[
'apply_version'
]
:
[],
'apply_terminal'
=>
isset
(
$base
[
'apply_terminal'
])
?
$base
[
'apply_terminal'
]
:
[],
'add_time_time'
=>
date
(
'Y-m-d H:i:s'
,
$v
[
'add_time'
])
,
'add_time_date'
=>
date
(
'Y-m-d'
,
$v
[
'add_time'
])
,
'add_time_time'
=>
isset
(
$db_config
[
'add_time'
])
?
date
(
'Y-m-d H:i:s'
,
$db_config
[
'add_time'
])
:
''
,
'add_time_date'
=>
isset
(
$db_config
[
'add_time'
])
?
date
(
'Y-m-d'
,
$db_config
[
'add_time'
])
:
''
,
];
}
}
}
closedir
(
$dh
);
}
}
return
$result
;
return
DataReturn
(
'处理成功'
,
0
,
$data
)
;
}
/**
*
总数
*
应用安装
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-
29
* @date 2018-09-
17
* @desc description
* @param [array] $
where [条件
]
* @param [array] $
params [输入参数
]
*/
public
static
function
PluginsTotal
(
$where
=
[])
public
static
function
PluginsInstall
(
$params
=
[])
{
// 参数
if
(
empty
(
$params
[
'id'
]))
{
return
DataReturn
(
'参数错误'
,
-
1
);
}
// 数据处理
$config
=
self
::
GetPluginsConfig
(
$params
[
'id'
]);;
if
(
$config
!==
false
)
{
$data
=
[
'plugins'
=>
$params
[
'id'
],
'is_enable'
=>
0
,
'add_time'
=>
time
(),
];
// 添加数据
if
(
Db
::
name
(
'Plugins'
)
->
insertGetId
(
$data
)
>
0
)
{
return
(
int
)
Db
::
name
(
'Plugins'
)
->
where
(
$where
)
->
count
();
return
DataReturn
(
'安装成功'
);
}
else
{
return
DataReturn
(
'安装失败'
,
-
100
);
}
}
else
{
return
DataReturn
(
'插件配置有误'
,
-
10
);
}
}
/**
*
列表条件
*
卸载应用
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-
29
* @date 2018-09-
17
* @desc description
* @param [array] $params [输入参数]
*/
public
static
function
PluginsListWhere
(
$params
=
[])
public
static
function
PluginsUninstall
(
$params
=
[])
{
// 参数
if
(
empty
(
$params
[
'id'
]))
{
return
DataReturn
(
'参数错误'
,
-
1
);
}
// 开启事务
Db
::
startTrans
();
// 开始卸载
if
(
db
(
'Plugins'
)
->
where
([
'plugins'
=>
$params
[
'id'
]])
->
delete
())
{
// 钩子部署
$ret
=
self
::
PluginsHookDeployment
();
if
(
$ret
[
'code'
]
==
0
)
{
// 提交事务
Db
::
commit
();
return
DataReturn
(
'卸载成功'
);
}
}
// 事务回退
Db
::
rollback
();
return
DataReturn
(
'卸载失败'
,
-
100
);
}
/**
* 获取插件配置信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-17
* @desc description
* @param [string] $plugins [插件名称]
*/
private
static
function
GetPluginsConfig
(
$plugins
)
{
$config
=
[];
$file
=
APP_PATH
.
'plugins'
.
DS
.
$plugins
.
DS
.
'config.json'
;
if
(
file_exists
(
$file
))
{
$where
=
[];
return
$where
;
$config
=
json_decode
(
file_get_contents
(
$file
),
true
);
}
return
empty
(
$config
)
?
false
:
$config
;
}
/**
...
...
@@ -155,7 +215,7 @@ class PluginsAdminService
Db
::
startTrans
();
// 数据更新
if
(
Db
::
name
(
'Plugins'
)
->
where
([
'
id
'
=>
$params
[
'id'
]])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
]),
'upd_time'
=>
time
()]))
if
(
Db
::
name
(
'Plugins'
)
->
where
([
'
plugins
'
=>
$params
[
'id'
]])
->
update
([
'is_enable'
=>
intval
(
$params
[
'state'
]),
'upd_time'
=>
time
()]))
{
// 钩子部署
$ret
=
self
::
PluginsHookDeployment
();
...
...
@@ -294,20 +354,19 @@ class PluginsAdminService
return
DataReturn
(
$ret
,
-
1
);
}
// 获取应用标记
$where
=
[
'id'
=>
intval
(
$params
[
'id'
])];
$plugins
=
Db
::
name
(
'Plugins'
)
->
where
(
$where
)
->
value
(
'plugins'
);
if
(
empty
(
$plugins
))
// 应用是否存在
if
(
!
file_exists
(
APP_PATH
.
'plugins'
.
DS
.
$params
[
'id'
]))
{
return
DataReturn
(
'应用不存在'
,
-
10
);
}
// 开启事务
Db
::
startTrans
();
// 删除操作
if
(
Db
::
name
(
'Plugins'
)
->
where
(
$where
)
->
delete
())
// 获取应用标记
$data
=
Db
::
name
(
'Plugins'
)
->
where
([
'plugins'
=>
$params
[
'id'
]])
->
find
();
if
(
!
empty
(
$data
[
'is_enable'
]))
{
return
DataReturn
(
'请先卸载应用'
,
-
10
);
}
// 钩子部署
$ret
=
self
::
PluginsHookDeployment
();
if
(
$ret
[
'code'
]
==
0
)
...
...
@@ -316,7 +375,7 @@ class PluginsAdminService
$is_delete_static
=
(
isset
(
$params
[
'value'
])
&&
$params
[
'value'
]
==
1
);
if
(
$is_delete_static
===
true
)
{
$uninstall_sql
=
APP_PATH
.
'plugins'
.
DS
.
$plugins
.
DS
.
'uninstall.sql'
;
$uninstall_sql
=
APP_PATH
.
'plugins'
.
DS
.
$params
[
'id'
]
.
DS
.
'uninstall.sql'
;
if
(
file_exists
(
$uninstall_sql
))
{
SqlconsoleService
::
Implement
([
'sql'
=>
file_get_contents
(
$uninstall_sql
)]);
...
...
@@ -324,18 +383,10 @@ class PluginsAdminService
}
// 删除应用文件
self
::
PluginsResourcesDelete
(
$plugins
,
$is_delete_static
);
self
::
PluginsResourcesDelete
(
$params
[
'id'
]
,
$is_delete_static
);
// 提交事务
Db
::
commit
();
return
DataReturn
(
'删除成功'
);
}
}
else
{
$ret
=
DataReturn
(
'删除失败或资源不存在'
,
-
100
);
}
// 事务回退
Db
::
rollback
();
return
$ret
;
}
...
...
@@ -366,25 +417,6 @@ class PluginsAdminService
}
}
/**
* 获取应用配置信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-17
* @desc description
* @param [string] $plugins [应用名称]
*/
private
static
function
GetPluginsConfig
(
$plugins
)
{
$config_file
=
APP_PATH
.
'plugins'
.
DS
.
$plugins
.
DS
.
'config.json'
;
if
(
file_exists
(
$config_file
))
{
return
json_decode
(
file_get_contents
(
$config_file
),
true
);
}
return
false
;
}
/**
* 保存
* @author Devil
...
...
@@ -460,13 +492,24 @@ class PluginsAdminService
// 应用唯一标记
$plugins
=
trim
(
$params
[
'plugins'
]);
// 应用
不存在则添加
$ret
=
self
::
Plugins
ExistInsert
(
$params
,
$plugins
);
// 应用
校验
$ret
=
self
::
Plugins
Verification
(
$plugins
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 应用是否已存在数据库
$plugins_id
=
Db
::
name
(
'Plugins'
)
->
where
([
'plugins'
=>
$plugins
])
->
value
(
'id'
);
if
(
empty
(
$plugins_id
))
{
$plugins_id
=
Db
::
name
(
'Plugins'
)
->
insertGetId
([
'plugins'
=>
$plugins
,
'is_enable'
=>
0
,
'add_time'
=>
time
()]);
if
(
empty
(
$plugins_id
))
{
return
DataReturn
(
'应用添加失败'
,
-
100
);
}
}
// 应用目录不存在则创建
$app_dir
=
APP_PATH
.
'plugins'
.
DS
.
$plugins
;
if
(
\
base\FileUtil
::
CreateDir
(
$app_dir
)
!==
true
)
...
...
@@ -826,10 +869,9 @@ php;
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-05-13T00:00:45+0800
* @param [array] $params [输入参数]
* @param [string] $plugins [应用唯一标记]
*/
public
static
function
PluginsVerification
(
$p
arams
,
$p
lugins
)
public
static
function
PluginsVerification
(
$plugins
)
{
// 排除校验
if
(
in_array
(
$plugins
,
self
::
$plugins_exclude_verification
))
...
...
@@ -837,13 +879,6 @@ php;
return
DataReturn
(
'不能使用限制的名称['
.
$plugins
.
']'
,
-
1
);
}
// 应用是否存在
$temp_plugins
=
Db
::
name
(
'Plugins'
)
->
where
([
'plugins'
=>
$plugins
])
->
value
(
'plugins'
);
if
(
empty
(
$params
[
'id'
])
&&
$temp_plugins
==
$plugins
)
{
return
DataReturn
(
'应用名称已存在['
.
$plugins
.
']'
,
-
1
);
}
return
DataReturn
(
'校验成功'
,
0
);
}
...
...
@@ -854,29 +889,14 @@ php;
* @version 1.0.0
* @date 2018-12-18
* @desc description
* @param [array] $params [输入参数]
* @param [string] $plugins [应用唯一标记]
*/
private
static
function
PluginsExistInsert
(
$params
,
$plugins
)
{
// 名称校验
$ret
=
self
::
PluginsVerification
(
$params
,
$plugins
);
if
(
$ret
[
'code'
]
!=
0
)
private
static
function
PluginsExist
(
$plugins
)
{
return
$ret
;
}
// 应用添加
if
(
empty
(
$params
[
'id'
]))
{
$temp_plugins
=
Db
::
name
(
'Plugins'
)
->
where
([
'plugins'
=>
$plugins
])
->
value
(
'plugins'
);
if
(
empty
(
$temp_plugins
))
{
if
(
Db
::
name
(
'Plugins'
)
->
insertGetId
([
'plugins'
=>
$plugins
,
'is_enable'
=>
0
,
'add_time'
=>
time
()])
<=
0
)
// 应用是否存在
if
(
is_dir
(
APP_PATH
.
'plugins'
.
DS
.
$plugins
))
{
return
DataReturn
(
'应用添加失败'
,
-
1
);
}
}
return
DataReturn
(
'应用名称已存在['
.
$plugins
.
']'
,
-
1
);
}
return
DataReturn
(
'添加成功'
,
0
);
...
...
@@ -1001,7 +1021,15 @@ php;
{
// 应用不存在则添加
$plugins_name
=
substr
(
$file
,
0
,
strpos
(
$file
,
'/'
));
$ret
=
self
::
PluginsExistInsert
([],
$plugins_name
);
$ret
=
self
::
PluginsVerification
(
$plugins_name
);
if
(
$ret
[
'code'
]
!=
0
)
{
zip_entry_close
(
$temp_resource
);
return
$ret
;
}
// 应用是否存在
$ret
=
self
::
PluginsExist
(
$plugins_name
);
if
(
$ret
[
'code'
]
!=
0
)
{
zip_entry_close
(
$temp_resource
);
...
...
config/app.php
浏览文件 @
38c99ec8
...
...
@@ -19,7 +19,7 @@ return [
// 应用地址
'app_host'
=>
''
,
// 应用调试模式
'app_debug'
=>
fals
e
,
'app_debug'
=>
tru
e
,
// 应用Trace
'app_trace'
=>
false
,
// 是否支持多模块
...
...
config/shopxo.sql
浏览文件 @
38c99ec8
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录