diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a83922..cbdaf86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v6.0.107 / 2020-08-15 +- 优化 + ## v6.0.106 / 2020-08-08 - 修复数组门面增加数组删除空格函数问题 diff --git a/composer.json b/composer.json index 74886a6..6b2c28d 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,6 @@ "ext-dom": "*", "topthink/framework": "^6.0.0", "topthink/think-orm": "^2.0", - "topthink/think-view": "^1.0", - "topthink/think-multi-app": "^1.0", "aliyuncs/oss-sdk-php": "^2.3", "obs/esdk-obs-php": "^3.19", "baidubce/bce-sdk-php": "^0.8.22", diff --git a/src/ApiController.php b/src/ApiController.php index daf276c..a897909 100644 --- a/src/ApiController.php +++ b/src/ApiController.php @@ -65,7 +65,7 @@ class ApiController extends stdClass $this->app = $app; $this->request = $app->request; $this->app->bind('DtApp\ThinkLibrary\ApiController', $this); - if (in_array($this->request->action(), get_class_methods(__CLASS__))) { + if (in_array($this->request->action(), get_class_methods(__CLASS__), true)) { $this->error('Access without permission.'); } $this->initialize(); @@ -193,11 +193,8 @@ class ApiController extends stdClass if (empty($name)) { return $this->aes_decrypt_data; } - if (isset($this->aes_decrypt_data[$name])) { - return $this->aes_decrypt_data[$name]; - } else { - return $default; - } + + return $this->aes_decrypt_data[$name] ?? $default; } /** diff --git a/src/Controller.php b/src/Controller.php index ee65843..14a3619 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -52,7 +52,7 @@ class Controller extends stdClass $this->app = $app; $this->request = $app->request; $this->app->bind('DtApp\ThinkLibrary\Controller', $this); - if (in_array($this->request->action(), get_class_methods(__CLASS__))) { + if (in_array($this->request->action(), get_class_methods(__CLASS__), true)) { $this->error('Access without permission.'); } $this->initialize(); diff --git a/src/common.php b/src/common.php index 939e513..e48f85d 100644 --- a/src/common.php +++ b/src/common.php @@ -21,12 +21,11 @@ use DtApp\ThinkLibrary\cache\Mysql; use DtApp\ThinkLibrary\exception\DtaException; use DtApp\ThinkLibrary\service\QqWryService; use DtApp\ThinkLibrary\service\SystemService; -use think\db\exception\DbException; /** * 定义当前版本 */ -const VERSION = '6.0.106'; +const VERSION = '6.0.107'; if (!function_exists('get_ip_info')) { /** @@ -61,9 +60,8 @@ if (!function_exists('get_ip')) { //为了兼容百度的CDN,所以转成数组 $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); return $arr[0]; - } else { - return $_SERVER['REMOTE_ADDR']; } + return $_SERVER['REMOTE_ADDR']; } } @@ -90,8 +88,8 @@ if (!function_exists('dtacache')) { * @param array $value * @param int $expire * @return bool|int|string - * @throws DbException * @throws DtaException + * @throws \think\db\exception\DbException */ function dtacache($name = '', $value = [], $expire = 6000) { @@ -99,19 +97,20 @@ if (!function_exists('dtacache')) { if (empty($value)) { return $myc->name($name) ->get(); + } + + $judge = $myc->name($name) + ->get(); + if (empty($judge)) { + $myc->name($name) + ->expire($expire) + ->set($value); } else { - if (empty($myc->name($name) - ->get())) { - $myc->name($name) - ->expire($expire) - ->set($value); - } else { - $myc->name($name) - ->expire($expire) - ->update($value); - } - return $myc->name($name) - ->get(); + $myc->name($name) + ->expire($expire) + ->update($value); } + return $myc->name($name) + ->get(); } } diff --git a/src/helper/Arrays.php b/src/helper/Arrays.php index 72df50d..fa1dada 100644 --- a/src/helper/Arrays.php +++ b/src/helper/Arrays.php @@ -64,7 +64,7 @@ class Arrays if (!is_int($iCount)) { $iCount = ceil($iCount); } else { - $iCount += 1; + ++$iCount; } for ($i = 0; $i < $iCount; ++$i) { $arrInfos = array_slice($array, $i * $num, $num); @@ -86,7 +86,7 @@ class Arrays { $out = array(); foreach ($array as $key => $value) { - if (!in_array($value, $out)) { + if (!in_array($value, $out, true)) { $out[$key] = $value; } } diff --git a/src/helper/Files.php b/src/helper/Files.php index 7a07e9b..d2b6e3d 100644 --- a/src/helper/Files.php +++ b/src/helper/Files.php @@ -79,9 +79,9 @@ class Files //删除当前文件夹: if (rmdir($name)) { return true; - } else { - return false; } + + return false; } /** @@ -97,23 +97,18 @@ class Files if (empty($name)) { throw new DtaException('请检查需要打包的路径名称'); } - 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 (\DtaException $e) { - return false; + $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; } /** @@ -139,9 +134,9 @@ class Files } $file->close(); return $files; - } else { - return []; } + + return []; } /** @@ -154,15 +149,17 @@ class Files $files = $this->getFiles($path); if (!is_array($files)) { return false; - } elseif (empty($files)) { + } + + if (empty($files)) { return false; - } else { - foreach ($files as $item => $file) { - if (is_dir($file)) { - rmdir($file); - } elseif (is_file($file)) { - unlink($file); - } + } + + foreach ($files as $item => $file) { + if (is_dir($file)) { + rmdir($file); + } elseif (is_file($file)) { + unlink($file); } } return true; diff --git a/src/helper/Randoms.php b/src/helper/Randoms.php index 6b32f5f..734222f 100644 --- a/src/helper/Randoms.php +++ b/src/helper/Randoms.php @@ -21,6 +21,8 @@ declare (strict_types=1); namespace DtApp\ThinkLibrary\helper; +use Exception; + /** * 随机管理类 * @mixin Randoms @@ -33,6 +35,7 @@ class Randoms * @param int $length 长度 * @param int $type 类型,1 纯数字,2 纯小写字母,3 纯大写字母,4 数字和小写字母,5 数字和大写字母,6 大小写字母,7 数字和大小写字母 * @return string + * @throws Exception */ public function generate(int $length = 6, int $type = 1) { @@ -61,30 +64,30 @@ class Randoms $str = ''; // 生成字符串 for ($i = 0; $i < $length; $i++) { - $str .= $charset[mt_rand(0, count($charset) - 1)]; + $str .= $charset[random_int(0, count($charset) - 1)]; // 验证规则 if ($type == 4 && strlen($str) >= 2) { if (!preg_match('/\d+/', $str) || !preg_match('/[a-z]+/', $str)) { $str = substr($str, 0, -1); - $i = $i - 1; + --$i; } } if ($type == 5 && strlen($str) >= 2) { if (!preg_match('/\d+/', $str) || !preg_match('/[A-Z]+/', $str)) { $str = substr($str, 0, -1); - $i = $i - 1; + --$i; } } if ($type == 6 && strlen($str) >= 2) { if (!preg_match('/[a-z]+/', $str) || !preg_match('/[A-Z]+/', $str)) { $str = substr($str, 0, -1); - $i = $i - 1; + --$i; } } if ($type == 7 && strlen($str) >= 3) { if (!preg_match('/\d+/', $str) || !preg_match('/[a-z]+/', $str) || !preg_match('/[A-Z]+/', $str)) { $str = substr($str, 0, -2); - $i = $i - 2; + $i -= 2; } } } diff --git a/src/helper/Requests.php b/src/helper/Requests.php index db6c31f..7ceee58 100644 --- a/src/helper/Requests.php +++ b/src/helper/Requests.php @@ -37,7 +37,7 @@ class Requests public function isEmpty(array $data, array $arr): array { foreach ($arr as $k => $v) { - if (empty(isset($data["$v"]) ? $data["$v"] : '')) { + if (empty($data[(string)$v] ?? '')) { return []; } } @@ -53,7 +53,7 @@ class Requests public function isEmptyRet(array $data, array $arr): array { foreach ($arr as $k => $v) { - if (empty(isset($data["$v"]) ? $data["$v"] : '')) { + if (empty($data[(string)$v] ?? '')) { (new Returns)->jsonError('请检查参数', 102); } } @@ -118,7 +118,7 @@ class Requests //如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息 //找不到为flase,否则为true if (isset($_SERVER['HTTP_VIA'])) { - return stristr(request()->server('HTTP_VIA'), "wap") ? true : false; + return stripos(request()->server('HTTP_VIA'), "wap") !== false; } //判断手机发送的客户端标志 if (isset($_SERVER['HTTP_USER_AGENT'])) { @@ -150,10 +150,7 @@ class Requests */ public function isWeiXin(): bool { - if (strpos(request()->server('HTTP_USER_AGENT'), 'MicroMessenger') !== false) { - return true; - } - return false; + return strpos(request()->server('HTTP_USER_AGENT'), 'MicroMessenger') !== false; } /** @@ -162,10 +159,7 @@ class Requests */ public function isWeiXinMp(): bool { - if (strpos(request()->server('HTTP_USER_AGENT'), 'miniProgram') !== false) { - return true; - } - return false; + return strpos(request()->server('HTTP_USER_AGENT'), 'miniProgram') !== false; } /** @@ -174,10 +168,7 @@ class Requests */ public function isAliPay(): bool { - if (strpos(request()->server('HTTP_USER_AGENT'), 'Alipay') !== false) { - return true; - } - return false; + return strpos(request()->server('HTTP_USER_AGENT'), 'Alipay') !== false; } /** @@ -186,12 +177,7 @@ class Requests */ public function isQQ(): bool { - if (strpos(request()->server('HTTP_USER_AGENT'), 'QQ') !== false) { - if (strpos(request()->server('HTTP_USER_AGENT'), '_SQ_') !== false) { - return true; - } - } - return false; + return (strpos(request()->server('HTTP_USER_AGENT'), 'QQ') !== false) && strpos(request()->server('HTTP_USER_AGENT'), '_SQ_') !== false; } /** @@ -201,11 +187,7 @@ class Requests public function isQQBrowser(): bool { if (strpos(request()->server('HTTP_USER_AGENT'), 'QQ') !== false) { - if (strpos(request()->server('HTTP_USER_AGENT'), '_SQ_') !== false) { - return false; - } else { - return true; - } + return !(strpos(request()->server('HTTP_USER_AGENT'), '_SQ_') !== false); } return false; } diff --git a/src/helper/Returns.php b/src/helper/Returns.php index e3d2485..168fd1e 100644 --- a/src/helper/Returns.php +++ b/src/helper/Returns.php @@ -30,6 +30,12 @@ use think\exception\HttpResponseException; */ class Returns { + public function __construct() + { + date_default_timezone_set('Asia/Shanghai'); + header('Content-Type:application/json; charset=utf-8'); + } + /** * 返回Json-成功 * @param array $data 数据 @@ -39,13 +45,21 @@ class Returns */ public function jsonSuccess(array $data = [], string $msg = 'success', int $code = 0, array $ext = []) { - date_default_timezone_set('Asia/Shanghai'); - header('Content-Type:application/json; charset=utf-8'); if (!empty($ext) && is_array($ext)) { - throw new HttpResponseException(json(array_merge(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => $data], $ext))); - } else { - throw new HttpResponseException(json(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => $data])); + throw new HttpResponseException(json(array_merge([ + 'code' => $code, + 'msg' => $msg, + 'time' => time(), + 'data' => $data + ], $ext))); } + + throw new HttpResponseException(json([ + 'code' => $code, + 'msg' => $msg, + 'time' => time(), + 'data' => $data + ])); } /** @@ -57,12 +71,20 @@ class Returns */ public function jsonError(string $msg = 'error', int $code = 1, array $data = [], array $ext = []) { - date_default_timezone_set('Asia/Shanghai'); - header('Content-Type:application/json; charset=utf-8'); if (!empty($ext) && is_array($ext)) { - throw new HttpResponseException(json(array_merge(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => $data], $ext))); - } else { - throw new HttpResponseException(json(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => $data])); + throw new HttpResponseException(json(array_merge([ + 'code' => $code, + 'msg' => $msg, + 'time' => time(), + 'data' => $data + ], $ext))); } + + throw new HttpResponseException(json([ + 'code' => $code, + 'msg' => $msg, + 'time' => time(), + 'data' => $data + ])); } } diff --git a/src/helper/Strings.php b/src/helper/Strings.php index 794d630..ebe6222 100644 --- a/src/helper/Strings.php +++ b/src/helper/Strings.php @@ -65,72 +65,7 @@ class Strings */ public function filter(string $str): string { - $str = str_replace('`', '', $str); - $str = str_replace('·', '', $str); - $str = str_replace('~', '', $str); - $str = str_replace('!', '', $str); - $str = str_replace('!', '', $str); - $str = str_replace('@', '', $str); - $str = str_replace('#', '', $str); - $str = str_replace('$', '', $str); - $str = str_replace('¥', '', $str); - $str = str_replace('%', '', $str); - $str = str_replace('^', '', $str); - $str = str_replace('……', '', $str); - $str = str_replace('&', '', $str); - $str = str_replace('*', '', $str); - $str = str_replace('(', '', $str); - $str = str_replace(')', '', $str); - $str = str_replace('(', '', $str); - $str = str_replace(')', '', $str); - $str = str_replace('-', '', $str); - $str = str_replace('_', '', $str); - $str = str_replace('——', '', $str); - $str = str_replace('+', '', $str); - $str = str_replace('=', '', $str); - $str = str_replace('|', '', $str); - $str = str_replace('\\', '', $str); - $str = str_replace('[', '', $str); - $str = str_replace(']', '', $str); - $str = str_replace('【', '', $str); - $str = str_replace('】', '', $str); - $str = str_replace('{', '', $str); - $str = str_replace('}', '', $str); - $str = str_replace(';', '', $str); - $str = str_replace(';', '', $str); - $str = str_replace(':', '', $str); - $str = str_replace(':', '', $str); - $str = str_replace('\'', '', $str); - $str = str_replace('"', '', $str); - $str = str_replace('“', '', $str); - $str = str_replace('”', '', $str); - $str = str_replace(',', '', $str); - $str = str_replace(',', '', $str); - $str = str_replace('<', '', $str); - $str = str_replace('>', '', $str); - $str = str_replace('《', '', $str); - $str = str_replace('》', '', $str); - $str = str_replace('.', '', $str); - $str = str_replace('。', '', $str); - $str = str_replace('/', '', $str); - $str = str_replace('、', '', $str); - $str = str_replace('?', '', $str); - $str = str_replace('?', '', $str); - $str = str_replace('╮', '', $str); - $str = str_replace('(', '', $str); - $str = str_replace(')', '', $str); - $str = str_replace('r', '', $str); - $str = str_replace('ぷ', '', $str); - $str = str_replace('〆', '', $str); - $str = str_replace('ゞ', '', $str); - $str = str_replace('ヤ', '', $str); - $str = str_replace('ゼ', '', $str); - $str = str_replace('ǎ', '', $str); - $str = str_replace('ǎ', '', $str); - $str = str_replace('〆', '', $str); - $str = str_replace('む', '', $str); - $str = str_replace('§', '', $str); - $str = str_replace('上门', '', $str); + $str = str_replace(array('`', '·', '~', '!', '!', '@', '#', '$', '¥', '%', '^', '……', '&', '*', '(', ')', '(', ')', '-', '_', '——', '+', '=', '|', '\\', '[', ']', '【', '】', '{', '}', ';', ';', ':', ':', '\'', '"', '“', '”', ',', ',', '<', '>', '《', '》', '.', '。', '/', '、', '?', '?', '╮', '(', ')', 'r', 'ぷ', '〆', 'ゞ', 'ヤ', 'ゼ', 'ǎ', 'ǎ', '〆', 'む', '§', '上门'), '', $str); return trim($str); } @@ -151,12 +86,9 @@ class Strings } } return false; - } else { - if ($str == $nee) { - return true; - } - return false; } + + return $str == $nee; } /** diff --git a/src/helper/UnIqIds.php b/src/helper/UnIqIds.php index c97140b..d614a3b 100644 --- a/src/helper/UnIqIds.php +++ b/src/helper/UnIqIds.php @@ -21,6 +21,8 @@ declare (strict_types=1); namespace DtApp\ThinkLibrary\helper; +use Exception; + /** * 唯一ID管理类 * @mixin UnIqIds @@ -34,24 +36,25 @@ class UnIqIds * @param integer $type 字符串类型(1纯数字,2纯字母,3数字字母) * @param string $prefix 编码前缀 * @return string + * @throws Exception */ public function random($size = 10, $type = 1, $prefix = ''): string { $numbs = '0123456789'; $chars = 'abcdefghijklmnopqrstuvwxyz'; - if (intval($type) === 1) { + if ((int)$type === 1) { $chars = $numbs; } - if (intval($type) === 2) { + if ((int)$type === 2) { $chars = "{$chars}"; } - if (intval($type) === 3) { + if ((int)$type === 3) { $chars = "{$numbs}{$chars}"; } - $string = $prefix . $chars[rand(1, strlen($chars) - 1)]; + $string = $prefix . $chars[random_int(1, strlen($chars) - 1)]; if (isset($chars)) { while (strlen($string) < $size) { - $string .= $chars[rand(0, strlen($chars) - 1)]; + $string .= $chars[random_int(0, strlen($chars) - 1)]; } } return $string; @@ -62,6 +65,7 @@ class UnIqIds * @param integer $size * @param string $prefix * @return string + * @throws Exception */ public function date($size = 16, $prefix = ''): string { @@ -70,7 +74,7 @@ class UnIqIds } $string = $prefix . date('Ymd') . (date('H') + date('i')) . date('s'); while (strlen($string) < $size) { - $string .= rand(0, 9); + $string .= random_int(0, 9); } return $string; } @@ -80,6 +84,7 @@ class UnIqIds * @param integer $size * @param string $prefix * @return string + * @throws Exception */ public function number($size = 12, $prefix = ''): string { @@ -87,9 +92,9 @@ class UnIqIds if ($size < 10) { $size = 10; } - $string = $prefix . ($time[0] . $time[1]) . substr($time, 2) . rand(0, 9); + $string = $prefix . ($time[0] . $time[1]) . substr($time, 2) . random_int(0, 9); while (strlen($string) < $size) { - $string .= rand(0, 9); + $string .= random_int(0, 9); } return $string; } diff --git a/src/helper/Urls.php b/src/helper/Urls.php index 8c69a1d..e7fde19 100644 --- a/src/helper/Urls.php +++ b/src/helper/Urls.php @@ -81,9 +81,9 @@ class Urls $pattern = "#(http|https)://(.*\.)?.*\..*#i"; if (preg_match($pattern, $url)) { return true; - } else { - return false; } + + return false; } /** diff --git a/src/service/bt/ApiService.php b/src/service/bt/ApiService.php index 253cc82..780b5f7 100644 --- a/src/service/bt/ApiService.php +++ b/src/service/bt/ApiService.php @@ -404,8 +404,8 @@ class ApiService extends Service //定义cookie保存位置 $file = app()->getRootPath() . 'runtime/dtapp/bt/cookie/'; $cookie_file = $file . md5($this->panel) . '.cookie'; - if (empty(Files::judgeContents($file))) { - mkdir($file, 0777, true); + if (empty(Files::judgeContents($file)) && !mkdir($file, 0777, true) && !is_dir($file)) { + throw new \RuntimeException(sprintf('Directory "%s" was not created', $file)); } if (!file_exists($cookie_file)) { $fp = fopen($cookie_file, 'w+'); diff --git a/src/service/huaweicloud/ObsService.php b/src/service/huaweicloud/ObsService.php index c007ec6..3cc9e79 100644 --- a/src/service/huaweicloud/ObsService.php +++ b/src/service/huaweicloud/ObsService.php @@ -96,8 +96,8 @@ class ObsService extends Service ]); if (isset($resp['RequestId'])) { return config('dtapp.huaweicloud.obs.url', '') . $object; - } else { - return false; } + + return false; } } diff --git a/src/service/qiniu/KodoService.php b/src/service/qiniu/KodoService.php index 0035231..3f5040d 100644 --- a/src/service/qiniu/KodoService.php +++ b/src/service/qiniu/KodoService.php @@ -83,11 +83,11 @@ class KodoService extends Service // 构建 UploadManager 对象 $uploadMgr = new UploadManager(); // 调用 UploadManager 的 putFile 方法进行文件的上传。 - list($ret, $err) = $uploadMgr->putFile($token, $object, $filePath); + [$ret, $err] = $uploadMgr->putFile($token, $object, $filePath); if ($err !== null) { return false; - } else { - return config('dtapp.qiniu.kodo.url', '') . $object; } + + return config('dtapp.qiniu.kodo.url', '') . $object; } } diff --git a/src/service/tencent/CosService.php b/src/service/tencent/CosService.php index 9460c58..5c03c39 100644 --- a/src/service/tencent/CosService.php +++ b/src/service/tencent/CosService.php @@ -94,16 +94,14 @@ class CosService extends Service ); $key = $object; $file = fopen($filePath, "rb"); - if ($file) { - if (empty($this->bucket)) { - $this->getConfig(); - $result = $cosClient->putObject( - array( - 'Bucket' => $this->bucket, - 'Key' => $key, - 'Body' => $file) - ); - } + if ($file && empty($this->bucket)) { + $this->getConfig(); + $result = $cosClient->putObject( + array( + 'Bucket' => $this->bucket, + 'Key' => $key, + 'Body' => $file) + ); } return config('dtapp.tencent.cos.url', '') . $object; } diff --git a/src/service/wechat/WebAppService.php b/src/service/wechat/WebAppService.php index b292875..a816d36 100644 --- a/src/service/wechat/WebAppService.php +++ b/src/service/wechat/WebAppService.php @@ -332,7 +332,7 @@ class WebAppService extends Service } } // 注意 URL 一定要动态获取,不能 hardcode. - $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; + $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $timestamp = time(); $nonceStr = $this->createNonceStr(); @@ -355,7 +355,7 @@ class WebAppService extends Service $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $str = ""; for ($i = 0; $i < $length; $i++) { - $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); + $str .= $chars[random_int(0, strlen($chars) - 1)]; } return $str; } @@ -667,12 +667,15 @@ class WebAppService extends Service if (!empty($cache_mysql_value)) { $access_token['access_token'] = $cache_mysql_value; } else { + // 获取远程Token $accessToken_res = HttpService::instance() ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") ->toArray(); + // 保存到数据库 dtacache($file, $accessToken_res['access_token'], 6000); $access_token['access_token'] = $accessToken_res['access_token']; } + // 判断token是否可以使用 $judge = HttpService::instance() ->url("{$this->api_url}cgi-bin/getcallbackip?access_token={$access_token['access_token']}") ->toArray(); diff --git a/src/session/Mysql.php b/src/session/Mysql.php index 450e5e7..5878b82 100644 --- a/src/session/Mysql.php +++ b/src/session/Mysql.php @@ -99,15 +99,15 @@ class Mysql implements SessionHandlerInterface $result = Db::table($this->table_name) ->insert($params); return $result ? true : false; - } else { - $params = [ - 'session_expire' => Times::dateRear("Y-m-d H:i:s", $this->config['session_expire']), - 'session_data' => $data - ]; - $result = Db::table($this->table_name) - ->where('id', $get['id']) - ->update($params); - return $result ? true : false; } + + $params = [ + 'session_expire' => Times::dateRear("Y-m-d H:i:s", $this->config['session_expire']), + 'session_data' => $data + ]; + $result = Db::table($this->table_name) + ->where('id', $get['id']) + ->update($params); + return $result ? true : false; } }