Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
9d6bdb4e
T
ThinkLibrary
项目概览
数据应用
/
ThinkLibrary
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
T
ThinkLibrary
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9d6bdb4e
编写于
8月 01, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 优化代码
上级
9335b3be
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
10 deletion
+21
-10
CHANGELOG.md
CHANGELOG.md
+3
-0
README.md
README.md
+4
-0
src/common.php
src/common.php
+1
-1
src/helper/Files.php
src/helper/Files.php
+8
-6
src/helper/Xmls.php
src/helper/Xmls.php
+5
-3
未找到文件。
CHANGELOG.md
浏览文件 @
9d6bdb4e
## v6.0.101 / 2020-07-25
-
优化代码
## v6.0.100 / 2020-07-25
-
优化淘宝客
...
...
README.md
浏览文件 @
9d6bdb4e
...
...
@@ -8,7 +8,11 @@
[
![Latest Unstable Version
](
https://poser.pugx.org/liguangchun/think-library/v/unstable
)
](https://packagist.org/packages/liguangchun/think-library)
[
![Total Downloads
](
https://poser.pugx.org/liguangchun/think-library/downloads
)
](https://packagist.org/packages/liguangchun/think-library)
[
![License
](
https://poser.pugx.org/liguangchun/think-library/license
)
](https://packagist.org/packages/liguangchun/think-library)
[
![PHP Version
](
https://img.shields.io/badge/php-%3E%3D7.1-8892BF.svg
)
](http://www.php.net/)
[
![Code Health
](
https://hn.devcloud.huaweicloud.com/codecheck/v1/codecheck/task/codehealth.svg?taskId=1567f5ea332546c3b45f4024cf50f10b
)
](https://hn.devcloud.huaweicloud.com/codecheck/project/c7ff3e2d65674858bd363cb43ee6c35e/codecheck/task/1567f5ea332546c3b45f4024cf50f10b/detail)
[
![Build Status
](
https://travis-ci.org/GC0202/ThinkLibrary.svg?branch=6.0
)
](https://travis-ci.org/GC0202/ThinkLibrary)
[
![Scrutinizer Code Quality
](
https://scrutinizer-ci.com/g/GC0202/ThinkLibrary/badges/quality-score.png?b=6.0
)
](https://scrutinizer-ci.com/g/GC0202/ThinkLibrary/?branch=6.0)
[
![Code Coverage
](
https://scrutinizer-ci.com/g/GC0202/ThinkLibrary/badges/coverage.png?b=6.0
)
](https://scrutinizer-ci.com/g/GC0202/ThinkLibrary/?branch=6.0)
## 依赖环境
...
...
src/common.php
浏览文件 @
9d6bdb4e
...
...
@@ -26,7 +26,7 @@ use think\db\exception\DbException;
/**
* 定义当前版本
*/
const
VERSION
=
'6.0.10
0
'
;
const
VERSION
=
'6.0.10
1
'
;
if
(
!
function_exists
(
'get_ip_info'
))
{
/**
...
...
src/helper/Files.php
浏览文件 @
9d6bdb4e
...
...
@@ -21,6 +21,7 @@ declare (strict_types=1);
namespace
DtApp\ThinkLibrary\helper
;
use
DtApp\ThinkLibrary\exception\DtaException
;
use
think\Exception
;
use
ZipArchive
;
...
...
@@ -35,12 +36,12 @@ class Files
* 删除文件
* @param string $name 路径
* @return bool
* @throws Exception
* @throws
Dta
Exception
*/
public
function
delete
(
string
$name
):
bool
{
if
(
empty
(
$name
))
{
throw
new
Exception
(
'请检查需要删除文件夹的名称'
);
throw
new
Dta
Exception
(
'请检查需要删除文件夹的名称'
);
}
if
(
file_exists
(
$name
))
{
if
(
unlink
(
$name
))
{
...
...
@@ -54,12 +55,13 @@ class Files
* 删除文件夹
* @param string $name 路径
* @return bool
* @throws DtaException
* @throws Exception
*/
public
function
deletes
(
string
$name
):
bool
{
if
(
empty
(
$name
))
{
throw
new
Exception
(
'请检查需要删除文件夹的名称'
);
throw
new
Dta
Exception
(
'请检查需要删除文件夹的名称'
);
}
//先删除目录下的文件:
$dh
=
opendir
(
$name
);
...
...
@@ -88,12 +90,12 @@ class Files
* @param string $suffix_name 需要打包的后缀名,默认.png
* @param string $file_name 文件名,默认全部名
* @return bool
* @throws Exception
* @throws
Dta
Exception
*/
public
function
folderZip
(
string
$name
,
string
$suffix_name
=
'.png'
,
string
$file_name
=
'*'
):
bool
{
if
(
empty
(
$name
))
{
throw
new
Exception
(
'请检查需要打包的路径名称'
);
throw
new
Dta
Exception
(
'请检查需要打包的路径名称'
);
}
try
{
// 获取目录下所有某个结尾的文件列表
...
...
@@ -109,7 +111,7 @@ class Files
//关闭压缩包
$zip
->
close
();
return
true
;
}
catch
(
\
Exception
$e
)
{
}
catch
(
\
Dta
Exception
$e
)
{
return
false
;
}
}
...
...
src/helper/Xmls.php
浏览文件 @
9d6bdb4e
...
...
@@ -21,6 +21,7 @@ declare (strict_types=1);
namespace
DtApp\ThinkLibrary\helper
;
use
DtApp\ThinkLibrary\exception\DtaException
;
use
think\Exception
;
/**
...
...
@@ -34,12 +35,13 @@ class Xmls
* 数组转换为xml
* @param array $values 数组
* @return string
* @throws DtaException
* @throws Exception
*/
public
function
toXml
(
array
$values
)
{
if
(
!
is_array
(
$values
)
||
count
(
$values
)
<=
0
)
{
throw
new
Exception
(
'数组数据异常!'
);
throw
new
Dta
Exception
(
'数组数据异常!'
);
}
$xml
=
"<xml>"
;
foreach
(
$values
as
$key
=>
$val
)
{
...
...
@@ -59,12 +61,12 @@ class Xmls
* 将XML转为array
* @param string $xml
* @return mixed
* @throws Exception
* @throws
Dta
Exception
*/
public
function
toArray
(
string
$xml
)
{
if
(
!
$xml
)
{
throw
new
Exception
(
'xml数据异常!'
);
throw
new
Dta
Exception
(
'xml数据异常!'
);
}
libxml_disable_entity_loader
(
true
);
return
json_decode
(
json_encode
(
simplexml_load_string
(
$xml
,
'SimpleXMLElement'
,
LIBXML_NOCDATA
)),
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录