@@ -64,26 +64,31 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function checkRequest() |
66 | 66 | { |
67 | - if (!$this->enabled) |
|
68 | - return false; |
|
67 | + if (!$this->enabled) { |
|
68 | + return false; |
|
69 | + } |
|
69 | 70 | |
70 | 71 | // Try to create the image cache directory if it doesn't exist |
71 | - if (!file_exists($this->cache)) |
|
72 | - if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
72 | + if (!file_exists($this->cache)) { |
|
73 | + if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
73 | 74 | return false; |
75 | + } |
|
74 | 76 | |
75 | - if (empty($_GET['hash']) || empty($_GET['request']) || ($_GET['request'] === "http:") || ($_GET['request'] === "https:")) |
|
76 | - return false; |
|
77 | + if (empty($_GET['hash']) || empty($_GET['request']) || ($_GET['request'] === "http:") || ($_GET['request'] === "https:")) { |
|
78 | + return false; |
|
79 | + } |
|
77 | 80 | |
78 | 81 | $hash = $_GET['hash']; |
79 | 82 | $request = $_GET['request']; |
80 | 83 | |
81 | - if (md5($request . $this->secret) != $hash) |
|
82 | - return false; |
|
84 | + if (md5($request . $this->secret) != $hash) { |
|
85 | + return false; |
|
86 | + } |
|
83 | 87 | |
84 | 88 | // Attempt to cache the request if it doesn't exist |
85 | - if (!$this->isCached($request)) |
|
86 | - return $this->cacheImage($request); |
|
89 | + if (!$this->isCached($request)) { |
|
90 | + return $this->cacheImage($request); |
|
91 | + } |
|
87 | 92 | |
88 | 93 | return true; |
89 | 94 | } |
@@ -118,8 +123,9 @@ discard block |
||
118 | 123 | if (!$cached || $time - $cached['time'] > (5 * 86400)) |
119 | 124 | { |
120 | 125 | @unlink($cached_file); |
121 | - if ($this->checkRequest()) |
|
122 | - $this->serve(); |
|
126 | + if ($this->checkRequest()) { |
|
127 | + $this->serve(); |
|
128 | + } |
|
123 | 129 | $this::redirectexit($request); |
124 | 130 | } |
125 | 131 | |
@@ -132,8 +138,9 @@ discard block |
||
132 | 138 | |
133 | 139 | // Make sure we're serving an image |
134 | 140 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
135 | - if ($contentParts[0] != 'image') |
|
136 | - exit; |
|
141 | + if ($contentParts[0] != 'image') { |
|
142 | + exit; |
|
143 | + } |
|
137 | 144 | |
138 | 145 | $max_age = $time - $cached['time'] + (5 * 86400); |
139 | 146 | header('content-type: ' . $cached['content_type']); |
@@ -191,12 +198,14 @@ discard block |
||
191 | 198 | |
192 | 199 | // Make sure the url is returning an image |
193 | 200 | $contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : ''); |
194 | - if ($contentParts[0] != 'image') |
|
195 | - return -1; |
|
201 | + if ($contentParts[0] != 'image') { |
|
202 | + return -1; |
|
203 | + } |
|
196 | 204 | |
197 | 205 | // Validate the filesize |
198 | - if ($response['size'] > ($this->maxSize * 1024)) |
|
199 | - return 0; |
|
206 | + if ($response['size'] > ($this->maxSize * 1024)) { |
|
207 | + return 0; |
|
208 | + } |
|
200 | 209 | |
201 | 210 | $time = $this->getTime(); |
202 | 211 |
@@ -140,7 +140,7 @@ |
||
140 | 140 | $max_age = $time - $cached['time'] + (5 * 86400); |
141 | 141 | header('content-type: ' . $cached['content_type']); |
142 | 142 | header('content-length: ' . $cached['size']); |
143 | - header('cache-control: public, max-age=' . $max_age ); |
|
143 | + header('cache-control: public, max-age=' . $max_age); |
|
144 | 144 | header('last-modified: ' . gmdate('D, d M Y H:i:s', $cached['time']) . ' GMT'); |
145 | 145 | header('etag: ' . $eTag); |
146 | 146 | echo base64_decode($cached['body']); |