@@ -21,7 +21,7 @@ |
||
21 | 21 | public static function getWebAccess($url = null) |
22 | 22 | { |
23 | 23 | // Local file |
24 | - if (! empty($url) && $url[0] == '/') { |
|
24 | + if (!empty($url) && $url[0] == '/') { |
|
25 | 25 | return new WebAccessLocal(); |
26 | 26 | } |
27 | 27 |
@@ -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 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * Thumbnails image cache. |
28 | 28 | */ |
29 | - const TYPE_THUMB = 'thumb'; |
|
29 | + const TYPE_THUMB = 'thumb'; |
|
30 | 30 | /** |
31 | 31 | * Finder cache. |
32 | 32 | */ |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | self::rebuildCacheFolders(); |
57 | 57 | return self::getCachePath($type, true); |
58 | 58 | } else if (!$path) { |
59 | - throw new IOException('Cache folders are not writable: '. $cache); |
|
59 | + throw new IOException('Cache folders are not writable: '.$cache); |
|
60 | 60 | } |
61 | 61 | return $path; |
62 | 62 | } |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | self::createDomainThumbCacheFolder($domain, $type); |
79 | 79 | $domainFolder = FileUtils::getPath(self::getCachePath($type), $domain); |
80 | 80 | if ($type === self::TYPE_THUMB) { |
81 | - $suffix = $width . $height . ($crop ? '1' : '0') .'.png'; |
|
81 | + $suffix = $width.$height.($crop ? '1' : '0').'.png'; |
|
82 | 82 | } else { |
83 | 83 | $suffix = ''; |
84 | 84 | } |
85 | - return $domainFolder . self::getThumbFilename($url) . $suffix; |
|
85 | + return $domainFolder.self::getThumbFilename($url).$suffix; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public static function isCacheValid($cacheFile, $domain, $type) { |
101 | 101 | $out = false; |
102 | - $cacheDuration = ConfigManager::get('settings.cache_duration', 3600*24*31); |
|
102 | + $cacheDuration = ConfigManager::get('settings.cache_duration', 3600 * 24 * 31); |
|
103 | 103 | |
104 | 104 | if (is_readable($cacheFile) |
105 | 105 | && ($cacheDuration < 0 || (time() - filemtime($cacheFile)) < $cacheDuration) |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected static function createDomainThumbCacheFolder($domain, $type) |
122 | 122 | { |
123 | - $domainFolder = self::getCachePath($type) . $domain; |
|
123 | + $domainFolder = self::getCachePath($type).$domain; |
|
124 | 124 | if (!file_exists($domainFolder)) { |
125 | 125 | mkdir($domainFolder, 0775, false); |
126 | - touch($domainFolder . '/' . self::$CLEAN_FILE); |
|
126 | + touch($domainFolder.'/'.self::$CLEAN_FILE); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | protected static function checkCacheType($type) |
151 | 151 | { |
152 | 152 | if ($type != self::TYPE_THUMB && $type != self::TYPE_FINDER) { |
153 | - throw new CacheException('Unknown cache type '. $type); |
|
153 | + throw new CacheException('Unknown cache type '.$type); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 |
@@ -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; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public static function buildRegex($regex, $flags) |
26 | 26 | { |
27 | - return '{' . $regex . '}' . $flags; |
|
27 | + return '{'.$regex.'}'.$flags; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | } else { |
49 | - if (! isset($rules[$value])) { |
|
49 | + if (!isset($rules[$value])) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function generateThumbnail($imageStr, $target, $maxWidth, $maxHeight, $crop = false) |
34 | 34 | { |
35 | - if (! touch($target)) { |
|
35 | + if (!touch($target)) { |
|
36 | 36 | throw new ImageConvertException('Target file is not writable.'); |
37 | 37 | } |
38 | 38 | |
39 | - if ($crop && ($maxWidth == 0 || $maxHeight == 0)) { |
|
39 | + if ($crop && ($maxWidth == 0 || $maxHeight == 0)) { |
|
40 | 40 | throw new ImageConvertException('Both width and height must be provided for cropping'); |
41 | 41 | } |
42 | 42 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ); |
64 | 64 | |
65 | 65 | $targetImg = imagecreatetruecolor($finalWidth, $finalHeight); |
66 | - if (! imagecopyresized( |
|
66 | + if (!imagecopyresized( |
|
67 | 67 | $targetImg, $sourceImg, |
68 | 68 | 0, 0, 0, 0, |
69 | 69 | $finalWidth, $finalHeight, $originalWidth, $originalHeight |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $diffHeight = !empty($maxHeight) ? $originalHeight - $maxHeight : false; |
98 | 98 | |
99 | 99 | if (($diffHeight === false && $diffWidth !== false) |
100 | - || ($diffWidth > $diffHeight && ! $crop) |
|
100 | + || ($diffWidth > $diffHeight && !$crop) |
|
101 | 101 | || ($diffWidth < $diffHeight && $crop) |
102 | 102 | ) { |
103 | 103 | $finalWidth = $maxWidth; |
@@ -26,14 +26,14 @@ |
||
26 | 26 | */ |
27 | 27 | public static function loadJson($jsonFile) |
28 | 28 | { |
29 | - if (! file_exists($jsonFile) || ! is_readable($jsonFile)) { |
|
29 | + if (!file_exists($jsonFile) || !is_readable($jsonFile)) { |
|
30 | 30 | throw new IOException('JSON resource file not found or not readable.'); |
31 | 31 | } |
32 | 32 | $data = json_decode(file_get_contents($jsonFile), true); |
33 | 33 | if ($data === null) { |
34 | 34 | $error = json_last_error(); |
35 | 35 | $msg = json_last_error_msg(); |
36 | - throw new BadRulesException('An error occured while parsing JSON file: error code #'. $error .': '. $msg); |
|
36 | + throw new BadRulesException('An error occured while parsing JSON file: error code #'.$error.': '.$msg); |
|
37 | 37 | } |
38 | 38 | return $data; |
39 | 39 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | */ |
51 | 51 | public static function isMetaSize($size) |
52 | 52 | { |
53 | - $metaSize = array ( |
|
53 | + $metaSize = array( |
|
54 | 54 | WebThumbnailer::SIZE_SMALL, |
55 | 55 | WebThumbnailer::SIZE_MEDIUM, |
56 | 56 | WebThumbnailer::SIZE_LARGE |