Completed
Push — release-2.1 ( b11117...7cbb85 )
by Colin
23:04 queued 14:33
created
proxy.php 1 patch
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -70,26 +70,31 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function checkRequest()
72 72
 	{
73
-		if (!$this->enabled)
74
-			return false;
73
+		if (!$this->enabled) {
74
+					return false;
75
+		}
75 76
 
76 77
 		// Try to create the image cache directory if it doesn't exist
77
-		if (!file_exists($this->cache))
78
-			if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
78
+		if (!file_exists($this->cache)) {
79
+					if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
79 80
 				return false;
81
+		}
80 82
 
81
-		if (empty($_GET['hash']) || empty($_GET['request']) || ($_GET['request'] === "http:") || ($_GET['request'] === "https:"))
82
-			return false;
83
+		if (empty($_GET['hash']) || empty($_GET['request']) || ($_GET['request'] === "http:") || ($_GET['request'] === "https:")) {
84
+					return false;
85
+		}
83 86
 
84 87
 		$hash = $_GET['hash'];
85 88
 		$request = $_GET['request'];
86 89
 
87
-		if (md5($request . $this->secret) != $hash)
88
-			return false;
90
+		if (md5($request . $this->secret) != $hash) {
91
+					return false;
92
+		}
89 93
 
90 94
 		// Attempt to cache the request if it doesn't exist
91
-		if (!$this->isCached($request))
92
-			return $this->cacheImage($request);
95
+		if (!$this->isCached($request)) {
96
+					return $this->cacheImage($request);
97
+		}
93 98
 
94 99
 		return true;
95 100
 	}
@@ -126,8 +131,9 @@  discard block
 block discarded – undo
126 131
 		if (!$cached || time() - $cached['time'] > ($this->maxDays * 86400))
127 132
 		{
128 133
 			@unlink($cached_file);
129
-			if ($this->checkRequest())
130
-				$this->serve();
134
+			if ($this->checkRequest()) {
135
+							$this->serve();
136
+			}
131 137
 			$this::redirectexit($request);
132 138
 		}
133 139
 
@@ -140,8 +146,9 @@  discard block
 block discarded – undo
140 146
 
141 147
 		// Make sure we're serving an image
142 148
 		$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
143
-		if ($contentParts[0] != 'image')
144
-			exit;
149
+		if ($contentParts[0] != 'image') {
150
+					exit;
151
+		}
145 152
 
146 153
 		$max_age = $time - $cached['time'] + (5 * 86400);
147 154
 		header('content-type: ' . $cached['content_type']);
@@ -200,12 +207,14 @@  discard block
 block discarded – undo
200 207
 
201 208
 		// Make sure the url is returning an image
202 209
 		$contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : '');
203
-		if ($contentParts[0] != 'image')
204
-			return -1;
210
+		if ($contentParts[0] != 'image') {
211
+					return -1;
212
+		}
205 213
 
206 214
 		// Validate the filesize
207
-		if ($response['size'] > ($this->maxSize * 1024))
208
-			return 0;
215
+		if ($response['size'] > ($this->maxSize * 1024)) {
216
+					return 0;
217
+		}
209 218
 
210 219
 		$time = $this->getTime();
211 220
 
Please login to merge, or discard this patch.