@@ -21,7 +21,9 @@ |
||
| 21 | 21 | $this->headers = $headers; |
| 22 | 22 | |
| 23 | 23 | /** message */ |
| 24 | - if(empty($message)) $message = isset(StatusCode::$status_code[$statusCode]) ? StatusCode::$status_code[$statusCode] :StatusCode::$status_code[StatusCode::COMMON_UNKNOWN]; |
|
| 24 | + if(empty($message)) { |
|
| 25 | + $message = isset(StatusCode::$status_code[$statusCode]) ? StatusCode::$status_code[$statusCode] :StatusCode::$status_code[StatusCode::COMMON_UNKNOWN]; |
|
| 26 | + } |
|
| 25 | 27 | parent::__construct('ERROR_TINYMENG_TOOL: '.$message, $code, $previous); |
| 26 | 28 | } |
| 27 | 29 | |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | |
| 38 | 38 | if($operation == 'decode'){ |
| 39 | 39 | $string = base64_decode(substr($string, $ckey_length)); |
| 40 | - }else{ |
|
| 40 | + } else{ |
|
| 41 | 41 | $a = $expiry ? $expiry + time() : 0; |
| 42 | 42 | $string = sprintf('%010d', $a).substr(md5($string.$keyb), 0, 16).$string; |
| 43 | 43 | } |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | throw new TinymengException(StatusCode::COMMON_TINYMENG_REQUEST_METHOD, |
| 102 | 102 | '[httpPost]: POST request was aborted ! Request url :' . $url . ' , post request data : ' . var_export($param,true) |
| 103 | 103 | ); |
| 104 | - }elseif(intval($info["http_code"]) != $http_code){ |
|
| 104 | + } elseif(intval($info["http_code"]) != $http_code){ |
|
| 105 | 105 | throw new TinymengException(StatusCode::COMMON_TINYMENG_REQUEST_METHOD, |
| 106 | 106 | '[httpPost]: POST request was aborted ! Request url :' . $url . ' , post request data : ' . var_export($param,true).' ,return code : '.$info["http_code"] .' ,return content : '.$content |
| 107 | 107 | ); |
| 108 | 108 | } else { |
| 109 | 109 | return $content; |
| 110 | 110 | } |
| 111 | - }else{ |
|
| 111 | + } else{ |
|
| 112 | 112 | return $content; |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | throw new TinymengException(StatusCode::COMMON_TINYMENG_REQUEST_METHOD, |
| 180 | 180 | '[httpGet]: GET request was aborted ! Request url :' . $url |
| 181 | 181 | ); |
| 182 | - }elseif(intval($info["http_code"]) != $http_code){ |
|
| 182 | + } elseif(intval($info["http_code"]) != $http_code){ |
|
| 183 | 183 | throw new TinymengException(StatusCode::COMMON_TINYMENG_REQUEST_METHOD, |
| 184 | 184 | '[httpGet]: GET request was aborted ! Request url :' . $url .' ,return code : '.$info["http_code"] .' ,return content : '.$content |
| 185 | 185 | ); |
| 186 | 186 | } else { |
| 187 | 187 | return $content; |
| 188 | 188 | } |
| 189 | - }else{ |
|
| 189 | + } else{ |
|
| 190 | 190 | return $content; |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | if($type == 'asc'){ |
| 25 | 25 | asort($keysValue); |
| 26 | - }else{ |
|
| 26 | + } else{ |
|
| 27 | 27 | arsort($keysValue); |
| 28 | 28 | } |
| 29 | 29 | reset($keysValue); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | if(is_array($val)){ |
| 89 | 89 | if(empty($val)){ |
| 90 | 90 | settype($val,'object'); |
| 91 | - }else{ |
|
| 91 | + } else{ |
|
| 92 | 92 | self::nullArrayToObject($val); |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | //内容写入文件 |
| 63 | 63 | if($file_append === false){ |
| 64 | 64 | file_put_contents($file_name,$content); |
| 65 | - }else{ |
|
| 65 | + } else{ |
|
| 66 | 66 | file_put_contents($file_name,$content,FILE_APPEND); |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $handle = fopen($file_name, 'w'); |
| 93 | 93 | fwrite($handle, $content); |
| 94 | 94 | fclose($handle); |
| 95 | - }else{ |
|
| 95 | + } else{ |
|
| 96 | 96 | $handle = fopen($file_name, 'a'); |
| 97 | 97 | fwrite($handle, $content); |
| 98 | 98 | fclose($handle); |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | if(empty($time)){ |
| 76 | 76 | list($msec, $sec) = explode(' ', microtime()); |
| 77 | 77 | $millisecond = (int)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); |
| 78 | - }elseif(is_numeric($time) && strlen((string)$time)==10){ |
|
| 78 | + } elseif(is_numeric($time) && strlen((string)$time)==10){ |
|
| 79 | 79 | $millisecond = (string)$time."000"; |
| 80 | - }else{ |
|
| 80 | + } else{ |
|
| 81 | 81 | $millisecond = strtotime($time)."000"; |
| 82 | 82 | } |
| 83 | 83 | return (int)$millisecond; |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | foreach ($string as $key => $val) { |
| 163 | 163 | $_key = self::autoCharset($key, $from, $to); |
| 164 | 164 | $string[$_key] = self::autoCharset($val, $from, $to); |
| 165 | - if ($key != $_key) |
|
| 166 | - unset($string[$key]); |
|
| 165 | + if ($key != $_key) { |
|
| 166 | + unset($string[$key]); |
|
| 167 | + } |
|
| 167 | 168 | } |
| 168 | 169 | return $string; |
| 169 | - } |
|
| 170 | - else { |
|
| 170 | + } else { |
|
| 171 | 171 | return $string; |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | public static function getTime($date,$is_timestamp=false):string { |
| 206 | 206 | if($is_timestamp === true){ |
| 207 | 207 | $time = $date; |
| 208 | - }else{ |
|
| 208 | + } else{ |
|
| 209 | 209 | $time = strtotime($date);//时间转换为时间戳 |
| 210 | 210 | } |
| 211 | 211 | |
@@ -19,11 +19,11 @@ |
||
| 19 | 19 | public static function getIp(){ |
| 20 | 20 | if(!empty($_SERVER["HTTP_CLIENT_IP"])){ |
| 21 | 21 | $cip = $_SERVER["HTTP_CLIENT_IP"]; |
| 22 | - }else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){ |
|
| 22 | + } else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){ |
|
| 23 | 23 | $cip = $_SERVER["HTTP_X_FORWARDED_FOR"]; |
| 24 | - }else if(!empty($_SERVER["REMOTE_ADDR"])){ |
|
| 24 | + } else if(!empty($_SERVER["REMOTE_ADDR"])){ |
|
| 25 | 25 | $cip = $_SERVER["REMOTE_ADDR"]; |
| 26 | - }else{ |
|
| 26 | + } else{ |
|
| 27 | 27 | $cip = ''; |
| 28 | 28 | } |
| 29 | 29 | preg_match("/[\d\.]{7,15}/", $cip, $cips); |
@@ -36,8 +36,9 @@ discard block |
||
| 36 | 36 | public function open($filename,$Fromfilename=null){ |
| 37 | 37 | if (!empty($filename)){ |
| 38 | 38 | $this->setFileName($filename); |
| 39 | - if(!$this->client->open($this->fileName, ZipArchive::CREATE)) |
|
| 40 | - return 'File open failed'; |
|
| 39 | + if(!$this->client->open($this->fileName, ZipArchive::CREATE)) { |
|
| 40 | + return 'File open failed'; |
|
| 41 | + } |
|
| 41 | 42 | } |
| 42 | 43 | if(!empty($Fromfilename)){ |
| 43 | 44 | if(is_dir($Fromfilename)){ |
@@ -54,7 +55,7 @@ discard block |
||
| 54 | 55 | } |
| 55 | 56 | } |
| 56 | 57 | } |
| 57 | - }else{ |
|
| 58 | + } else{ |
|
| 58 | 59 | $this->client->addFile ($Fromfilename); |
| 59 | 60 | } |
| 60 | 61 | } |
@@ -129,17 +130,20 @@ discard block |
||
| 129 | 130 | * @time: 2022/4/27 9:38 |
| 130 | 131 | */ |
| 131 | 132 | public function unzip($filename,$dir){ |
| 132 | - if(!file_exists($filename)) |
|
| 133 | - return 'File does not exist'; |
|
| 134 | - if(!$this->client->open($filename)) |
|
| 135 | - return 'File open failed'; |
|
| 133 | + if(!file_exists($filename)) { |
|
| 134 | + return 'File does not exist'; |
|
| 135 | + } |
|
| 136 | + if(!$this->client->open($filename)) { |
|
| 137 | + return 'File open failed'; |
|
| 138 | + } |
|
| 136 | 139 | if(!is_dir($dir)){ |
| 137 | 140 | mkdir($dir,775); |
| 138 | - }else{ |
|
| 141 | + } else{ |
|
| 139 | 142 | return 'Dir mk failed'; |
| 140 | 143 | } |
| 141 | - if(!$this->client->extractTo($dir)) |
|
| 142 | - return 'File unzip failed'; |
|
| 144 | + if(!$this->client->extractTo($dir)) { |
|
| 145 | + return 'File unzip failed'; |
|
| 146 | + } |
|
| 143 | 147 | return $this; |
| 144 | 148 | } |
| 145 | 149 | |