@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | if (empty($thumburl)) { |
| 113 | - $error = 'No thumbnail could be found using '. $this->finder->getName() .' finder: '. $this->url; |
|
| 113 | + $error = 'No thumbnail could be found using '.$this->finder->getName().' finder: '.$this->url; |
|
| 114 | 114 | throw new ThumbnailNotFoundException($error); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | protected function thumbnailStrictHotlink($thumburl) |
| 141 | 141 | { |
| 142 | - if (! $this->finder->isHotlinkAllowed()) { |
|
| 142 | + if (!$this->finder->isHotlinkAllowed()) { |
|
| 143 | 143 | throw new ThumbnailNotFoundException('Hotlink is not supported for this URL.'); |
| 144 | 144 | } |
| 145 | 145 | return $thumburl; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | protected function thumbnailHotlink($thumburl) |
| 160 | 160 | { |
| 161 | - if (! $this->finder->isHotlinkAllowed()) { |
|
| 161 | + if (!$this->finder->isHotlinkAllowed()) { |
|
| 162 | 162 | return $this->thumbnailDownload($thumburl); |
| 163 | 163 | } |
| 164 | 164 | return $thumburl; |
@@ -209,13 +209,13 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | if (strpos($headers[0], '200') === false) { |
| 211 | 211 | throw new DownloadException( |
| 212 | - 'Unreachable thumbnail URL. HTTP '. $headers[0] .'.'. PHP_EOL . |
|
| 213 | - ' - thumbnail URL: '. $thumburl |
|
| 212 | + 'Unreachable thumbnail URL. HTTP '.$headers[0].'.'.PHP_EOL. |
|
| 213 | + ' - thumbnail URL: '.$thumburl |
|
| 214 | 214 | ); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | if (empty($data)) { |
| 218 | - throw new DownloadException('Couldn\'t download the thumbnail at '. $thumburl); |
|
| 218 | + throw new DownloadException('Couldn\'t download the thumbnail at '.$thumburl); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // Resize and save it locally. |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $this->options[WebThumbnailer::CROP] |
| 228 | 228 | ); |
| 229 | 229 | |
| 230 | - if (! is_file($thumbPath)) { |
|
| 230 | + if (!is_file($thumbPath)) { |
|
| 231 | 231 | throw new ImageConvertException('Thumbnail was not generated.'); |
| 232 | 232 | } |
| 233 | 233 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | { |
| 308 | 308 | // Width |
| 309 | 309 | $width = 0; |
| 310 | - if (! empty($options[WebThumbnailer::MAX_WIDTH])) { |
|
| 310 | + if (!empty($options[WebThumbnailer::MAX_WIDTH])) { |
|
| 311 | 311 | if (SizeUtils::isMetaSize($options[WebThumbnailer::MAX_WIDTH])) { |
| 312 | 312 | $width = SizeUtils::getMetaSize($options[WebThumbnailer::MAX_WIDTH]); |
| 313 | 313 | } elseif (is_int($options[WebThumbnailer::MAX_WIDTH]) |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | if (count(array_intersect($incompatibleFlags, $options)) > 1) { |
| 358 | 358 | $error = 'Only one of these flags can be set between: '; |
| 359 | 359 | foreach ($incompatibleFlags as $flag) { |
| 360 | - $error .= $flag .' '; |
|
| 360 | + $error .= $flag.' '; |
|
| 361 | 361 | } |
| 362 | 362 | throw new BadRulesException($error); |
| 363 | 363 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * @var string Path to resources folder. |
| 14 | 14 | */ |
| 15 | - const RESOURCES_PATH = __DIR__ . DIRECTORY_SEPARATOR .'..'. DIRECTORY_SEPARATOR .'resources'. DIRECTORY_SEPARATOR; |
|
| 15 | + const RESOURCES_PATH = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Build the path from all given folders, with a trailing /. |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | return false; |
| 30 | 30 | } |
| 31 | 31 | foreach ($args as $arg) { |
| 32 | - $out .= rtrim(rtrim($arg, '/'), '\\') . DIRECTORY_SEPARATOR; |
|
| 32 | + $out .= rtrim(rtrim($arg, '/'), '\\').DIRECTORY_SEPARATOR; |
|
| 33 | 33 | } |
| 34 | 34 | return is_dir($out) ? $out : false; |
| 35 | 35 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public static function rmdir($path) |
| 45 | 45 | { |
| 46 | - if (empty($path) || $path == '/' || ! self::getPath($path)) { |
|
| 46 | + if (empty($path) || $path == '/' || !self::getPath($path)) { |
|
| 47 | 47 | return false; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -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 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | public static function clear() |
| 68 | 68 | { |
| 69 | 69 | self::$configFiles = [ |
| 70 | - FileUtils::RESOURCES_PATH . 'settings.json', |
|
| 70 | + FileUtils::RESOURCES_PATH.'settings.json', |
|
| 71 | 71 | ]; |
| 72 | 72 | self::reload(); |
| 73 | 73 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | protected static function getConfig($settings, $config) |
| 111 | 111 | { |
| 112 | - if (! is_array($settings) || count($settings) == 0) { |
|
| 112 | + if (!is_array($settings) || count($settings) == 0) { |
|
| 113 | 113 | return self::$NOT_FOUND; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -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 | } elseif (!$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 | } |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | self::createDomainThumbCacheFolder($domainHash, $type); |
| 87 | 87 | $domainFolder = FileUtils::getPath(self::getCachePath($type), $domainHash); |
| 88 | 88 | if ($type === self::TYPE_THUMB) { |
| 89 | - $suffix = $width . $height . ($crop ? '1' : '0') .'.jpg'; |
|
| 89 | + $suffix = $width.$height.($crop ? '1' : '0').'.jpg'; |
|
| 90 | 90 | } else { |
| 91 | - $suffix = $width . $height; |
|
| 91 | + $suffix = $width.$height; |
|
| 92 | 92 | } |
| 93 | - return $domainFolder . self::getThumbFilename($url) . $suffix; |
|
| 93 | + return $domainFolder.self::getThumbFilename($url).$suffix; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | public static function isCacheValid($cacheFile, $domain, $type) |
| 109 | 109 | { |
| 110 | 110 | $out = false; |
| 111 | - $cacheDuration = ConfigManager::get('settings.cache_duration', 3600*24*31); |
|
| 111 | + $cacheDuration = ConfigManager::get('settings.cache_duration', 3600 * 24 * 31); |
|
| 112 | 112 | |
| 113 | 113 | if (is_readable($cacheFile) |
| 114 | 114 | && ($cacheDuration < 0 || (time() - filemtime($cacheFile)) < $cacheDuration) |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | protected static function createDomainThumbCacheFolder($domain, $type) |
| 131 | 131 | { |
| 132 | 132 | $cachePath = self::getCachePath($type); |
| 133 | - $domainFolder = $cachePath . $domain; |
|
| 133 | + $domainFolder = $cachePath.$domain; |
|
| 134 | 134 | if (!file_exists($domainFolder)) { |
| 135 | 135 | mkdir($domainFolder, 0775, false); |
| 136 | - touch($domainFolder . '/' . self::$CLEAN_FILE); |
|
| 136 | + touch($domainFolder.'/'.self::$CLEAN_FILE); |
|
| 137 | 137 | } |
| 138 | 138 | self::createHtaccessFile($cachePath, $type === self::TYPE_THUMB); |
| 139 | 139 | } |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | protected static function createHtaccessFile($path, $allowed = false) |
| 149 | 149 | { |
| 150 | 150 | $apacheVersion = ConfigManager::get('settings.apache_version', ''); |
| 151 | - $htaccessFile = $path . '.htaccess'; |
|
| 151 | + $htaccessFile = $path.'.htaccess'; |
|
| 152 | 152 | if (file_exists($htaccessFile)) { |
| 153 | 153 | return; |
| 154 | 154 | } |
| 155 | - $templateFile = file_exists(FileUtils::RESOURCES_PATH .'htaccess'. $apacheVersion .'_template') |
|
| 156 | - ? FileUtils::RESOURCES_PATH .'htaccess'. $apacheVersion .'_template' |
|
| 157 | - : FileUtils::RESOURCES_PATH .'htaccess_template'; |
|
| 155 | + $templateFile = file_exists(FileUtils::RESOURCES_PATH.'htaccess'.$apacheVersion.'_template') |
|
| 156 | + ? FileUtils::RESOURCES_PATH.'htaccess'.$apacheVersion.'_template' |
|
| 157 | + : FileUtils::RESOURCES_PATH.'htaccess_template'; |
|
| 158 | 158 | $template = new \Text_Template($templateFile); |
| 159 | 159 | $template->setVar([ |
| 160 | 160 | 'new_all' => $allowed ? 'granted' : 'denied', |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | protected static function checkCacheType($type) |
| 188 | 188 | { |
| 189 | 189 | if ($type != self::TYPE_THUMB && $type != self::TYPE_FINDER) { |
| 190 | - throw new CacheException('Unknown cache type '. $type); |
|
| 190 | + throw new CacheException('Unknown cache type '.$type); |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
@@ -197,19 +197,19 @@ discard block |
||
| 197 | 197 | protected static function rebuildCacheFolders() |
| 198 | 198 | { |
| 199 | 199 | $mainFolder = ConfigManager::get('settings.path.cache', 'cache/'); |
| 200 | - if (! is_dir($mainFolder)) { |
|
| 200 | + if (!is_dir($mainFolder)) { |
|
| 201 | 201 | mkdir($mainFolder, 0755); |
| 202 | 202 | } |
| 203 | - if (! is_dir($mainFolder.self::TYPE_THUMB)) { |
|
| 203 | + if (!is_dir($mainFolder.self::TYPE_THUMB)) { |
|
| 204 | 204 | mkdir($mainFolder.self::TYPE_THUMB, 0755); |
| 205 | 205 | } |
| 206 | - if (! is_readable($mainFolder . self::TYPE_THUMB . DIRECTORY_SEPARATOR . '.gitkeep')) { |
|
| 207 | - touch($mainFolder . self::TYPE_THUMB . DIRECTORY_SEPARATOR . '.gitkeep'); |
|
| 206 | + if (!is_readable($mainFolder.self::TYPE_THUMB.DIRECTORY_SEPARATOR.'.gitkeep')) { |
|
| 207 | + touch($mainFolder.self::TYPE_THUMB.DIRECTORY_SEPARATOR.'.gitkeep'); |
|
| 208 | 208 | } |
| 209 | - if (! is_dir($mainFolder.self::TYPE_FINDER)) { |
|
| 210 | - mkdir($mainFolder . self::TYPE_FINDER, 0755); |
|
| 209 | + if (!is_dir($mainFolder.self::TYPE_FINDER)) { |
|
| 210 | + mkdir($mainFolder.self::TYPE_FINDER, 0755); |
|
| 211 | 211 | } |
| 212 | - if (! is_readable($mainFolder . self::TYPE_THUMB . DIRECTORY_SEPARATOR . '.gitkeep')) { |
|
| 212 | + if (!is_readable($mainFolder.self::TYPE_THUMB.DIRECTORY_SEPARATOR.'.gitkeep')) { |
|
| 213 | 213 | touch($mainFolder.self::TYPE_FINDER.DIRECTORY_SEPARATOR.'.gitkeep'); |
| 214 | 214 | } |
| 215 | 215 | } |