ComposerUpdate

This commit is contained in:
Anyon 2020-05-15 11:35:10 +08:00
parent b08ca4c9bb
commit 15c1c77110
16 changed files with 63 additions and 67 deletions

8
composer.lock generated
View File

@ -915,12 +915,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac" "reference": "41cba1a861a1cadebd71dc1b75d247b78e2cdeac"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/38dabf5b9074b0f87de24aab4f4e939a06ef93ac", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/41cba1a861a1cadebd71dc1b75d247b78e2cdeac",
"reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac", "reference": "41cba1a861a1cadebd71dc1b75d247b78e2cdeac",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -964,7 +964,7 @@
], ],
"description": "ThinkPHP v6.0 Development Library", "description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top", "homepage": "http://framework.thinkadmin.top",
"time": "2020-05-13T02:56:23+00:00" "time": "2020-05-15T03:25:42+00:00"
}, },
{ {
"name": "zoujingli/wechat-developer", "name": "zoujingli/wechat-developer",

View File

@ -941,12 +941,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac" "reference": "41cba1a861a1cadebd71dc1b75d247b78e2cdeac"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/38dabf5b9074b0f87de24aab4f4e939a06ef93ac", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/41cba1a861a1cadebd71dc1b75d247b78e2cdeac",
"reference": "38dabf5b9074b0f87de24aab4f4e939a06ef93ac", "reference": "41cba1a861a1cadebd71dc1b75d247b78e2cdeac",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -962,7 +962,7 @@
"ext-json": "*", "ext-json": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2020-05-13T02:56:23+00:00", "time": "2020-05-15T03:25:42+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2020-05-14 16:52:07 // This file is automatically generated at:2020-05-15 11:34:31
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\app\\Service', 0 => 'think\\app\\Service',

View File

@ -81,6 +81,7 @@ abstract class Controller extends \stdClass
if (in_array($this->request->action(), get_class_methods(__CLASS__))) { if (in_array($this->request->action(), get_class_methods(__CLASS__))) {
$this->error('Access without permission.'); $this->error('Access without permission.');
} }
$this->csrf_message = lang('think_library_csrf_error');
$this->initialize(); $this->initialize();
} }
@ -89,9 +90,6 @@ abstract class Controller extends \stdClass
*/ */
protected function initialize() protected function initialize()
{ {
if (empty($this->csrf_message)) {
$this->csrf_message = lang('think_library_csrf_error');
}
} }
/** /**

View File

@ -30,7 +30,23 @@ use function Composer\Autoload\includeFile;
class Library extends Service class Library extends Service
{ {
/** /**
* 注册初始化服务 * 启动服务
*/
public function boot()
{
// 动态绑定运行配置
SystemService::instance()->bindRuntime();
// 注册系统任务指令
$this->commands([
'think\admin\command\Queue',
'think\admin\command\Install',
'think\admin\command\Version',
'think\admin\command\Database',
]);
}
/**
* 初始化服务
*/ */
public function register() public function register()
{ {
@ -74,20 +90,4 @@ class Library extends Service
$sysRule = "{$this->app->getAppPath()}*/sys.php"; $sysRule = "{$this->app->getAppPath()}*/sys.php";
foreach (glob($sysRule) as $file) includeFile($file); foreach (glob($sysRule) as $file) includeFile($file);
} }
/**
* 启动服务
*/
public function boot()
{
// 动态绑定运行配置
SystemService::instance()->bindRuntime();
// 注册系统任务指令
$this->commands([
'think\admin\command\Queue',
'think\admin\command\Install',
'think\admin\command\Version',
'think\admin\command\Database',
]);
}
} }

View File

@ -163,7 +163,7 @@ abstract class Storage
{ {
$mimes = self::mimes(); $mimes = self::mimes();
foreach (is_string($exts) ? explode(',', $exts) : $exts as $ext) { foreach (is_string($exts) ? explode(',', $exts) : $exts as $ext) {
$mime[] = isset($mimes[strtolower($ext)]) ? $mimes[strtolower($ext)] : 'application/octet-stream'; $mime[] = $mimes[strtolower($ext)] ?? 'application/octet-stream';
} }
return join(',', array_unique($mime)); return join(',', array_unique($mime));
} }

