@@ -32,8 +32,8 @@ |
||
32 | 32 | protected $webAccess; |
33 | 33 | |
34 | 34 | /** |
35 | - * @var string thumbnail_url rule. |
|
36 | - */ |
|
35 | + * @var string thumbnail_url rule. |
|
36 | + */ |
|
37 | 37 | protected $thumbnailUrlFormat; |
38 | 38 | |
39 | 39 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | // With curl, the thumb is extracted during the download |
91 | - if ($this->webAccess instanceof WebAccessCUrl && ! empty($thumbnail)) { |
|
91 | + if ($this->webAccess instanceof WebAccessCUrl && !empty($thumbnail)) { |
|
92 | 92 | return $thumbnail; |
93 | 93 | } |
94 | 94 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | if (preg_match($this->urlRegex, $content, $matches) !== 0) { |
155 | 155 | $total = count($matches); |
156 | 156 | for ($i = 1; $i < $total; $i++) { |
157 | - $thumbnailUrl = str_replace('${'. $i . '}', $matches[$i], $thumbnailUrl); |
|
157 | + $thumbnailUrl = str_replace('${'.$i.'}', $matches[$i], $thumbnailUrl); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // Match only options (not ${number}) |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function checkRules($rules) |
175 | 175 | { |
176 | - if (! FinderUtils::checkMandatoryRules($rules, [ |
|
176 | + if (!FinderUtils::checkMandatoryRules($rules, [ |
|
177 | 177 | 'image_regex', |
178 | 178 | 'thumbnail_url' |
179 | 179 | ])) { |
@@ -103,7 +103,7 @@ |
||
103 | 103 | */ |
104 | 104 | public function checkRules($rules) |
105 | 105 | { |
106 | - if (! FinderUtils::checkMandatoryRules($rules, [ |
|
106 | + if (!FinderUtils::checkMandatoryRules($rules, [ |
|
107 | 107 | 'image_xpath', |
108 | 108 | 'thumbnail_url' |
109 | 109 | ])) { |
@@ -32,8 +32,8 @@ |
||
32 | 32 | protected $webAccess; |
33 | 33 | |
34 | 34 | /** |
35 | - * @var string thumbnail_url rule. |
|
36 | - */ |
|
35 | + * @var string thumbnail_url rule. |
|
36 | + */ |
|
37 | 37 | protected $thumbnailUrlFormat; |
38 | 38 | |
39 | 39 | /** |
@@ -30,8 +30,8 @@ |
||
30 | 30 | |
31 | 31 | $size = $this->getOptionValue('size'); |
32 | 32 | // One size is actually no suffix... |
33 | - $size = ! empty($size) ? '_'. $size : ''; |
|
34 | - $thumb = preg_replace('#(.*)_\w(\.\w+)$#i', '$1'. $size .'$2', $thumb); |
|
33 | + $size = !empty($size) ? '_'.$size : ''; |
|
34 | + $thumb = preg_replace('#(.*)_\w(\.\w+)$#i', '$1'.$size.'$2', $thumb); |
|
35 | 35 | return $thumb; |
36 | 36 | } |
37 | 37 | } |
@@ -104,7 +104,7 @@ |
||
104 | 104 | try { |
105 | 105 | $downloader = new Thumbnailer($url, $options, $_SERVER); |
106 | 106 | return $downloader->getThumbnail(); |
107 | - } catch(MissingRequirementException $e) { |
|
107 | + } catch (MissingRequirementException $e) { |
|
108 | 108 | throw $e; |
109 | 109 | } catch (WebThumbnailerException $e) { |
110 | 110 | if (isset($options[self::DEBUG]) && $options[self::DEBUG] === true) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | if (empty($thumburl)) { |
107 | - $error = 'No thumbnail could be found using '. $this->finder->getName() .' finder: '. $this->url; |
|
107 | + $error = 'No thumbnail could be found using '.$this->finder->getName().' finder: '.$this->url; |
|
108 | 108 | throw new ThumbnailNotFoundException($error); |
109 | 109 | } |
110 | 110 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function thumbnailStrictHotlink($thumburl) |
136 | 136 | { |
137 | - if (! $this->finder->isHotlinkAllowed()) { |
|
137 | + if (!$this->finder->isHotlinkAllowed()) { |
|
138 | 138 | throw new ThumbnailNotFoundException('Hotlink is not supported for this URL.'); |
139 | 139 | } |
140 | 140 | return $thumburl; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function thumbnailHotlink($thumburl) |
151 | 151 | { |
152 | - if (! $this->finder->isHotlinkAllowed()) { |
|
152 | + if (!$this->finder->isHotlinkAllowed()) { |
|
153 | 153 | return $this->thumbnailDownload($thumburl); |
154 | 154 | } |
155 | 155 | return $thumburl; |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | |
200 | 200 | if (strpos($headers[0], '200') === false) { |
201 | 201 | throw new DownloadException( |
202 | - 'Unreachable thumbnail URL. HTTP '. $headers[0] .'.'. PHP_EOL . |
|
203 | - ' - thumbnail URL: '. $thumburl |
|
202 | + 'Unreachable thumbnail URL. HTTP '.$headers[0].'.'.PHP_EOL. |
|
203 | + ' - thumbnail URL: '.$thumburl |
|
204 | 204 | ); |
205 | 205 | } |
206 | 206 | |
207 | 207 | if (empty($data)) { |
208 | - throw new DownloadException('Couldn\'t download the thumbnail at '. $thumburl); |
|
208 | + throw new DownloadException('Couldn\'t download the thumbnail at '.$thumburl); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | // Resize and save it locally. |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->options[WebThumbnailer::CROP] |
218 | 218 | ); |
219 | 219 | |
220 | - if (! is_file($thumbPath)) { |
|
220 | + if (!is_file($thumbPath)) { |
|
221 | 221 | throw new ImageConvertException('Thumbnail was not generated.'); |
222 | 222 | } |
223 | 223 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | protected function setSizeOptions($options) { |
295 | 295 | // Width |
296 | 296 | $width = 0; |
297 | - if (! empty($options[WebThumbnailer::MAX_WIDTH])) { |
|
297 | + if (!empty($options[WebThumbnailer::MAX_WIDTH])) { |
|
298 | 298 | if (SizeUtils::isMetaSize($options[WebThumbnailer::MAX_WIDTH])) { |
299 | 299 | $width = SizeUtils::getMetaSize($options[WebThumbnailer::MAX_WIDTH]); |
300 | 300 | } else if (is_int($options[WebThumbnailer::MAX_WIDTH]) |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | if (count(array_intersect($incompatibleFlags, $options)) > 1) { |
345 | 345 | $error = 'Only one of these flags can be set between: '; |
346 | 346 | foreach ($incompatibleFlags as $flag) { |
347 | - $error .= $flag .' '; |
|
347 | + $error .= $flag.' '; |
|
348 | 348 | } |
349 | 349 | throw new BadRulesException($error); |
350 | 350 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @var array List of JSON configuration file path. |
24 | 24 | */ |
25 | 25 | public static $configFiles = [ |
26 | - FileUtils::RESOURCES_PATH . 'settings.json', |
|
26 | + FileUtils::RESOURCES_PATH.'settings.json', |
|
27 | 27 | ]; |
28 | 28 | |
29 | 29 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | protected static function initialize() |
48 | 48 | { |
49 | 49 | self::$loadedConfig = []; |
50 | - foreach(self::$configFiles as $configFile) { |
|
50 | + foreach (self::$configFiles as $configFile) { |
|
51 | 51 | self::$loadedConfig = array_replace_recursive(self::$loadedConfig, DataUtils::loadJson($configFile)); |
52 | 52 | } |
53 | 53 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected static function getConfig($settings, $config) |
102 | 102 | { |
103 | - if (! is_array($settings) || count($settings) == 0) { |
|
103 | + if (!is_array($settings) || count($settings) == 0) { |
|
104 | 104 | return self::$NOT_FOUND; |
105 | 105 | } |
106 | 106 |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | $maxBytes = ConfigManager::get('settings.default.max_img_dl', 16777216); |
60 | 60 | } |
61 | 61 | |
62 | - $cookie = ConfigManager::get('settings.path.cache') . '/cookie.txt'; |
|
62 | + $cookie = ConfigManager::get('settings.path.cache').'/cookie.txt'; |
|
63 | 63 | $userAgent = |
64 | 64 | 'Mozilla/5.0 (X11; Linux x86_64; rv:45.0; WebThumbnailer)' |
65 | 65 | . ' Gecko/20100101 Firefox/45.0'; |
66 | 66 | $acceptLanguage = |
67 | - substr(setlocale(LC_COLLATE, 0), 0, 2) . ',en-US;q=0.7,en;q=0.3'; |
|
67 | + substr(setlocale(LC_COLLATE, 0), 0, 2).',en-US;q=0.7,en;q=0.3'; |
|
68 | 68 | $maxRedirs = 6; |
69 | 69 | |
70 | 70 | $ch = curl_init($url); |
@@ -73,26 +73,26 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | // General cURL settings |
76 | - curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
|
77 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
78 | - curl_setopt($ch, CURLOPT_HEADER, true); |
|
76 | + curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
|
77 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
78 | + curl_setopt($ch, CURLOPT_HEADER, true); |
|
79 | 79 | curl_setopt( |
80 | 80 | $ch, |
81 | 81 | CURLOPT_HTTPHEADER, |
82 | - ['Accept-Language: ' . $acceptLanguage] |
|
82 | + ['Accept-Language: '.$acceptLanguage] |
|
83 | 83 | ); |
84 | - curl_setopt($ch, CURLOPT_MAXREDIRS, $maxRedirs); |
|
85 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
86 | - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
87 | - curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); |
|
84 | + curl_setopt($ch, CURLOPT_MAXREDIRS, $maxRedirs); |
|
85 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
86 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
87 | + curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); |
|
88 | 88 | |
89 | 89 | curl_setopt($ch, CURLOPT_COOKIESESSION, true); |
90 | - curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); |
|
91 | - curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); |
|
90 | + curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); |
|
91 | + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); |
|
92 | 92 | |
93 | 93 | // Max download size management |
94 | - curl_setopt($ch, CURLOPT_BUFFERSIZE, 1024*16); |
|
95 | - curl_setopt($ch, CURLOPT_NOPROGRESS, false); |
|
94 | + curl_setopt($ch, CURLOPT_BUFFERSIZE, 1024 * 16); |
|
95 | + curl_setopt($ch, CURLOPT_NOPROGRESS, false); |
|
96 | 96 | curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, |
97 | 97 | function($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes) |
98 | 98 | { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | curl_close($ch); |
111 | 111 | |
112 | 112 | if ($response === false) { |
113 | - return [[0 => 'curl_exec() error #'. $errorNo .': ' . $errorStr], false]; |
|
113 | + return [[0 => 'curl_exec() error #'.$errorNo.': '.$errorStr], false]; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // Formatting output like the fallback method |
@@ -31,13 +31,13 @@ |
||
31 | 31 | $context = $this->getContext($timeout, false); |
32 | 32 | stream_context_set_default($context); |
33 | 33 | list($headers, $finalUrl) = $this->getRedirectedHeaders($url, $timeout, $maxRedr); |
34 | - if (! $headers || strpos($headers[0], '200 OK') === false) { |
|
34 | + if (!$headers || strpos($headers[0], '200 OK') === false) { |
|
35 | 35 | $context = $this->getContext($timeout, true); |
36 | 36 | stream_context_set_default($context); |
37 | 37 | list($headers, $finalUrl) = $this->getRedirectedHeaders($url, $timeout, $maxRedr); |
38 | 38 | } |
39 | 39 | |
40 | - if (! $headers) { |
|
40 | + if (!$headers) { |
|
41 | 41 | return array($headers, false); |
42 | 42 | } |
43 | 43 |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public static function getDomain($url) |
22 | 22 | { |
23 | - if (! parse_url($url, PHP_URL_SCHEME)) { |
|
24 | - $url = 'http://' . $url; |
|
23 | + if (!parse_url($url, PHP_URL_SCHEME)) { |
|
24 | + $url = 'http://'.$url; |
|
25 | 25 | } |
26 | 26 | return strtolower(parse_url($url, PHP_URL_HOST)); |
27 | 27 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public static function generateRelativeUrlFromPath($server, $path) |
42 | 42 | { |
43 | 43 | if (isset($server['DOCUMENT_ROOT'])) { |
44 | - $root = ! empty($server['DOCUMENT_ROOT']) ? rtrim($server['DOCUMENT_ROOT'], '/') .'/' : ''; |
|
44 | + $root = !empty($server['DOCUMENT_ROOT']) ? rtrim($server['DOCUMENT_ROOT'], '/').'/' : ''; |
|
45 | 45 | return substr($path, strlen($root)); |
46 | 46 | } |
47 | 47 | return $path; |