From 3d4f60a7a7215ae3a2a7fc85f37e09bd13f3c68e Mon Sep 17 00:00:00 2001 From: Chaim Date: Fri, 17 Apr 2020 15:51:26 +0800 Subject: [PATCH] - update facade --- CHANGELOG.md | 5 -- composer.json | 10 ++- src/Date.php | 28 +++++++ src/Files.php | 100 ++++++++++++++++++++++++ src/Ints.php | 48 ++++++++++++ src/Preg.php | 3 +- src/Service.php | 13 ++++ src/Time.php | 127 +++++++++++++++++++++++++++++++ src/UnIqId.php | 77 +++++++++++++++++++ src/Urls.php | 61 +++++++++++++++ src/Xmls.php | 64 ++++++++++++++++ src/common.php | 2 +- src/config.php | 17 +++++ src/exception/DtAppException.php | 32 ++++++++ src/facade/Date.php | 39 ++++++++++ src/facade/Files.php | 43 +++++++++++ src/facade/Ints.php | 43 +++++++++++ src/facade/Preg.php | 23 +++++- src/facade/Time.php | 48 ++++++++++++ src/facade/UnIqId.php | 43 +++++++++++ src/facade/Urls.php | 43 +++++++++++ src/facade/Xmls.php | 41 ++++++++++ 22 files changed, 899 insertions(+), 11 deletions(-) delete mode 100644 CHANGELOG.md create mode 100644 src/Date.php create mode 100644 src/Files.php create mode 100644 src/Ints.php create mode 100644 src/Time.php create mode 100644 src/UnIqId.php create mode 100644 src/Urls.php create mode 100644 src/Xmls.php create mode 100644 src/config.php create mode 100644 src/exception/DtAppException.php create mode 100644 src/facade/Date.php create mode 100644 src/facade/Files.php create mode 100644 src/facade/Ints.php create mode 100644 src/facade/Time.php create mode 100644 src/facade/UnIqId.php create mode 100644 src/facade/Urls.php create mode 100644 src/facade/Xmls.php diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index bc102b1..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -## v5.1.2 / 2020-04-13 -- 测试 - -## v5.1.1 / 2020-04-13 -- 测试 diff --git a/composer.json b/composer.json index 332dbb8..b6781d7 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,11 @@ "homepage": "https://www.dtapp.net", "require": { "php": ">=5.6.0", + "ext-gd": "*", + "ext-libxml": "*", + "ext-json": "*", + "ext-simplexml": "*", + "ext-zip": "*", "topthink/framework": "5.1.*", "liguangchun/ip": "^1.1" }, @@ -36,7 +41,10 @@ "think": { "services": [ "DtApp\\ThinkLibrary" - ] + ], + "config": { + "dtapp": "src/config.php" + } } } } diff --git a/src/Date.php b/src/Date.php new file mode 100644 index 0000000..90cdeae --- /dev/null +++ b/src/Date.php @@ -0,0 +1,28 @@ +deletes($fullpath); + } + } + } + closedir($dh); + //删除当前文件夹: + if (rmdir($name)) { + return true; + } else { + return false; + } + } + + /** + * 把文件夹里面的文件打包成zip文件 + * @param string $name 路径 + * @param string $suffix_name 需要打包的后缀名,默认.png + * @param string $file_name 文件名,默认全部名 + * @return bool + * @throws DtAppException + */ + public function folderZip(string $name, string $suffix_name = '.png', string $file_name = '*') + { + if (empty($name)) throw new DtAppException('请检查需要打包的路径名称'); + try { + // 获取目录下所有某个结尾的文件列表 + $list = glob($name . "{$file_name}.{$suffix_name}"); + $fileList = $list; + $zip = new ZipArchive(); + // 打开压缩包 + $zip->open($name, ZipArchive::CREATE); + //向压缩包中添加文件 + foreach ($fileList as $file) $zip->addFile($file, basename($file)); + //关闭压缩包 + $zip->close(); + return true; + } catch (\Exception $e) { + return false; + } + } +} diff --git a/src/Ints.php b/src/Ints.php new file mode 100644 index 0000000..90ead8d --- /dev/null +++ b/src/Ints.php @@ -0,0 +1,48 @@ + $assignTime1 && $curTime < $assignTime2) $result = true; + return $result; + } +} diff --git a/src/UnIqId.php b/src/UnIqId.php new file mode 100644 index 0000000..9b03f12 --- /dev/null +++ b/src/UnIqId.php @@ -0,0 +1,77 @@ + $v) if ($k != "sign" && $v !== "" && !is_array($v)) $buff .= $k . "=" . $v . "&"; + $buff = trim($buff, "&"); + return $buff; + } +} diff --git a/src/Xmls.php b/src/Xmls.php new file mode 100644 index 0000000..43d7c7e --- /dev/null +++ b/src/Xmls.php @@ -0,0 +1,64 @@ +"; + foreach ($values as $key => $val) { + if (is_array($val)) { + $xml .= "<" . $key . ">" . toXml($val) . ""; + } else if (is_numeric($val)) { + $xml .= "<" . $key . ">" . $val . ""; + } else { + $xml .= "<" . $key . ">"; + } + } + $xml .= ""; + return $xml; + } + + /** + * 将XML转为array + * @param string $xml + * @return mixed + * @throws DtAppException + */ + public function toArray(string $xml) + { + if (!$xml) throw new DtAppException('xml数据异常!'); + libxml_disable_entity_loader(true); + return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); + } +} diff --git a/src/common.php b/src/common.php index b4453e3..3131121 100644 --- a/src/common.php +++ b/src/common.php @@ -1,7 +1,7 @@ getMessage(); + } +} diff --git a/src/facade/Date.php b/src/facade/Date.php new file mode 100644 index 0000000..481ef5e --- /dev/null +++ b/src/facade/Date.php @@ -0,0 +1,39 @@ +