Completed
Push — master ( fabb7c...5b2234 )
by Yannick
06:40
created
require/class.Image.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 	* @return Array the images list
18 18
 	*
19 19
 	*/
20
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
20
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
21 21
 	{
22
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
22
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
23
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
24
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
25 25
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
26 26
 		$registration = trim($registration);
27
-		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
27
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28 28
 			FROM spotter_image 
29 29
 			WHERE spotter_image.registration = :registration";
30 30
 		$sth = $this->db->prepare($query);
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
64 64
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
65 65
 		if ($copyright != '') {
66
-			$copyright = str_replace('Copyright ','',$copyright);
67
-			$copyright = str_replace('© ','',$copyright);
68
-			$copyright = str_replace('(c) ','',$copyright);
66
+			$copyright = str_replace('Copyright ', '', $copyright);
67
+			$copyright = str_replace('© ', '', $copyright);
68
+			$copyright = str_replace('(c) ', '', $copyright);
69 69
 		}
70 70
 		return $copyright;
71 71
 	}
@@ -76,26 +76,26 @@  discard block
 block discarded – undo
76 76
 	* @return String either success or error
77 77
 	*
78 78
 	*/
79
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
79
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
80 80
 	{
81
-		global $globalDebug,$globalAircraftImageFetch;
81
+		global $globalDebug, $globalAircraftImageFetch;
82 82
 		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
83
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
83
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
84 84
 		$registration = trim($registration);
85 85
 		//getting the aircraft image
86 86
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
87 87
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
88 88
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
89 89
 		else return "success";
90
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
90
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
91 91
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
92 92
 		if ($image_url['original'] != '') {
93 93
 			if ($globalDebug) echo 'Found !'."\n";
94
-			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
94
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
95 95
 			try {
96 96
 				$sth = $this->db->prepare($query);
97
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
98
-			} catch(PDOException $e) {
97
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
98
+			} catch (PDOException $e) {
99 99
 				echo $e->getMessage()."\n";
100 100
 				return "error";
101 101
 			}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 		global $globalAircraftImageSources, $globalIVAO;
116 116
 		$Spotter = new Spotter($this->db);
117 117
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
118
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
118
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
119 119
 		if ($aircraft_registration != '') {
120
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
120
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
121 121
 			$aircraft_registration = urlencode(trim($aircraft_registration));
122 122
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
123 123
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -129,24 +129,24 @@  discard block
 block discarded – undo
129 129
 		} elseif ($aircraft_icao != '') {
130 130
 			$aircraft_registration = $aircraft_icao;
131 131
 			$aircraft_name = '';
132
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
133
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
132
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
133
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
134 134
 		foreach ($globalAircraftImageSources as $source) {
135 135
 			$source = strtolower($source);
136
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
137
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
138
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
139
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
140
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
141
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
142
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
143
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
144
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
145
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
136
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao, $airline_icao);
137
+			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration, $aircraft_name);
138
+			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration, $aircraft_name);
139
+			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration, $aircraft_name);
140
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration, $aircraft_name);
141
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration, $aircraft_name);
142
+			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration, $aircraft_name);
143
+			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration, $aircraft_name);
144
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration, $aircraft_name);
145
+			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration, $aircraft_name);
146 146
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
147 147
 		}
148 148
 		if (isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
149
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
149
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
150 150
 	}
151 151
 
152 152
 	/**
@@ -157,24 +157,24 @@  discard block
 block discarded – undo
157 157
 	* @return Array the aircraft thumbnail, orignal url and copyright
158 158
 	*
159 159
 	*/
160
-	public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
160
+	public function fromPlanespotters($aircraft_registration, $aircraft_name = '') {
161 161
 		$Common = new Common();
162 162
 		// If aircraft registration is only number, also check with aircraft model
163
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
164
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
163
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
164
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
165 165
 		} else {
166 166
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
167
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
167
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
168 168
 		}
169 169
 		$data = $Common->getData($url);