View File

@ -126,7 +126,7 @@ if (!function_exists('systoken')) {
function systoken($node = null) function systoken($node = null)
{ {
$result = TokenService::instance()->buildFormToken($node); $result = TokenService::instance()->buildFormToken($node);
return isset($result['token']) ? $result['token'] : ''; return $result['token'] ?? '';
} }
} }
if (!function_exists('sysoplog')) { if (!function_exists('sysoplog')) {
@ -279,6 +279,6 @@ if (!function_exists('down_file')) {
function down_file($source, $force = false, $expire = 0) function down_file($source, $force = false, $expire = 0)
{ {
$result = Storage::down($source, $force, $expire); $result = Storage::down($source, $force, $expire);
return isset($result['url']) ? $result['url'] : $source; return $result['url'] ?? $source;
} }
} }

View File

@ -53,7 +53,7 @@ class DataExtend
$tree = []; $tree = [];
foreach (self::arr2tree($list, $cid, $pid) as $attr) { foreach (self::arr2tree($list, $cid, $pid) as $attr) {
$attr[$cpath] = "{$ppath}-{$attr[$cid]}"; $attr[$cpath] = "{$ppath}-{$attr[$cid]}";
$attr['sub'] = isset($attr['sub']) ? $attr['sub'] : []; $attr['sub'] = $attr['sub'] ?? [];
$attr['spt'] = substr_count($ppath, '-'); $attr['spt'] = substr_count($ppath, '-');
$attr['spl'] = str_repeat(" ├ ", $attr['spt']); $attr['spl'] = str_repeat(" ├ ", $attr['spt']);
$sub = $attr['sub']; $sub = $attr['sub'];

View File

@ -65,7 +65,7 @@ class ExcelExtend
public static function parseKeyDotValue(array $data, $rule) public static function parseKeyDotValue(array $data, $rule)
{ {
list($temp, $attr) = [$data, explode('.', trim($rule, '.'))]; list($temp, $attr) = [$data, explode('.', trim($rule, '.'))];
while ($key = array_shift($attr)) $temp = isset($temp[$key]) ? $temp[$key] : $temp; while ($key = array_shift($attr)) $temp = $temp[$key] ?? $temp;
return (is_string($temp) || is_numeric($temp)) ? @iconv('utf-8', 'gbk//TRANSLIT', "{$temp}") : ''; return (is_string($temp) || is_numeric($temp)) ? @iconv('utf-8', 'gbk//TRANSLIT', "{$temp}") : '';
} }
} }

View File

@ -71,8 +71,8 @@ class FormHelper extends Helper
{ {
$this->query = $this->buildQuery($dbQuery); $this->query = $this->buildQuery($dbQuery);
list($this->template, $this->where, $this->data) = [$template, $where, $data]; list($this->template, $this->where, $this->data) = [$template, $where, $data];
$this->field = empty($field) ? ($this->query->getPk() ? $this->query->getPk() : 'id') : $field;; $this->field = $field ?: ($this->query->getPk() ?: 'id');
$this->value = input($this->field, isset($data[$this->field]) ? $data[$this->field] : null); $this->value = input($this->field, $data[$this->field] ?? null);
// GET请求, 获取数据并显示表单页面 // GET请求, 获取数据并显示表单页面
if ($this->app->request->isGet()) { if ($this->app->request->isGet()) {
if ($this->value !== null) { if ($this->value !== null) {

View File

@ -70,13 +70,9 @@ class PageHelper extends Helper
$this->display = $display; $this->display = $display;
$this->query = $this->buildQuery($dbQuery); $this->query = $this->buildQuery($dbQuery);
// 数据列表排序自动处理 // 数据列表排序自动处理
if ($this->app->request->isPost()) { if ($this->app->request->isPost()) $this->sortAction();
$this->sortAction();
}
// 列表设置默认排序处理 // 列表设置默认排序处理
if (!$this->query->getOptions('order')) { if (!$this->query->getOptions('order')) $this->orderAction();
$this->orderAction();
}
// 列表分页及结果集处理 // 列表分页及结果集处理
if ($this->page) { if ($this->page) {
if ($this->limit > 0) { if ($this->limit > 0) {

View File

@ -153,11 +153,7 @@ class QueryHelper extends Helper
public function dateBetween($fields, $split = ' - ', $input = 'request', $alias = '#') public function dateBetween($fields, $split = ' - ', $input = 'request', $alias = '#')
{ {
return $this->setBetweenWhere($fields, $split, $input, $alias, function ($value, $type) { return $this->setBetweenWhere($fields, $split, $input, $alias, function ($value, $type) {
if ($type === 'after') { return $type === 'after' ? "{$value} 23:59:59" : "{$value} 00:00:00";
return "{$value} 23:59:59";
} else {
return "{$value} 00:00:00";
}
}); });
} }
@ -172,11 +168,7 @@ class QueryHelper extends Helper
public function timeBetween($fields, $split = ' - ', $input = 'request', $alias = '#') public function timeBetween($fields, $split = ' - ', $input = 'request', $alias = '#')
{ {
return $this->setBetweenWhere($fields, $split, $input, $alias, function ($value, $type) { return $this->setBetweenWhere($fields, $split, $input, $alias, function ($value, $type) {
if ($type === 'after') { return $type === 'after' ? strtotime("{$value} 23:59:59") : strtotime("{$value} 00:00:00");
return strtotime("{$value} 23:59:59");
} else {
return strtotime("{$value} 00:00:00");
}
}); });
} }

View File

@ -62,8 +62,8 @@ class SaveHelper extends Helper
{ {
$this->where = $where; $this->where = $where;
$this->query = $this->buildQuery($dbQuery); $this->query = $this->buildQuery($dbQuery);
$this->data = empty($data) ? $this->app->request->post() : $data; $this->field = $field ?: $this->query->getPk();
$this->field = empty($field) ? $this->query->getPk() : $field; $this->data = $data ?: $this->app->request->post();
$this->value = $this->app->request->post($this->field, null); $this->value = $this->app->request->post($this->field, null);
// 主键限制处理 // 主键限制处理
if (!isset($this->where[$this->field]) && is_string($this->value)) { if (!isset($this->where[$this->field]) && is_string($this->value)) {

View File

@ -30,32 +30,44 @@ class ValidateHelper extends Helper
* @param array $rules 验证规则( 验证信息数组 * @param array $rules 验证规则( 验证信息数组
* @param string $type 输入方式 ( post. get. ) * @param string $type 输入方式 ( post. get. )
* @return array * @return array
* name.require => message
* age.max:100 => message
* name.between:1,120 => message
* name.value => value
* name.default => 100 // 获取并设置默认值
*/ */
public function init(array $rules, $type = '') public function init(array $rules, $type = '')
{ {
list($data, $rule, $info) = [[], [], []]; list($data, $rule, $info, $alias) = [[], [], [], ''];
foreach ($rules as $name => $message) { foreach ($rules as $name => $message) {
if (stripos($name, '#') !== false) { if (stripos($name, '#') !== false) {
list($name, $alias) = explode('#', $name); list($name, $alias) = explode('#', $name);
} }
if (stripos($name, '.') === false) { if (stripos($name, '.') === false) {
if (is_numeric($name)) { if (is_numeric($name)) {
$keys = $message; $field = $message;
if (is_string($message) && stripos($message, '#') !== false) { if (is_string($message) && stripos($message, '#') !== false) {
list($name, $alias) = explode('#', $message); list($name, $alias) = explode('#', $message);
$keys = empty($alias) ? $name : $alias; $field = empty($alias) ? $name : $alias;
} }
$data[$name] = input("{$type}{$keys}"); $data[$name] = input("{$type}{$field}");
} else { } else {
$data[$name] = $message; $data[$name] = $message;
} }
} else { } else {
list($_rgx) = explode(':', $name); list($_rgx) = explode(':', $name);
list($_key, $_rule) = explode('.', $name); list($_key, $_rule) = explode('.', $name);
$keys = empty($alias) ? $_key : $alias; if (in_array($_rule, ['value', 'default'])) {
$info[$_rgx] = $message; if ($_rule === 'value') {
$data[$_key] = input("{$type}{$keys}"); $data[$_key] = $message;
$rule[$_key] = empty($rule[$_key]) ? $_rule : "{$rule[$_key]}|{$_rule}"; } elseif ($_rule === 'default') {
$data[$_key] = input($type . ($alias ?: $_key), $message);
}
} else {
$info[$_rgx] = $message;
$data[$_key] = $data[$_key] ?? input($type . ($alias ?: $_key));
$rule[$_key] = empty($rule[$_key]) ? $_rule : "{$rule[$_key]}|{$_rule}";
}
} }
} }
$validate = new Validate(); $validate = new Validate();
@ -65,5 +77,4 @@ class ValidateHelper extends Helper
$this->controller->error($validate->getError()); $this->controller->error($validate->getError());
} }
} }
} }

View File

@ -265,8 +265,7 @@ class MessageService extends Service
{ {
$tkey = date("YmdHis"); $tkey = date("YmdHis");
$result = HttpExtend::post('http://intl.zthysms.com/intBalance.do', [ $result = HttpExtend::post('http://intl.zthysms.com/intBalance.do', [
'username' => $this->globe_username, 'tkey' => $tkey, 'username' => $this->globe_username, 'tkey' => $tkey, 'password' => md5(md5($this->globe_password) . $tkey),
'password' => md5(md5($this->globe_password) . $tkey),
]); ]);
if (!is_numeric($result) && ($state = intval($result)) && isset($this->globeMessageMap[$state])) { if (!is_numeric($result) && ($state = intval($result)) && isset($this->globeMessageMap[$state])) {
return ['code' => 0, 'num' => 0, 'msg' => $this->globeMessageMap[$state]]; return ['code' => 0, 'num' => 0, 'msg' => $this->globeMessageMap[$state]];

View File

@ -107,7 +107,7 @@ class SystemService extends Service
$map = isset($where[$key]) ? [] : (is_string($value) ? [[$key, 'in', explode(',', $value)]] : [$key => $value]); $map = isset($where[$key]) ? [] : (is_string($value) ? [[$key, 'in', explode(',', $value)]] : [$key => $value]);
if (is_array($info = $this->app->db->table($table)->master()->where($where)->where($map)->find()) && !empty($info)) { if (is_array($info = $this->app->db->table($table)->master()->where($where)->where($map)->find()) && !empty($info)) {
if ($this->app->db->table($table)->strict(false)->where($where)->where($map)->update($data) !== false) { if ($this->app->db->table($table)->strict(false)->where($where)->where($map)->update($data) !== false) {
return isset($info[$key]) ? $info[$key] : true; return $info[$key] ?? true;
} else { } else {
return false; return false;
} }
@ -275,7 +275,7 @@ class SystemService extends Service
if (empty($data['app_map']) || !is_array($data['app_map'])) $data['app_map'] = []; if (empty($data['app_map']) || !is_array($data['app_map'])) $data['app_map'] = [];
if (empty($data['app_uri']) || !is_array($data['app_uri'])) $data['app_uri'] = []; if (empty($data['app_uri']) || !is_array($data['app_uri'])) $data['app_uri'] = [];
if (empty($data['app_run']) || !is_string($data['app_run'])) $data['app_run'] = 'developer'; if (empty($data['app_run']) || !is_string($data['app_run'])) $data['app_run'] = 'developer';
return is_null($key) ? $data : (isset($data[$key]) ? $data[$key] : null); return is_null($key) ? $data : ($data[$key] ?? null);
} }
/** /**