ComposerUpdate

This commit is contained in:
Anyon 2020-08-19 13:44:57 +08:00
parent 44ed0cec59
commit 14ae65d343
10 changed files with 324 additions and 30 deletions

18
composer.lock generated
View File

@ -74,16 +74,16 @@
},
{
"name": "league/flysystem",
"version": "1.1.1",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "6e96f54d82e71f71c4108da33ee96a7f57083710"
"reference": "63cd8c14708b9544d3f61d3c15b747fda1c95c6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/6e96f54d82e71f71c4108da33ee96a7f57083710",
"reference": "6e96f54d82e71f71c4108da33ee96a7f57083710",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/63cd8c14708b9544d3f61d3c15b747fda1c95c6e",
"reference": "63cd8c14708b9544d3f61d3c15b747fda1c95c6e",
"shasum": "",
"mirrors": [
{
@ -167,7 +167,7 @@
"type": "other"
}
],
"time": "2020-08-12T14:23:41+00:00"
"time": "2020-08-18T10:57:55+00:00"
},
{
"name": "league/flysystem-cached-adapter",
@ -937,12 +937,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "7a6e104189fca196ea4bc8311d7c9e45a2348de3"
"reference": "2100be983dcb654d93003773ec62ac7324cd91e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/7a6e104189fca196ea4bc8311d7c9e45a2348de3",
"reference": "7a6e104189fca196ea4bc8311d7c9e45a2348de3",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/2100be983dcb654d93003773ec62ac7324cd91e9",
"reference": "2100be983dcb654d93003773ec62ac7324cd91e9",
"shasum": "",
"mirrors": [
{
@ -987,7 +987,7 @@
],
"description": "ThinkPHP v6.0 Development Library",
"homepage": "http://thinkadmin.top",
"time": "2020-08-17T10:35:51+00:00"
"time": "2020-08-19T02:25:08+00:00"
},
{
"name": "zoujingli/wechat-developer",

View File

@ -308,6 +308,7 @@ return array(
'think\\admin\\service\\QueueService' => $vendorDir . '/zoujingli/think-library/src/service/QueueService.php',
'think\\admin\\service\\SystemService' => $vendorDir . '/zoujingli/think-library/src/service/SystemService.php',
'think\\admin\\service\\TokenService' => $vendorDir . '/zoujingli/think-library/src/service/TokenService.php',
'think\\admin\\service\\ZtSmsService' => $vendorDir . '/zoujingli/think-library/src/service/ZtSmsService.php',
'think\\admin\\storage\\AliossStorage' => $vendorDir . '/zoujingli/think-library/src/storage/AliossStorage.php',
'think\\admin\\storage\\LocalStorage' => $vendorDir . '/zoujingli/think-library/src/storage/LocalStorage.php',
'think\\admin\\storage\\QiniuStorage' => $vendorDir . '/zoujingli/think-library/src/storage/QiniuStorage.php',

View File

@ -441,6 +441,7 @@ class ComposerStaticInitb911c14a0826c73d9f097343fd33a252
'think\\admin\\service\\QueueService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/QueueService.php',
'think\\admin\\service\\SystemService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/SystemService.php',
'think\\admin\\service\\TokenService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/TokenService.php',
'think\\admin\\service\\ZtSmsService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/ZtSmsService.php',
'think\\admin\\storage\\AliossStorage' => __DIR__ . '/..' . '/zoujingli/think-library/src/storage/AliossStorage.php',
'think\\admin\\storage\\LocalStorage' => __DIR__ . '/..' . '/zoujingli/think-library/src/storage/LocalStorage.php',
'think\\admin\\storage\\QiniuStorage' => __DIR__ . '/..' . '/zoujingli/think-library/src/storage/QiniuStorage.php',

View File

@ -69,17 +69,17 @@
},
{
"name": "league/flysystem",
"version": "1.1.1",
"version_normalized": "1.1.1.0",
"version": "1.1.2",
"version_normalized": "1.1.2.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "6e96f54d82e71f71c4108da33ee96a7f57083710"
"reference": "63cd8c14708b9544d3f61d3c15b747fda1c95c6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/6e96f54d82e71f71c4108da33ee96a7f57083710",
"reference": "6e96f54d82e71f71c4108da33ee96a7f57083710",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/63cd8c14708b9544d3f61d3c15b747fda1c95c6e",
"reference": "63cd8c14708b9544d3f61d3c15b747fda1c95c6e",
"shasum": "",
"mirrors": [
{
@ -116,7 +116,7 @@
"spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
"srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications"
},
"time": "2020-08-12T14:23:41+00:00",
"time": "2020-08-18T10:57:55+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -963,12 +963,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "7a6e104189fca196ea4bc8311d7c9e45a2348de3"
"reference": "2100be983dcb654d93003773ec62ac7324cd91e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/7a6e104189fca196ea4bc8311d7c9e45a2348de3",
"reference": "7a6e104189fca196ea4bc8311d7c9e45a2348de3",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/2100be983dcb654d93003773ec62ac7324cd91e9",
"reference": "2100be983dcb654d93003773ec62ac7324cd91e9",
"shasum": "",
"mirrors": [
{
@ -985,7 +985,7 @@
"ext-mbstring": "*",
"topthink/framework": "^6.0"
},
"time": "2020-08-17T10:35:51+00:00",
"time": "2020-08-19T02:25:08+00:00",
"type": "library",
"extra": {
"think": {

View File

@ -440,7 +440,13 @@ abstract class AbstractFtpAdapter extends AbstractAdapter
$path = $base === '' ? $name : $base . $this->separator . $name;
if ($type === 'dir') {
return compact('type', 'path');
$result = compact('type', 'path');
if ($this->enableTimestampsOnUnixListings) {
$timestamp = $this->normalizeUnixTimestamp($month, $day, $timeOrYear);
$result += compact('timestamp');
}
return $result;
}
$permissions = $this->normalizePermissions($permissions);

View File

@ -37,7 +37,7 @@ class MimeType
*
* @param mixed $content
*
* @return string|null MIME Type or NULL if no mime type detected
* @return string MIME Type
*/
public static function detectByContent($content)
{
@ -45,7 +45,7 @@ class MimeType
return static::detector()->detectMimeTypeFromBuffer($content);
}
return null;
return 'text/plain';
}
/**
@ -53,7 +53,7 @@ class MimeType
*
* @param string $extension
*
* @return string|null MIME Type or NULL if no extension detected
* @return string MIME Type
*/
public static function detectByFileExtension($extension)
{
@ -63,7 +63,7 @@ class MimeType
/**
* @param string $filename
*
* @return string|null MIME Type or NULL if no extension detected
* @return string MIME Type
*/
public static function detectByFilename($filename)
{

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2020-08-17 18:39:50
// This file is automatically generated at:2020-08-19 13:44:17
declare (strict_types = 1);
return array (
0 => 'think\\admin\\Library',

View File

@ -19,7 +19,7 @@ use think\admin\extend\HttpExtend;
use think\admin\Service;
/**
* 短信业务扩展服务
* 旧助通短信接口服务
* Class MessageService
* @package app\store\service
* =================================
@ -145,7 +145,7 @@ class MessageService extends Service
'productid' => $productid,
'password' => md5(md5($this->chinaPassword) . $tkey),
]);
list($code, $message) = explode(',', $result . ',');
[$code, $message] = explode(',', $result . ',');
$this->app->db->name($this->table)->insert([
'phone' => $phone, 'region' => '860', 'content' => $content, 'result' => $result,
]);
@ -169,7 +169,7 @@ class MessageService extends Service
$dtime = ($cache['time'] + $wait < time()) ? 0 : ($wait - time() + $cache['time']);
return [1, '短信验证码已经发送!', ['time' => $dtime]];
}
list($code, $content) = [rand(1000, 9999), sysconf($type)];
[$code, $content] = [rand(1000, 9999), sysconf($type)];
if (empty($content) || stripos($content, '{code}') === false) {
$content = '您的验证码为{code},请在十分钟内完成操作!';
}

View File

@ -234,7 +234,7 @@ class SystemService extends Service
if (is_null($state)) {
return $this->bindRuntime();
} else {
return $this->setRuntime([], $state ? 'product' : 'developoer');
return $this->setRuntime([], $state ? 'product' : 'debug');
}
}
@ -253,7 +253,7 @@ class SystemService extends Service
if (empty($data) || !is_array($data)) $data = [];
if (empty($data['map']) || !is_array($data['map'])) $data['map'] = [];
if (empty($data['uri']) || !is_array($data['uri'])) $data['uri'] = [];
if (empty($data['run']) || !is_string($data['run'])) $data['run'] = 'developer';
if (empty($data['run']) || !is_string($data['run'])) $data['run'] = 'debug';
return is_null($key) ? $data : ($data[$key] ?? $default);
}

View File

@ -0,0 +1,286 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkLibrary
// | github 代码仓库https://github.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
namespace think\admin\service;
use think\admin\extend\HttpExtend;
use think\admin\Service;
/**
* 新助通短信接口服务
* Class ZtSmsService
* @package think\admin\service
*/
class ZtSmsService extends Service
{
/**
* 子账号名称
* @var string
*/
protected $username;
/**
* 子账号密码
* @var string
*/
protected $password;
/**
* 短信服务初始化
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
protected function initialize()
{
$this->username = sysconf('ztsms.username');
$this->password = sysconf('ztsms.password');
}
/**
* 短信服务初始化
* @param string $username 账号名称
* @param string $password 账号密码
* @return static
*/
public function make(string $username, string $password)
{
$this->username = $username;
$this->password = $password;
return $this;
}
/**
* 验证手机短信验证码
* @param string $code 验证码
* @param string $phone 手机号验证
* @param string $tplcode
* @return boolean
*/
public function checkVerifyCode(string $code, string $phone, string $tplcode = 'ztsms.register_verify'): bool
{
$cache = $this->app->cache->get($ckey = md5("code-{$tplcode}-{$phone}"), []);
if (is_array($cache) && isset($cache['code']) && $cache['code'] == $code) {
$this->app->cache->delete($ckey);
return true;
} else {
return false;
}
}
/**
* 验证手机短信验证码
* @param string $phone 手机号码
* @param integer $wait 等待时间
* @param string $tplcode 模板编号
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function sendVerifyCode(string $phone, int $wait = 120, string $tplcode = 'ztsms.register_verify'): array
{
$content = sysconf($tplcode) ?: '您的短信验证码为{code},请在十分钟内完成操作!';
$cache = $this->app->cache->get($ckey = md5("code-{$tplcode}-{$phone}"), []);
// 检查是否已经发送
if (is_array($cache) && isset($cache['time']) && $cache['time'] > time() - $wait) {
$dtime = ($cache['time'] + $wait < time()) ? 0 : ($wait - time() + $cache['time']);
return [1, '短信验证码已经发送!', ['time' => $dtime]];
}
// 生成新的验证码
[$code, $time] = [rand(100000, 999999), time()];
$this->app->cache->set($ckey, ['code' => $code, 'time' => $time], 600);
// 尝试发送短信内容
[$state] = $this->timeSend($phone, preg_replace_callback("|{(.*?)}|", function ($matches) use ($code) {
return $matches[1] === 'code' ? $code : $matches[1];
}, $content));
if ($state) return [1, '短信验证码发送成功!', [
'time' => ($time + $wait < time()) ? 0 : ($wait - time() + $time)],
]; else {
$this->app->cache->delete($ckey);
return [0, '短信发送失败,请稍候再试!', []];
}
}
/**
* 创建短信签名
* @param array $signs 签名列表
* @param string $remark 签名备注
* @return array
*/
public function signAdd(array $signs = [], string $remark = ''): array
{
foreach ($signs as $key => $sign) {
if (strpos($sign, '】') === false) $signs[$key] = $sign . '】';
if (strpos($sign, '【') === false) $signs[$key] = '【' . $sign;
}
return $this->doRequest('https://api.mix2.zthysms.com/sms/v1/sign', [
'sign' => $signs, 'remark' => $remark,
]);
}
/**
* 查询短信签名
* @param string $sign 短信签名
* @return array
*/
public function signGet(string $sign): array
{
if (strpos($sign, '】') === false) $sign = $sign . '】';
if (strpos($sign, '【') === false) $sign = '【' . $sign;
return $this->doRequest('https://api.mix2.zthysms.com/sms/v1/sign/query', ['sign' => $sign]);
}
/**
* 报备短信模板
* @param string $temName 模板名称
* @param integer $temType 模板类型1验证码,2行业通知,3营销推广)
* @param string $temContent 模板内容
* @param array $paramJson 变量格式
* @param string $remark 模板备注
* @return array
*/
public function tplAdd(string $temName, int $temType, string $temContent, array $paramJson = [], string $remark = ''): array
{
return $this->doRequest('https://api.mix2.zthysms.com/sms/v2/template', [
'temName' => $temName, 'temType' => $temType, 'temContent' => $temContent, 'paramJson' => $paramJson, 'remark' => $remark,
]);
}
/**
* 查询模板状态
* @param string $temId 短信模板
* @return array
*/
public function tplGet(string $temId): array
{
return $this->doRequest('https://api.mix2.zthysms.com/sms/v2/template/query', ['temId' => $temId]);
}
/**
* 发送模板短信
* @param string $tpId 短信模板
* @param string $sign 短信签名
* @param array $records 发送记录
* @return array
*/
public function tplSend(string $tpId, string $sign, array $records): array
{
if (strpos($sign, '】') === false) $sign = $sign . '】';
if (strpos($sign, '【') === false) $sign = '【' . $sign;
return $this->doRequest('https://api.mix2.zthysms.com/v2/sendSmsTp', [
'tpId' => $tpId, 'records' => $records, 'signature' => $sign,
]);
}
/**
* 发送定时短信
* @param string $mobile 发送手机号码
* @param string $content 发送短信内容
* @param string $time 定时发送时间(为 null 立即发送)
* @return array
*/
public function timeSend(string $mobile, string $content, $time = null): array
{
$data = ['mobile' => $mobile, 'content' => $content];
if ($time > 0) $data['time'] = $time;
return $this->doRequest('https://api.mix2.zthysms.com/v2/sendSms', $data);
}
/**
* 批量发送短信
* @param array $records
* @return array
*/
public function batchSend(array $records): array
{
return $this->doRequest('https://api.mix2.zthysms.com/v2/sendSmsPa', ['records' => $records]);
}
/**
* 短信条数查询
*/
public function balance(): array
{
[$state, $result, $message] = $this->doRequest('https://api.mix2.zthysms.com/v2/balance', []);
return [$state, $state ? $result['sumSms'] : 0, $message];
}
/**
* 执行网络请求
* @param string $url 接口请求地址
* @param array $data 接口请求参数
* @return array
*/
private function doRequest(string $url, array $data): array
{
$encode = md5(md5($this->password) . ($tkey = time()));
$options = ['headers' => ['Content-Type:application/json;charset="UTF-8"']];
$extends = ['username' => $this->username, 'password' => $encode, 'tKey' => $tkey];
$result = json_decode(HttpExtend::post($url, json_encode(array_merge($data, $extends)), $options), true);
if (empty($result['code'])) {
return [0, [], '接口请求网络异常'];
} elseif (intval($result['code']) === 200) {
return [1, $result, $this->error($result['code'])];
} else {
return [0, $result, $this->error($result['code'])];
}
}
/**
* 获取状态描述
* @param integer $code 异常编号
* @return string
*/
private function error(int $code): string
{
$arrs = [
200 => '提交成功',
4001 => '用户名错误',
4002 => '密码不能为空',
4003 => '短信内容不能为空',
4004 => '手机号码错误',
4006 => 'IP鉴权错误',
4007 => '用户禁用',
4008 => 'tKey错误',
4009 => '密码错误',
4011 => '请求错误',
4013 => '定时时间错误',
4014 => '模板错误',
4015 => '扩展号错误',
4019 => '用户类型错误',
4023 => '签名错误',
4025 => '模板变量内容为空',
4026 => '手机号码数最大2000个',
4027 => '模板变量内容最大200组',
4029 => '请使用 POST 请求',
4030 => 'Content-Type 请使用 application/json',
4031 => '模板名称不能为空',
4032 => '模板类型不正确',
4034 => '模板内容不能为空',
4035 => '模板名称已经存在',
4036 => '添加模板信息失败',
4037 => '模板名称最大20字符',
4038 => '模板内容超过最大字符数',
4040 => '模板内容缺少变量值或规则错误',
4041 => '模板内容中变量规范错误',
4042 => '模板变量个数超限',
4044 => '接口24小时限制提交次数超限',
9998 => 'JSON解析错误',
9999 => '非法请求',
];
return $arrs[$code] ?? $code;
}
}