@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public function __construct($options = []) |
67 | 67 | { |
68 | 68 | $this->_c = Arrays::merge($this->_c, $options); |
69 | - setlocale(LC_ALL, (string) I::get($this->_c, 'locale', 'zh_CN.UTF-8')); |
|
69 | + setlocale(LC_ALL, (string)I::get($this->_c, 'locale', 'zh_CN.UTF-8')); |
|
70 | 70 | clearstatcache(); |
71 | 71 | } |
72 | 72 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | private function __file($file) |
94 | 94 | { |
95 | - return (string) I::getAlias($file); |
|
95 | + return (string)I::getAlias($file); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | if ($result && $info = curl_getinfo($curl)) { |
152 | 152 | if (200 == $info['http_code']) { |
153 | 153 | $this->_attributes[$hashName]['isExists'] = true; |
154 | - $this->_attributes[$hashName]['fileSize'] = (int) $info['download_content_length']; |
|
154 | + $this->_attributes[$hashName]['fileSize'] = (int)$info['download_content_length']; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | curl_close($curl); |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | if ('fsockopen' === $this->_c['loader']) { |
162 | 162 | $url = parse_url($fileName); |
163 | 163 | $host = $url['host']; |
164 | - $path = (string) I::get($url, 'path', '/'); |
|
165 | - $port = (int) I::get($url, 'port', 80); |
|
164 | + $path = (string)I::get($url, 'path', '/'); |
|
165 | + $port = (int)I::get($url, 'port', 80); |
|
166 | 166 | $fp = fsockopen($host, $port); |
167 | 167 | if (is_resource($fp)) { |
168 | 168 | fputs($fp, "GET {$path} HTTP/1.1\r\n"); |
@@ -171,17 +171,17 @@ discard block |
||
171 | 171 | while (!feof($fp)) { |
172 | 172 | $line = fgets($fp); |
173 | 173 | preg_match('/HTTP.*(\s\d{3}\s)/', $line, $arr) && $this->_attributes[$hashName]['isExists'] = true; |
174 | - preg_match('/Content-Length:(.*)/si', $line, $arr) && $this->_attributes[$hashName]['fileSize'] = (int) trim($arr[1]); |
|
174 | + preg_match('/Content-Length:(.*)/si', $line, $arr) && $this->_attributes[$hashName]['fileSize'] = (int)trim($arr[1]); |
|
175 | 175 | } |
176 | 176 | fclose($fp); |
177 | 177 | } |
178 | 178 | return $this; |
179 | 179 | } |
180 | - if ('fopen' === $this->_c['loader'] && (bool) ini_get('allow_url_fopen')) { |
|
181 | - $headArray = (array) get_headers($fileName, 1); |
|
180 | + if ('fopen' === $this->_c['loader'] && (bool)ini_get('allow_url_fopen')) { |
|
181 | + $headArray = (array)get_headers($fileName, 1); |
|
182 | 182 | if (preg_match('/200/', $headArray[0])) { |
183 | 183 | $this->_attributes[$hashName]['isExists'] = true; |
184 | - $this->_attributes[$hashName]['fileSize'] = (int) $headArray['Content-Length']; |
|
184 | + $this->_attributes[$hashName]['fileSize'] = (int)$headArray['Content-Length']; |
|
185 | 185 | } |
186 | 186 | return $this; |
187 | 187 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | public function line($fileName, $lineNumber = 0, $autoClose = false) |
279 | 279 | { |
280 | 280 | $spl = $this->spl($fileName, 'r'); |
281 | - $lineNumber = (int) $lineNumber; |
|
281 | + $lineNumber = (int)$lineNumber; |
|
282 | 282 | foreach ($this->linesGenerator($fileName, $autoClose) as $k => $line) { |
283 | 283 | if ($k === $lineNumber) { |
284 | 284 | $spl->rewind(); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | */ |
385 | 385 | public function getFilesize($fileName) |
386 | 386 | { |
387 | - return (int) $this->attribute($fileName, 'fileSize'); |
|
387 | + return (int)$this->attribute($fileName, 'fileSize'); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | */ |
417 | 417 | public function isFile($file) |
418 | 418 | { |
419 | - return (bool) $this->attribute($file, 'isExists'); |
|
419 | + return (bool)$this->attribute($file, 'isExists'); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | list($originName, $downloadName) = $this->fileMap($fileName); |
601 | 601 | $originName = $this->__file($originName); |
602 | 602 | try { |
603 | - $ip = (string) I::get($config, self::C_DOWNLOAD_IP, '*'); |
|
603 | + $ip = (string)I::get($config, self::C_DOWNLOAD_IP, '*'); |
|
604 | 604 | if ('*' !== $ip) { |
605 | 605 | C::assertTrue(Arrays::in((new Request())->getUserIP(), Strings::toArray($ip)), 'http/1.1 403.6 此 IP 禁止访问'); |
606 | 606 | } |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | header('Accept-Ranges:bytes'); |
611 | 611 | header('Content-Length:' . $fileSize); |
612 | 612 | header('Content-Disposition: attachment; filename=' . $downloadName); |
613 | - $speed = (int) I::get($config, self::C_DOWNLOAD_SPEED, 0); |
|
613 | + $speed = (int)I::get($config, self::C_DOWNLOAD_SPEED, 0); |
|
614 | 614 | $xSendFile = I::get($config, self::C_DOWNLOAD_X_SEND_FILE, false); |
615 | - $xSendFileRoot = (string) I::get($config, self::C_DOWNLOAD_X_SEND_FILE_ROOT, '/protected/'); |
|
615 | + $xSendFileRoot = (string)I::get($config, self::C_DOWNLOAD_X_SEND_FILE_ROOT, '/protected/'); |
|
616 | 616 | if (true === $xSendFile) { |
617 | 617 | $path = rtrim($xSendFileRoot, '/') . '/' . $this->getBasename($originName); |
618 | 618 | header('X-Accel-Redirect: ' . $path); // Nginx、Cherokee 实现了该头 |