@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | date_default_timezone_set('Asia/Shanghai'); |
| 59 | 59 | $msec = 0; |
| 60 | 60 | list($msec, $sec) = explode(' ', microtime()); |
| 61 | - return (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); |
|
| 61 | + return (float)sprintf('%.0f', (floatval($msec)+floatval($sec))*1000); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | date_default_timezone_set('Asia/Shanghai'); |
| 73 | 73 | $end_time = strtotime($end_time); |
| 74 | 74 | $start_time = $start_time == '' ? time() : strtotime($start_time); |
| 75 | - return $end_time - $start_time; |
|
| 75 | + return $end_time-$start_time; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if (empty($time)) { |
| 112 | 112 | $time = time(); |
| 113 | 113 | } |
| 114 | - return date($format, $time - $mun); |
|
| 114 | + return date($format, $time-$mun); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | if (empty($time)) { |
| 128 | 128 | $time = time(); |
| 129 | 129 | } |
| 130 | - return date($format, $time + $mun); |
|
| 130 | + return date($format, $time+$mun); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | { |
| 142 | 142 | date_default_timezone_set('Asia/Shanghai'); |
| 143 | 143 | $date = date('H:i'); |
| 144 | - $curTime = strtotime($date);//当前时分 |
|
| 145 | - $assignTime1 = strtotime($start);//获得指定分钟时间戳,00:00 |
|
| 146 | - $assignTime2 = strtotime($end);//获得指定分钟时间戳,01:00 |
|
| 144 | + $curTime = strtotime($date); //当前时分 |
|
| 145 | + $assignTime1 = strtotime($start); //获得指定分钟时间戳,00:00 |
|
| 146 | + $assignTime2 = strtotime($end); //获得指定分钟时间戳,01:00 |
|
| 147 | 147 | $result = false; |
| 148 | 148 | if ($curTime > $assignTime1 && $curTime < $assignTime2) { |
| 149 | 149 | $result = true; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | if (intval($type) === 3) { |
| 49 | 49 | $chars = "{$numbs}{$chars}"; |
| 50 | 50 | } |
| 51 | - $string = $prefix . $chars[rand(1, strlen($chars) - 1)]; |
|
| 51 | + $string = $prefix.$chars[rand(1, strlen($chars)-1)]; |
|
| 52 | 52 | if (isset($chars)) { |
| 53 | - while (strlen($string) < $size) $string .= $chars[rand(0, strlen($chars) - 1)]; |
|
| 53 | + while (strlen($string) < $size) $string .= $chars[rand(0, strlen($chars)-1)]; |
|
| 54 | 54 | } |
| 55 | 55 | return $string; |
| 56 | 56 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | if ($size < 14) { |
| 67 | 67 | $size = 14; |
| 68 | 68 | } |
| 69 | - $string = $prefix . date('Ymd') . (date('H') + date('i')) . date('s'); |
|
| 69 | + $string = $prefix.date('Ymd').(date('H')+date('i')).date('s'); |
|
| 70 | 70 | while (strlen($string) < $size) $string .= rand(0, 9); |
| 71 | 71 | return $string; |
| 72 | 72 | } |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function number($size = 12, $prefix = ''): string |
| 81 | 81 | { |
| 82 | - $time = time() . ''; |
|
| 82 | + $time = time().''; |
|
| 83 | 83 | if ($size < 10) { |
| 84 | 84 | $size = 10; |
| 85 | 85 | } |
| 86 | - $string = $prefix . ($time[0] . $time[1]) . substr($time, 2) . rand(0, 9); |
|
| 86 | + $string = $prefix.($time[0].$time[1]).substr($time, 2).rand(0, 9); |
|
| 87 | 87 | while (strlen($string) < $size) $string .= rand(0, 9); |
| 88 | 88 | return $string; |
| 89 | 89 | } |
@@ -50,7 +50,9 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | $string = $prefix . $chars[rand(1, strlen($chars) - 1)]; |
| 52 | 52 | if (isset($chars)) { |
| 53 | - while (strlen($string) < $size) $string .= $chars[rand(0, strlen($chars) - 1)]; |
|
| 53 | + while (strlen($string) < $size) { |
|
| 54 | + $string .= $chars[rand(0, strlen($chars) - 1)]; |
|
| 55 | + } |
|
| 54 | 56 | } |
| 55 | 57 | return $string; |
| 56 | 58 | } |
@@ -67,7 +69,9 @@ discard block |
||
| 67 | 69 | $size = 14; |
| 68 | 70 | } |
| 69 | 71 | $string = $prefix . date('Ymd') . (date('H') + date('i')) . date('s'); |
| 70 | - while (strlen($string) < $size) $string .= rand(0, 9); |
|
| 72 | + while (strlen($string) < $size) { |
|
| 73 | + $string .= rand(0, 9); |
|
| 74 | + } |
|
| 71 | 75 | return $string; |
| 72 | 76 | } |
| 73 | 77 | |
@@ -84,7 +88,9 @@ discard block |
||
| 84 | 88 | $size = 10; |
| 85 | 89 | } |
| 86 | 90 | $string = $prefix . ($time[0] . $time[1]) . substr($time, 2) . rand(0, 9); |
| 87 | - while (strlen($string) < $size) $string .= rand(0, 9); |
|
| 91 | + while (strlen($string) < $size) { |
|
| 92 | + $string .= rand(0, 9); |
|
| 93 | + } |
|
| 88 | 94 | return $string; |
| 89 | 95 | } |
| 90 | 96 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function extractBefore(string $str, int $start_num, int $end_num): string |
| 39 | 39 | { |
| 40 | - if (strlen($str) < $start_num + $end_num) { |
|
| 40 | + if (strlen($str) < $start_num+$end_num) { |
|
| 41 | 41 | return $str; |
| 42 | 42 | } |
| 43 | 43 | return substr($str, $start_num, $end_num); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | return false; |
| 154 | - } else { |
|
| 154 | + }else { |
|
| 155 | 155 | if ($str == $nee) { |
| 156 | 156 | return true; |
| 157 | 157 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | $xml = "<xml>"; |
| 45 | 45 | foreach ($values as $key => $val) { |
| 46 | 46 | if (is_array($val)) { |
| 47 | - $xml .= "<" . $key . ">" . $this->toXml($val) . "</" . $key . ">"; |
|
| 48 | - } else if (is_numeric($val)) { |
|
| 49 | - $xml .= "<" . $key . ">" . $val . "</" . $key . ">"; |
|
| 50 | - } else { |
|
| 51 | - $xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">"; |
|
| 47 | + $xml .= "<".$key.">".$this->toXml($val)."</".$key.">"; |
|
| 48 | + }else if (is_numeric($val)) { |
|
| 49 | + $xml .= "<".$key.">".$val."</".$key.">"; |
|
| 50 | + }else { |
|
| 51 | + $xml .= "<".$key."><![CDATA[".$val."]]></".$key.">"; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | $xml .= "</xml>"; |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\facade; |
| 23 | 23 | |
@@ -73,7 +73,9 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function error($info, $data = '{-null-}', $code = 0) |
| 75 | 75 | { |
| 76 | - if ($data === '{-null-}') $data = new stdClass(); |
|
| 76 | + if ($data === '{-null-}') { |
|
| 77 | + $data = new stdClass(); |
|
| 78 | + } |
|
| 77 | 79 | throw new HttpResponseException(json([ |
| 78 | 80 | 'code' => $code, 'info' => $info, 'data' => $data, |
| 79 | 81 | ])); |
@@ -87,7 +89,9 @@ discard block |
||
| 87 | 89 | */ |
| 88 | 90 | public function success($info, $data = '{-null-}', $code = 1) |
| 89 | 91 | { |
| 90 | - if ($data === '{-null-}') $data = new stdClass(); |
|
| 92 | + if ($data === '{-null-}') { |
|
| 93 | + $data = new stdClass(); |
|
| 94 | + } |
|
| 91 | 95 | throw new HttpResponseException(json([ |
| 92 | 96 | 'code' => $code, 'info' => $info, 'data' => $data, |
| 93 | 97 | ])); |
@@ -110,7 +114,9 @@ discard block |
||
| 110 | 114 | */ |
| 111 | 115 | public function fetch($tpl = '', $vars = []) |
| 112 | 116 | { |
| 113 | - foreach ($this as $name => $value) $vars[$name] = $value; |
|
| 117 | + foreach ($this as $name => $value) { |
|
| 118 | + $vars[$name] = $value; |
|
| 119 | + } |
|
| 114 | 120 | throw new HttpResponseException(view($tpl, $vars)); |
| 115 | 121 | } |
| 116 | 122 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | public function read(string $sessionId): string |
| 58 | 58 | { |
| 59 | 59 | return (string)Db::table($this->table_name) |
| 60 | - ->where('session_id', $this->config['session_prefix'] . $sessionId) |
|
| 60 | + ->where('session_id', $this->config['session_prefix'].$sessionId) |
|
| 61 | 61 | ->whereTime('session_expire', '>=', time()) |
| 62 | 62 | ->order('session_expire desc') |
| 63 | 63 | ->value('session_data', ''); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | public function delete(string $sessionId): bool |
| 73 | 73 | { |
| 74 | 74 | $result = Db::table($this->table_name) |
| 75 | - ->where('session_id', $this->config['session_prefix'] . $sessionId) |
|
| 75 | + ->where('session_id', $this->config['session_prefix'].$sessionId) |
|
| 76 | 76 | ->delete(); |
| 77 | 77 | return $result ? true : false; |
| 78 | 78 | } |
@@ -89,20 +89,20 @@ discard block |
||
| 89 | 89 | public function write(string $sessionId, string $data): bool |
| 90 | 90 | { |
| 91 | 91 | $get = Db::table($this->table_name) |
| 92 | - ->where('session_id', $this->config['session_prefix'] . $sessionId) |
|
| 92 | + ->where('session_id', $this->config['session_prefix'].$sessionId) |
|
| 93 | 93 | ->whereTime('session_expire', '>=', time()) |
| 94 | 94 | ->field('id') |
| 95 | 95 | ->find(); |
| 96 | 96 | if (empty($get)) { |
| 97 | 97 | $params = [ |
| 98 | - 'session_id' => $this->config['session_prefix'] . $sessionId, |
|
| 98 | + 'session_id' => $this->config['session_prefix'].$sessionId, |
|
| 99 | 99 | 'session_expire' => Times::dateRear("Y-m-d H:i:s", $this->config['session_expire']), |
| 100 | 100 | 'session_data' => $data |
| 101 | 101 | ]; |
| 102 | 102 | $result = Db::table($this->table_name) |
| 103 | 103 | ->insert($params); |
| 104 | 104 | return $result ? true : false; |
| 105 | - } else { |
|
| 105 | + }else { |
|
| 106 | 106 | $params = [ |
| 107 | 107 | 'session_expire' => Times::dateRear("Y-m-d H:i:s", $this->config['session_expire']), |
| 108 | 108 | 'session_data' => $data |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | if (isset($this->aes_decrypt_data[$name])) { |
| 188 | 188 | return $this->aes_decrypt_data[$name]; |
| 189 | - } else { |
|
| 189 | + }else { |
|
| 190 | 190 | return $default; |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $rear = strtotime('+2minute'); |
| 219 | 219 | if ($timestamp <= $rear && $timestamp >= $before) { |
| 220 | 220 | $this->aes_decrypt_data = $data; |
| 221 | - } else { |
|
| 221 | + }else { |
|
| 222 | 222 | $this->error('已超时,请重新尝试!'); |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | if (!empty(is_array($data))) { |
| 241 | 241 | $data = json_encode($data); |
| 242 | 242 | } |
| 243 | - return urlencode(base64_encode(openssl_encrypt($data, 'AES-128-CBC', $this->aes_md5, 1, $this->aes_md5_iv . $timestamp))); |
|
| 243 | + return urlencode(base64_encode(openssl_encrypt($data, 'AES-128-CBC', $this->aes_md5, 1, $this->aes_md5_iv.$timestamp))); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -257,6 +257,6 @@ discard block |
||
| 257 | 257 | if (empty($this->aes_md5_iv)) { |
| 258 | 258 | $this->setAesMd5Iv(); |
| 259 | 259 | } |
| 260 | - return openssl_decrypt(base64_decode(urldecode($data)), "AES-128-CBC", $this->aes_md5, true, $this->aes_md5_iv . $timestamp); |
|
| 260 | + return openssl_decrypt(base64_decode(urldecode($data)), "AES-128-CBC", $this->aes_md5, true, $this->aes_md5_iv.$timestamp); |
|
| 261 | 261 | } |
| 262 | 262 | } |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | 'domain' => request()->domain(), |
| 106 | 106 | 'url' => request()->url(), |
| 107 | 107 | 'node' => config('dtapp.exception.wechat.node', ''), |
| 108 | - 'info' => "ServerIp:" . $ip . ";CdnIp:" . $_SERVER['REMOTE_ADDR'] . ";ClientIp:" . get_ip(), |
|
| 108 | + 'info' => "ServerIp:".$ip.";CdnIp:".$_SERVER['REMOTE_ADDR'].";ClientIp:".get_ip(), |
|
| 109 | 109 | 'ip' => $ipinfo['location_all'], |
| 110 | 110 | 'error' => base64_encode($msg) |
| 111 | 111 | ]) |