170 170
 		if ($xml = simplexml_load_string($data)) {
171 171
 			if (isset($xml->channel->item)) {
172 172
 				$image_url = array();
173
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
173
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
174 174
 				$image_url['thumbnail'] = $thumbnail_url;
175
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
176
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
177
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
175
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
176
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
177
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
178 178
 				$image_url['source'] = 'planespotters';
179 179
 				return $image_url;
180 180
 			}
@@ -190,25 +190,25 @@  discard block
 block discarded – undo
190 190
 	* @return Array the aircraft thumbnail, orignal url and copyright
191 191
 	*
192 192
 	*/
193
-	public function fromDeviantart($aircraft_registration, $aircraft_name='') {
193
+	public function fromDeviantart($aircraft_registration, $aircraft_name = '') {
194 194
 		$Common = new Common();
195 195
 		// If aircraft registration is only number, also check with aircraft model
196
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
197
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
196
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
197
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
198 198
 		} else {
199
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
199
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
200 200
 		}
201 201
 
202 202
 		$data = $Common->getData($url);
203 203
 		if ($xml = simplexml_load_string($data)) {
204 204
 			if (isset($xml->channel->item->link)) {
205 205
 				$image_url = array();
206
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
206
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
207 207
 				$image_url['thumbnail'] = $thumbnail_url;
208
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
208
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
209 209
 				$image_url['original'] = $original_url;
210
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
211
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
210
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
211
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
212 212
 				$image_url['source'] = 'deviantart';
213 213
 				return $image_url;
214 214
 			}
@@ -224,32 +224,32 @@  discard block
 block discarded – undo
224 224
 	* @return Array the aircraft thumbnail, orignal url and copyright
225 225
 	*
226 226
 	*/
227
-	public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
227
+	public function fromJetPhotos($aircraft_registration, $aircraft_name = '') {
228 228
 		$Common = new Common();
229
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
229
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
230 230
 		$data = $Common->getData($url);
231 231
 		$dom = new DOMDocument();
232 232
 		@$dom->loadHTML($data);
233 233
 		$all_pics = array();
234
-		foreach($dom->getElementsByTagName('img') as $image) {
234
+		foreach ($dom->getElementsByTagName('img') as $image) {
235 235
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
236 236
 				$all_pics[] = $image->getAttribute('src');
237 237
 			}
238 238
 		}
239 239
 		$all_authors = array();
240
-		foreach($dom->getElementsByTagName('meta') as $author) {
240
+		foreach ($dom->getElementsByTagName('meta') as $author) {
241 241
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
242 242
 				$all_authors[] = $author->getAttribute('content');
243 243
 			}
244 244
 		}
245 245
 		$all_ref = array();
246
-		foreach($dom->getElementsByTagName('a') as $link) {
246
+		foreach ($dom->getElementsByTagName('a') as $link) {
247 247
 			$all_ref[] = $link->getAttribute('href');
248 248
 		}
249 249
 		if (isset($all_pics[0])) {
250 250
 			$image_url = array();
251 251
 			$image_url['thumbnail'] = $all_pics[0];
252
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
252
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
253 253
 			$image_url['copyright'] = $all_authors[0];
254 254
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
255 255
 			$image_url['source'] = 'JetPhotos';
@@ -266,24 +266,24 @@  discard block
 block discarded – undo
266 266
 	* @return Array the aircraft thumbnail, orignal url and copyright
267 267
 	*
268 268
 	*/
269
-	public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
269
+	public function fromPlanePictures($aircraft_registration, $aircraft_name = '') {
270 270
 		$Common = new Common();
271
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
271
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
272 272
 		$data = $Common->getData($url);
273 273
 		$dom = new DOMDocument();
274 274
 		@$dom->loadHTML($data);
275 275
 		$all_pics = array();
276
-		foreach($dom->getElementsByTagName('img') as $image) {
276
+		foreach ($dom->getElementsByTagName('img') as $image) {
277 277
 			$all_pics[] = $image->getAttribute('src');
278 278
 		}
279 279
 		$all_links = array();
280
-		foreach($dom->getElementsByTagName('a') as $link) {
281
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
280
+		foreach ($dom->getElementsByTagName('a') as $link) {
281
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
282 282
 		}
283
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) {
283
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1])) {
284 284
 			$image_url = array();
285 285
 			$image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1];
286
-			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN','',$all_pics[1]);
286
+			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN', '', $all_pics[1]);
287 287
 			$image_url['copyright'] = $all_links[6]['text'];
288 288
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
289 289
 			$image_url['source'] = 'PlanePictures';
@@ -300,19 +300,19 @@  discard block
 block discarded – undo
300 300
 	* @return Array the aircraft thumbnail, orignal url and copyright
301 301
 	*
302 302
 	*/
303
-	public function fromFlickr($aircraft_registration,$aircraft_name='') {
303
+	public function fromFlickr($aircraft_registration, $aircraft_name = '') {
304 304
 		$Common = new Common();
305 305
 		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
306 306
 		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
307 307
 		$data = $Common->getData($url);
308 308
 		if ($xml = simplexml_load_string($data)) {
309 309
 			if (isset($xml->channel->item)) {
310
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
310
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
311 311
 				$image_url = array();
312 312
 				$image_url['thumbnail'] = $original_url;
313 313
 				$image_url['original'] = $original_url;
314
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
315
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
314
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
315
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
316 316
 				$image_url['source'] = 'flickr';
317 317
 				return $image_url;
318 318
 			}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 		return false;
321 321
 	}
322 322
 
323
-	public function fromIvaoMtl($aircraft_icao,$airline_icao) {
323
+	public function fromIvaoMtl($aircraft_icao, $airline_icao) {
324 324
 		$Common = new Common();
325 325
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
326 326
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
 	* @return Array the aircraft thumbnail, orignal url and copyright
345 345
 	*
346 346
 	*/
347
-	public function fromBing($aircraft_registration,$aircraft_name='') {
347
+	public function fromBing($aircraft_registration, $aircraft_name = '') {
348 348
 		global $globalImageBingKey;
349 349
 		$Common = new Common();
350 350
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
351 351
 		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
352 352
 		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
353
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
354
-		$data = $Common->getData($url,'get','',$headers);
353
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
354
+		$data = $Common->getData($url, 'get', '', $headers);
355 355
 		$result = json_decode($data);
356 356
 		if (isset($result->d->results[0]->MediaUrl)) {
357 357
 			$image_url = array();
@@ -376,14 +376,14 @@  discard block
 block discarded – undo
376 376
 	* @return Array the aircraft thumbnail, orignal url and copyright
377 377
 	*
378 378
 	*/
379
-	public function fromAirportData($aircraft_registration,$aircraft_name='') {
379
+	public function fromAirportData($aircraft_registration, $aircraft_name = '') {
380 380
 		$Common = new Common();
381 381
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
382 382
 		$data = $Common->getData($url);
383 383
 		$result = json_decode($data);
384 384
 		if (isset($result->count) && $result->count > 0) {
385 385
 			$image_url = array();
386
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
386
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
387 387
 			$image_url['source_website'] = $result->data[0]->link;
388 388
 			$image_url['thumbnail'] = $result->data[0]->image;
389 389
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	* @return Array the aircraft thumbnail, orignal url and copyright
402 402
 	*
403 403
 	*/
404
-	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
404
+	public function fromWikimedia($aircraft_registration, $aircraft_name = '') {
405 405
 		$Common = new Common();
406 406
 		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
407 407
 		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		$result = json_decode($data);
410 410
 		if (isset($result->query->search[0]->title)) {
411 411
 			$fileo = $result->query->search[0]->title;
412
-			if (substr($fileo,-3) == 'pdf') return false;
412
+			if (substr($fileo, -3) == 'pdf') return false;
413 413
 			$file = urlencode($fileo);
414 414
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
415 415
 			$data2 = $Common->getData($url2);
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 				if (isset($result2->query->pages)) {
435 435
 					foreach ($result2->query->pages as $page) {
436 436
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
437
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
437
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
438 438
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
439 439
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
440 440
 							}
441
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
441
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
442 442
 							return $image_url;
443 443
 						}
444 444
 					}
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	* @return Array the aircraft thumbnail, orignal url and copyright
458 458
 	*
459 459
 	*/
460
-	public function fromCustomSource($aircraft_registration,$aircraft_name='') {
460
+	public function fromCustomSource($aircraft_registration, $aircraft_name = '') {
461 461
 		global $globalAircraftImageCustomSources, $globalDebug;
462 462
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
463 463
 		if (!empty($globalAircraftImageCustomSources)) {
@@ -474,15 +474,15 @@  discard block
 block discarded – undo
474 474
 					print_r($source);
475 475
 					print_r($customsources);
476 476
 				}
477
-				$url = str_replace('{registration}',$aircraft_registration,$source['original']);
478
-				$url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['thumbnail']);
477
+				$url = str_replace('{registration}', $aircraft_registration, $source['original']);
478
+				$url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['thumbnail']);
479 479
 				if ($Common->urlexist($url)) {
480 480
 					$image_url = array();
481 481
 					$image_url['thumbnail'] = $url_thumbnail;
482 482
 					$image_url['original'] = $url;
483 483
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
484 484
 					else $exifCopyright = '';
485
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
485
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
486 486
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
487 487
 					else $image_url['copyright'] = $source['source_website'];
488 488
 					$image_url['source_website'] = $source['source_website'];
Please login to merge, or discard this patch.