Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
纵之格
ShopXO
提交
fc137da5
ShopXO
项目概览
纵之格
/
ShopXO
通知
394
Star
16
Fork
11
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fc137da5
编写于
3月 25, 2019
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
应用打包
上级
63bb409f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
149 addition
and
2 deletion
+149
-2
application/service/PluginsAdminService.php
application/service/PluginsAdminService.php
+101
-2
extend/base/FileUtil.php
extend/base/FileUtil.php
+48
-0
未找到文件。
application/service/PluginsAdminService.php
浏览文件 @
fc137da5
...
...
@@ -1018,8 +1018,107 @@ php;
return
DataReturn
(
'应用不存在'
,
-
10
);
}
// 开始打包
return
DataReturn
(
'开发中'
,
-
10
);
// 目录不存在则创建
$new_dir
=
ROOT
.
'runtime'
.
DS
.
'data'
.
DS
.
'plugins_package'
.
DS
.
$plugins
;
\
base\FileUtil
::
CreateDir
(
$new_dir
);
// 复制包目录 - 控制器
$old_dir
=
APP_PATH
.
'plugins'
.
DS
.
$plugins
;
if
(
is_dir
(
$old_dir
))
{
if
(
\
base\FileUtil
::
CopyDir
(
$old_dir
,
$new_dir
.
DS
.
'_controller_'
.
DS
.
$plugins
)
!=
true
)
{
return
DataReturn
(
'项目包复制失败[控制器]'
,
-
2
);
}
}
// 复制包目录 - 视图
$old_dir
=
APP_PATH
.
'plugins'
.
DS
.
'view'
.
DS
.
$plugins
;
if
(
is_dir
(
$old_dir
))
{
if
(
\
base\FileUtil
::
CopyDir
(
$old_dir
,
$new_dir
.
DS
.
'_view_'
.
DS
.
$plugins
)
!=
true
)
{
return
DataReturn
(
'项目包复制失败[视图]'
,
-
2
);
}
}
// 复制包目录 - css
$old_dir
=
ROOT
.
'public'
.
DS
.
'static'
.
DS
.
'plugins'
.
DS
.
'css'
.
DS
.
$plugins
;
if
(
is_dir
(
$old_dir
))
{
if
(
\
base\FileUtil
::
CopyDir
(
$old_dir
,
$new_dir
.
DS
.
'_css_'
.
DS
.
$plugins
)
!=
true
)
{
return
DataReturn
(
'项目包复制失败[css]'
,
-
2
);
}
}
// 复制包目录 - js
$old_dir
=
ROOT
.
'public'
.
DS
.
'static'
.
DS
.
'plugins'
.
DS
.
'js'
.
DS
.
$plugins
;
if
(
is_dir
(
$old_dir
))
{
if
(
\
base\FileUtil
::
CopyDir
(
$old_dir
,
$new_dir
.
DS
.
'_js_'
.
DS
.
$plugins
)
!=
true
)
{
return
DataReturn
(
'项目包复制失败[js]'
,
-
2
);
}
}
// 复制包目录 - images
$old_dir
=
ROOT
.
'public'
.
DS
.
'static'
.
DS
.
'plugins'
.
DS
.
'images'
.
DS
.
$plugins
;
if
(
is_dir
(
$old_dir
))
{
if
(
\
base\FileUtil
::
CopyDir
(
$old_dir
,
$new_dir
.
DS
.
'_images_'
.
DS
.
$plugins
)
!=
true
)
{
return
DataReturn
(
'项目包复制失败[images]'
,
-
2
);
}
}
// 复制包目录 - uploadimages
$old_dir
=
ROOT
.
'public'
.
DS
.
'static'
.
DS
.
'upload'
.
DS
.
'images'
.
DS
.
'plugins_'
.
$plugins
;
if
(
is_dir
(
$old_dir
))
{
if
(
\
base\FileUtil
::
CopyDir
(
$old_dir
,
$new_dir
.
DS
.
'_uploadimages_'
.
DS
.
'plugins_'
.
$plugins
)
!=
true
)
{
return
DataReturn
(
'项目包复制失败[uploadimages]'
,
-
2
);
}
}
// 复制包目录 - uploadvideo
$old_dir
=
ROOT
.
'public'
.
DS
.
'static'
.
DS
.
'upload'
.
DS
.
'video'
.
DS
.
'plugins_'
.
$plugins
;
if
(
is_dir
(
$old_dir
))
{
if
(
\
base\FileUtil
::
CopyDir
(
$old_dir
,
$new_dir
.
DS
.
'_uploadvideo_'
.
DS
.
'plugins_'
.
$plugins
)
!=
true
)
{
return
DataReturn
(
'项目包复制失败[uploadvideo]'
,
-
2
);
}
}
// 复制包目录 - uploadfile
$old_dir
=
ROOT
.
'public'
.
DS
.
'static'
.
DS
.
'upload'
.
DS
.
'file'
.
DS
.
'plugins_'
.
$plugins
;
if
(
is_dir
(
$old_dir
))
{
if
(
\
base\FileUtil
::
CopyDir
(
$old_dir
,
$new_dir
.
DS
.
'_uploadfile_'
.
DS
.
'plugins_'
.
$plugins
)
!=
true
)
{
return
DataReturn
(
'项目包复制失败[uploadfile]'
,
-
2
);
}
}
// 生成压缩包
$zip
=
new
\
base\ZipFolder
();
if
(
!
$zip
->
zip
(
$new_dir
.
'.zip'
,
$new_dir
))
{
return
DataReturn
(
'压缩包生成失败'
,
-
100
);
}
// 生成成功删除目录
\
base\FileUtil
::
UnlinkDir
(
$new_dir
);
// 开始下载
if
(
\
base\FileUtil
::
DownloadFile
(
$new_dir
.
'.zip'
,
$plugins
.
'.zip'
))
{
@
unlink
(
$new_dir
.
'.zip'
);
}
else
{
return
DataReturn
(
'下载失败'
,
-
100
);
}
}
}
?>
\ No newline at end of file
extend/base/FileUtil.php
浏览文件 @
fc137da5
...
...
@@ -301,5 +301,53 @@ class FileUtil
copy
(
$file_url
,
$aim_url
);
return
true
;
}
/**
* 文件下载
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-25
* @desc description
* @param [string] $file_path [文件地址]
* @param [string] $show_name [显示名称]
*/
public
static
function
DownloadFile
(
$file_path
,
$show_name
)
{
if
(
is_file
(
$file_path
))
{
//打开文件
$file
=
fopen
(
$file_path
,
"r"
);
//返回的文件类型
Header
(
"Content-type: application/octet-stream"
);
//按照字节大小返回
Header
(
"Accept-Ranges: bytes"
);
//返回文件的大小
Header
(
"Accept-Length: "
.
filesize
(
$file_path
));
//这里设置客户端的弹出对话框显示的文件名
Header
(
"Content-Disposition: attachment; filename="
.
$show_name
);
//一次性将数据传输给客户端
//echo fread($file, filesize($file_path));
//一次只传输1024个字节的数据给客户端
//向客户端回送数据
$buffer
=
1024
;
//判断文件是否读完
while
(
!
feof
(
$file
))
{
//将文件读入内存
$file_data
=
fread
(
$file
,
$buffer
);
//每次向客户端回送1024个字节的数据
echo
$file_data
;
}
return
true
;
}
return
false
;
}
}
?>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录