Completed
Pull Request — master (#455)
by
unknown
10:12
created
require/class.Image.php 2 patches
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 		if ($this->db === null) die('Error: No DB connection. (Image)');
23 23
 	}
24 24
 
25
-    /**
26
-     * Gets the images based on the aircraft registration
27
-     *
28
-     * @param $registration
29
-     * @param string $aircraft_icao
30
-     * @param string $airline_icao
31
-     * @return array the images list
32
-     */
25
+	/**
26
+	 * Gets the images based on the aircraft registration
27
+	 *
28
+	 * @param $registration
29
+	 * @param string $aircraft_icao
30
+	 * @param string $airline_icao
31
+	 * @return array the images list
32
+	 */
33 33
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
34 34
 	{
35 35
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
 		else return array();
50 50
 	}
51 51
 
52
-    /**
53
-     * Gets the images based on the ship name
54
-     *
55
-     * @param $mmsi
56
-     * @param string $imo
57
-     * @param string $name
58
-     * @param string $type_name
59
-     * @return array the images list
60
-     */
52
+	/**
53
+	 * Gets the images based on the ship name
54
+	 *
55
+	 * @param $mmsi
56
+	 * @param string $imo
57
+	 * @param string $name
58
+	 * @param string $type_name
59
+	 * @return array the images list
60
+	 */
61 61
 	public function getMarineImage($mmsi,$imo = '',$name = '',$type_name = '')
62 62
 	{
63 63
 		global $globalMarineImagePics;
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 		return $result;
95 95
 	}
96 96
 
97
-    /**
98
-     * Gets the image copyright based on the Exif data
99
-     *
100
-     * @param $url
101
-     * @return String image copyright
102
-     */
97
+	/**
98
+	 * Gets the image copyright based on the Exif data
99
+	 *
100
+	 * @param $url
101
+	 * @return String image copyright
102
+	 */
103 103
 	public function getExifCopyright($url) {
104 104
 		$exif = exif_read_data($url);
105 105
 		$copyright = '';
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
 		return $copyright;
114 114
 	}
115 115
 
116
-    /**
117
-     * Adds the images based on the aircraft registration
118
-     *
119
-     * @param $registration
120
-     * @param string $aircraft_icao
121
-     * @param string $airline_icao
122
-     * @return String either success or error
123
-     */
116
+	/**
117
+	 * Adds the images based on the aircraft registration
118
+	 *
119
+	 * @param $registration
120
+	 * @param string $aircraft_icao
121
+	 * @param string $airline_icao
122
+	 * @return String either success or error
123
+	 */
124 124
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
125 125
 	{
126 126
 		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 		return "success";
148 148
 	}
149 149
 
150
-    /**
151
-     * Adds the images based on the marine name
152
-     *
153
-     * @param $mmsi
154
-     * @param string $imo
155
-     * @param string $name
156
-     * @return String either success or error
157
-     */
150
+	/**
151
+	 * Adds the images based on the marine name
152
+	 *
153
+	 * @param $mmsi
154
+	 * @param string $imo
155
+	 * @param string $name
156
+	 * @return String either success or error
157
+	 */
158 158
 	public function addMarineImage($mmsi,$imo = '',$name = '')
159 159
 	{
160 160
 		global $globalDebug,$globalMarineImageFetch, $globalOffline;
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 		return "success";
191 191
 	}
192 192
 
193
-    /**
194
-     * Gets the aircraft image
195
-     *
196
-     * @param String $aircraft_registration the registration of the aircraft
197
-     * @param string $aircraft_icao
198
-     * @param string $airline_icao
199
-     * @return array the aircraft thumbnail, orignal url and copyright
200
-     */
193
+	/**
194
+	 * Gets the aircraft image
195
+	 *
196
+	 * @param String $aircraft_registration the registration of the aircraft
197
+	 * @param string $aircraft_icao
198
+	 * @param string $airline_icao
199
+	 * @return array the aircraft thumbnail, orignal url and copyright
200
+	 */
201 201
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
202 202
 	{
203 203
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
 	}
242 242
 
243 243
 	/**
244
-	* Gets the vessel image
245
-	*
246
-	* @param String $mmsi the vessel mmsi
247
-	* @param String $imo the vessel imo
248
-	* @param String $name the vessel name
249
-	* @return array the aircraft thumbnail, orignal url and copyright
250
-	*
251
-	*/
244
+	 * Gets the vessel image
245
+	 *
246
+	 * @param String $mmsi the vessel mmsi
247
+	 * @param String $imo the vessel imo
248
+	 * @param String $name the vessel name
249
+	 * @return array the aircraft thumbnail, orignal url and copyright
250
+	 *
251
+	 */
252 252
 	public function findMarineImage($mmsi,$imo = '',$name = '')
253 253
 	{
254 254
 		global $globalMarineImageSources;
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
 	}
283 283
 
284 284
 	/**
285
-	* Gets the aircraft image from Planespotters
286
-	*
287
-	* @param String $aircraft_registration the registration of the aircraft
288
-	* @param String $aircraft_name type of the aircraft
289
-	* @return array the aircraft thumbnail, orignal url and copyright
290
-	*
291
-	*/
285
+	 * Gets the aircraft image from Planespotters
286
+	 *
287
+	 * @param String $aircraft_registration the registration of the aircraft
288
+	 * @param String $aircraft_name type of the aircraft
289
+	 * @return array the aircraft thumbnail, orignal url and copyright
290
+	 *
291
+	 */
292 292
 	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
293 293
 		$Common = new Common();
294 294
 		// If aircraft registration is only number, also check with aircraft model
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
316 316
 	}
317 317
 
318
-    /**
319
-     * Gets the aircraft image from Deviantart
320
-     *
321
-     * @param $type
322
-     * @param String $registration the registration of the aircraft
323
-     * @param String $name type of the aircraft
324
-     * @return array the aircraft thumbnail, orignal url and copyright
325
-     */
318
+	/**
319
+	 * Gets the aircraft image from Deviantart
320
+	 *
321
+	 * @param $type
322
+	 * @param String $registration the registration of the aircraft
323
+	 * @param String $name type of the aircraft
324
+	 * @return array the aircraft thumbnail, orignal url and copyright
325
+	 */
326 326
 	public function fromDeviantart($type,$registration, $name='') {
327 327
 		$Common = new Common();
328 328
 		if ($type == 'aircraft') {
@@ -356,13 +356,13 @@  discard block
 block discarded – undo
356 356
 	}
357 357
 
358 358
 	/**
359
-	* Gets the aircraft image from JetPhotos
360
-	*
361
-	* @param String $aircraft_registration the registration of the aircraft
362
-	* @param String $aircraft_name type of the aircraft
363
-	* @return array the aircraft thumbnail, orignal url and copyright
364
-	*
365
-	*/
359
+	 * Gets the aircraft image from JetPhotos
360
+	 *
361
+	 * @param String $aircraft_registration the registration of the aircraft
362
+	 * @param String $aircraft_name type of the aircraft
363
+	 * @return array the aircraft thumbnail, orignal url and copyright
364
+	 *
365
+	 */
366 366
 	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
367 367
 		$Common = new Common();
368 368
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
 	}
399 399
 
400 400
 	/**
401
-	* Gets the aircraft image from PlanePictures
402
-	*
403
-	* @param String $aircraft_registration the registration of the aircraft
404
-	* @param String $aircraft_name type of the aircraft
405
-	* @return array the aircraft thumbnail, orignal url and copyright
406
-	*
407
-	*/
401
+	 * Gets the aircraft image from PlanePictures
402
+	 *
403
+	 * @param String $aircraft_registration the registration of the aircraft
404
+	 * @param String $aircraft_name type of the aircraft
405
+	 * @return array the aircraft thumbnail, orignal url and copyright
406
+	 *
407
+	 */
408 408
 	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
409 409
 		$Common = new Common();
410 410
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
 	}
433 433
 
434 434
 	/**
435
-	* Gets the aircraft image from Flickr
436
-	*
437
-	* @param String $registration the registration of the aircraft
438
-	* @param String $name type of the aircraft
439
-	* @return array the aircraft thumbnail, orignal url and copyright
440
-	*
441
-	*/
435
+	 * Gets the aircraft image from Flickr
436
+	 *
437
+	 * @param String $registration the registration of the aircraft
438
+	 * @param String $name type of the aircraft
439
+	 * @return array the aircraft thumbnail, orignal url and copyright
440
+	 *
441
+	 */
442 442
 	public function fromFlickr($type,$registration,$name='') {
443 443
 		$Common = new Common();
444 444
 		if ($type == 'aircraft') {
@@ -465,13 +465,13 @@  discard block
 block discarded – undo
465 465
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
466 466
 	}
467 467
 
468
-    /**
469
-     * @param $type
470
-     * @param $aircraft_icao
471
-     * @param $airline_icao
472
-     * @return array
473
-     */
474
-    public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) {
468
+	/**
469
+	 * @param $type
470
+	 * @param $aircraft_icao
471
+	 * @param $airline_icao
472
+	 * @return array
473
+	 */
474
+	public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) {
475 475
 		$Common = new Common();
476 476
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
477 477
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -487,14 +487,14 @@  discard block
 block discarded – undo
487 487
 		}
488 488
 	}
489 489
 
490
-    /**
491
-     * Gets the aircraft image from Bing
492
-     *
493
-     * @param $type
494
-     * @param String $aircraft_registration the registration of the aircraft
495
-     * @param String $aircraft_name type of the aircraft
496
-     * @return array the aircraft thumbnail, orignal url and copyright
497
-     */
490
+	/**
491
+	 * Gets the aircraft image from Bing
492
+	 *
493
+	 * @param $type
494
+	 * @param String $aircraft_registration the registration of the aircraft
495
+	 * @param String $aircraft_name type of the aircraft
496
+	 * @return array the aircraft thumbnail, orignal url and copyright
497
+	 */
498 498
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
499 499
 		global $globalImageBingKey;
500 500
 		$Common = new Common();
@@ -525,14 +525,14 @@  discard block
 block discarded – undo
525 525
 	}
526 526
 
527 527
 	/**
528
-	* Gets the aircraft image from airport-data
529
-	*
530
-	* @param String $aircraft_registration the registration of the aircraft
531
-	* @param String $aircraft_icao the icao code of the aircraft
532
-	* @param String $aircraft_name type of the aircraft
533
-	* @return array the aircraft thumbnail, orignal url and copyright
534
-	*
535
-	*/
528
+	 * Gets the aircraft image from airport-data
529
+	 *
530
+	 * @param String $aircraft_registration the registration of the aircraft
531
+	 * @param String $aircraft_icao the icao code of the aircraft
532
+	 * @param String $aircraft_name type of the aircraft
533
+	 * @return array the aircraft thumbnail, orignal url and copyright
534
+	 *
535
+	 */
536 536
 	public function fromAirportData($type,$aircraft_registration,$aircraft_icao,$aircraft_name='') {
537 537
 		$Common = new Common();
538 538
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration.'&m='.$aircraft_icao;
@@ -551,13 +551,13 @@  discard block
 block discarded – undo
551 551
 	}
552 552
 
553 553
 	/**
554
-	* Gets image from WikiMedia
555
-	*
556
-	* @param String $registration the registration of the aircraft/mmsi
557
-	* @param String $name name
558
-	* @return array the aircraft thumbnail, orignal url and copyright
559
-	*
560
-	*/
554
+	 * Gets image from WikiMedia
555
+	 *
556
+	 * @param String $registration the registration of the aircraft/mmsi
557
+	 * @param String $name name
558
+	 * @return array the aircraft thumbnail, orignal url and copyright
559
+	 *
560
+	 */
561 561
 	public function fromWikimedia($type,$registration,$name='') {
562 562
 		$Common = new Common();
563 563
 		if ($type == 'aircraft') {
@@ -612,13 +612,13 @@  discard block
 block discarded – undo
612 612
 	}
613 613
 
614 614
 	/**
615
-	* Gets the aircraft image from custom url
616
-	*
617
-	* @param String $registration the registration of the aircraft
618
-	* @param String $name type of the aircraft
619
-	* @return array the aircraft thumbnail, orignal url and copyright
620
-	*
621
-	*/
615
+	 * Gets the aircraft image from custom url
616
+	 *
617
+	 * @param String $registration the registration of the aircraft
618
+	 * @param String $name type of the aircraft
619
+	 * @return array the aircraft thumbnail, orignal url and copyright
620
+	 *
621
+	 */
622 622
 	public function fromCustomSource($type,$registration,$name='') {
623 623
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
624 624
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
Braces   +223 added lines, -82 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 	public function __construct($dbc = null) {
20 20
 		$Connection = new Connection($dbc);
21 21
 		$this->db = $Connection->db();
22
-		if ($this->db === null) die('Error: No DB connection. (Image)');
22
+		if ($this->db === null) {
23
+			die('Error: No DB connection. (Image)');
24
+		}
23 25
 	}
24 26
 
25 27
     /**
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
37 39
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
38 40
 		$reg = $registration;
39
-		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
41
+		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') {
42
+			$reg = $aircraft_icao.$airline_icao;
43
+		}
40 44
 		$reg = trim($reg);
41 45
 		$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 
42 46
 			FROM spotter_image 
@@ -44,9 +48,13 @@  discard block
 block discarded – undo
44 48
 		$sth = $this->db->prepare($query);
45 49
 		$sth->execute(array(':registration' => $reg));
46 50
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
47
-		if (!empty($result)) return $result;
48
-		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
49
-		else return array();
51
+		if (!empty($result)) {
52
+			return $result;
53
+		} elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) {
54
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
55
+		} else {
56
+			return array();
57
+		}
50 58
 	}
51 59
 
52 60
     /**
@@ -74,7 +82,9 @@  discard block
 block discarded – undo
74 82
 			}
75 83
 		}
76 84
 		$name = trim($name);
77
-		if ($mmsi == '' && $imo == '' && $name == '') return array();
85
+		if ($mmsi == '' && $imo == '' && $name == '') {
86
+			return array();
87
+		}
78 88
 		$query  = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
79 89
 			FROM marine_image 
80 90
 			WHERE marine_image.mmsi = :mmsi";
@@ -103,8 +113,11 @@  discard block
 block discarded – undo
103 113
 	public function getExifCopyright($url) {
104 114
 		$exif = exif_read_data($url);
105 115
 		$copyright = '';
106
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
107
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
116
+		if (isset($exif['COMPUTED']['copyright'])) {
117
+			$copyright = $exif['COMPUTED']['copyright'];
118
+		} elseif (isset($exif['copyright'])) {
119
+			$copyright = $exif['copyright'];
120
+		}
108 121
 		if ($copyright != '') {
109 122
 			$copyright = str_replace('Copyright ','',$copyright);
110 123
 			$copyright = str_replace('© ','',$copyright);
@@ -124,17 +137,27 @@  discard block
 block discarded – undo
124 137
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
125 138
 	{
126 139
 		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
127
-		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
140
+		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) {
141
+			return '';
142
+		}
128 143
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
129 144
 		$registration = trim($registration);
130 145
 		//getting the aircraft image
131
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
132
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
133
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
146
+		if ($globalDebug && $registration != '') {
147
+			echo 'Try to find an aircraft image for '.$registration.'...';
148
+		} elseif ($globalDebug && $aircraft_icao != '') {
149
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
150
+		} elseif ($globalDebug && $airline_icao != '') {
151
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
152
+		}
134 153
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
135
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
154
+		if ($registration == '' && $aircraft_icao != '') {
155
+			$registration = $aircraft_icao.$airline_icao;
156
+		}
136 157
 		if ($image_url['original'] != '') {
137
-			if ($globalDebug) echo 'Found !'."\n";
158
+			if ($globalDebug) {
159
+				echo 'Found !'."\n";
160
+			}
138 161
 			$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)";
139 162
 			try {
140 163
 				$sth = $this->db->prepare($query);
@@ -143,7 +166,9 @@  discard block
 block discarded – undo
143 166
 				echo $e->getMessage()."\n";
144 167
 				return "error";
145 168
 			}
146
-		} elseif ($globalDebug) echo "Not found :'(\n";
169
+		} elseif ($globalDebug) {
170
+			echo "Not found :'(\n";
171
+		}
147 172
 		return "success";
148 173
 	}
149 174
 
@@ -158,7 +183,9 @@  discard block
 block discarded – undo
158 183
 	public function addMarineImage($mmsi,$imo = '',$name = '')
159 184
 	{
160 185
 		global $globalDebug,$globalMarineImageFetch, $globalOffline;
161
-		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
186
+		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) {
187
+			return '';
188
+		}
162 189
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
163 190
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
164 191
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -168,16 +195,22 @@  discard block
 block discarded – undo
168 195
 			$identity = $Marine->getIdentity($mmsi);
169 196
 			if (isset($identity[0]['mmsi'])) {
170 197
 				$imo = $identity[0]['imo'];
171
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
198
+				if ($identity[0]['ship_name'] != '') {
199
+					$name = $identity[0]['ship_name'];
200
+				}
172 201
 			}
173 202
 		}
174 203
 		unset($Marine);
175 204
 
176 205
 		//getting the aircraft image
177
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
206
+		if ($globalDebug && $name != '') {
207
+			echo 'Try to find an vessel image for '.$name.'...';
208
+		}
178 209
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
179 210
 		if ($image_url['original'] != '') {
180
-			if ($globalDebug) echo 'Found !'."\n";
211
+			if ($globalDebug) {
212
+				echo 'Found !'."\n";
213
+			}
181 214
 			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
182 215
 			try {
183 216
 				$sth = $this->db->prepare($query);
@@ -186,7 +219,9 @@  discard block
 block discarded – undo
186 219
 				echo $e->getMessage()."\n";
187 220
 				return "error";
188 221
 			}
189
-		} elseif ($globalDebug) echo "Not found :'(\n";
222
+		} elseif ($globalDebug) {
223
+			echo "Not found :'(\n";
224
+		}
190 225
 		return "success";
191 226
 	}
192 227
 
@@ -202,41 +237,85 @@  discard block
 block discarded – undo
202 237
 	{
203 238
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
204 239
 		$Spotter = new Spotter($this->db);
205
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
240
+		if (!isset($globalIVAO)) {
241
+			$globalIVAO = FALSE;
242
+		}
206 243
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
207 244
 		if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) {
208
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
245
+			if (strpos($aircraft_registration,'/') !== false) {
246
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
247
+			}
209 248
 			$aircraft_registration = urlencode(trim($aircraft_registration));
210 249
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
211
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
212
-			else $aircraft_name = '';
213
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
214
-			else $aircraft_icao = '';
215
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
216
-			else $airline_icao = '';
250
+			if (isset($aircraft_info[0]['aircraft_name'])) {
251
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
252
+			} else {
253
+				$aircraft_name = '';
254
+			}
255
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
256
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
257
+			} else {
258
+				$aircraft_icao = '';
259
+			}
260
+			if (isset($aircraft_info[0]['airline_icao'])) {
261
+				$airline_icao = $aircraft_info[0]['airline_icao'];
262
+			} else {
263
+				$airline_icao = '';
264
+			}
217 265
 		} elseif ($aircraft_icao != '') {
218 266
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
219
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
220
-			else $aircraft_name = '';
267
+			if (isset($aircraft_info[0]['type'])) {
268
+				$aircraft_name = $aircraft_info[0]['type'];
269
+			} else {
270
+				$aircraft_name = '';
271
+			}
221 272
 			$aircraft_registration = $aircraft_icao;
222
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
273
+		} else {
274
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
275
+		}
223 276
 		unset($Spotter);
224
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
277
+		if (!isset($globalAircraftImageSources)) {
278
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
279
+		}
225 280
 		foreach ($globalAircraftImageSources as $source) {
226 281
 			$source = strtolower($source);
227
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
228
-			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
229
-			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
230
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
231
-			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
232
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
233
-			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
234
-			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
235
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_icao,$aircraft_name);
236
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
237
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
238
-		}
239
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
282
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
283
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
284
+			}
285
+			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) {
286
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
287
+			}
288
+			if ($source == 'flickr' && extension_loaded('simplexml')) {
289
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
290
+			}
291
+			if ($source == 'bing') {
292
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
293
+			}
294
+			if ($source == 'deviantart' && extension_loaded('simplexml')) {
295
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
296
+			}
297
+			if ($source == 'wikimedia') {
298
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
299
+			}
300
+			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) {
301
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
302
+			}
303
+			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) {
304
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
305
+			}
306
+			if ($source == 'airportdata' && !$globalIVAO) {
307
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_icao,$aircraft_name);
308
+			}
309
+			if ($source == 'customsources') {
310
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
311
+			}
312
+			if (isset($images_array) && $images_array['original'] != '') {
313
+				return $images_array;
314
+			}
315
+		}
316
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
317
+			return $this->findAircraftImage($aircraft_icao);
318
+		}
240 319
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
241 320
 	}
242 321
 
@@ -256,7 +335,9 @@  discard block
 block discarded – undo
256 335
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
257 336
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
258 337
 		$name = trim($name);
259
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
338
+		if (strlen($name) < 4) {
339
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
340
+		}
260 341
 		/*
261 342
 		$Marine = new Marine($this->db);
262 343
 		if ($imo == '' || $name == '') {
@@ -268,15 +349,29 @@  discard block
 block discarded – undo
268 349
 		}
269 350
 		unset($Marine);
270 351
 		*/
271
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
352
+		if (!isset($globalMarineImageSources)) {
353
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
354
+		}
272 355
 		foreach ($globalMarineImageSources as $source) {
273 356
 			$source = strtolower($source);
274
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
275
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
276
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
277
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
278
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
279
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
357
+			if ($source == 'flickr') {
358
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
359
+			}
360
+			if ($source == 'bing') {
361
+				$images_array = $this->fromBing('marine',$mmsi,$name);
362
+			}
363
+			if ($source == 'deviantart') {
364
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
365
+			}
366
+			if ($source == 'wikimedia') {
367
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
368
+			}
369
+			if ($source == 'customsources') {
370
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
371
+			}
372
+			if (isset($images_array) && $images_array['original'] != '') {
373
+				return $images_array;
374
+			}
280 375
 		}
281 376
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
282 377
 	}
@@ -299,7 +394,9 @@  discard block
 block discarded – undo
299 394
 			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
300 395
 		}
301 396
 		$data = $Common->getData($url);
302
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
397
+		if (substr($data, 0, 5) != "<?xml") {
398
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
399
+		}
303 400
 		if ($xml = simplexml_load_string($data)) {
304 401
 			if (isset($xml->channel->item)) {
305 402
 				$image_url = array();
@@ -338,7 +435,9 @@  discard block
 block discarded – undo
338 435
 			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
339 436
 		}
340 437
 		$data = $Common->getData($url);
341
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
438
+		if (substr($data, 0, 5) != "<?xml") {
439
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
440
+		}
342 441
 		if ($xml = simplexml_load_string($data)) {
343 442
 			if (isset($xml->channel->item->link)) {
344 443
 				$image_url = array();
@@ -442,14 +541,22 @@  discard block
 block discarded – undo
442 541
 	public function fromFlickr($type,$registration,$name='') {
443 542
 		$Common = new Common();
444 543
 		if ($type == 'aircraft') {
445
-			if ($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='.$registration.','.urlencode($name);
446
-			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='.$registration.',aircraft';
544
+			if ($name != '') {
545
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
546
+			} else {
547
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
548
+			}
447 549
 		} elseif ($type == 'marine') {
448
-			if ($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=ship,'.urlencode($name);
449
-			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='.$registration.',ship';
550
+			if ($name != '') {
551
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
552
+			} else {
553
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
554
+			}
450 555
 		}
451 556
 		$data = $Common->getData($url);
452
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
557
+		if (substr($data, 0, 5) != "<?xml") {
558
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
559
+		}
453 560
 		if ($xml = simplexml_load_string($data)) {
454 561
 			if (isset($xml->channel->item)) {
455 562
 				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
@@ -498,13 +605,21 @@  discard block
 block discarded – undo
498 605
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
499 606
 		global $globalImageBingKey;
500 607
 		$Common = new Common();
501
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
608
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
609
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
610
+		}
502 611
 		if ($type == 'aircraft') {
503
-			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';
504
-			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';
612
+			if ($aircraft_name != '') {
613
+				$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';
614
+			} else {
615
+				$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';
616
+			}
505 617
 		} elseif ($type == 'marine') {
506
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
507
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
618
+			if ($aircraft_name != '') {
619
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
620
+			} else {
621
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
622
+			}
508 623
 		}
509 624
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
510 625
 		$data = $Common->getData($url,'get','',$headers);
@@ -561,17 +676,25 @@  discard block
 block discarded – undo
561 676
 	public function fromWikimedia($type,$registration,$name='') {
562 677
 		$Common = new Common();
563 678
 		if ($type == 'aircraft') {
564
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
565
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
679
+			if ($name != '') {
680
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
681
+			} else {
682
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
683
+			}
566 684
 		} elseif ($type == 'marine') {
567
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
568
-			else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
685
+			if ($name != '') {
686
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
687
+			} else {
688
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
689
+			}
569 690
 		}
570 691
 		$data = $Common->getData($url);
571 692
 		$result = json_decode($data);
572 693
 		if (isset($result->query->search[0]->title)) {
573 694
 			$fileo = $result->query->search[0]->title;
574
-			if (substr($fileo,-3) == 'pdf') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
695
+			if (substr($fileo,-3) == 'pdf') {
696
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
697
+			}
575 698
 			$file = urlencode($fileo);
576 699
 			$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;
577 700
 			$data2 = $Common->getData($url2);
@@ -642,18 +765,27 @@  discard block
 block discarded – undo
642 765
 					$image_url = array();
643 766
 					$image_url['thumbnail'] = $url_thumbnail;
644 767
 					$image_url['original'] = $url;
645
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
646
-					else $exifCopyright = '';
647
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
648
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
649
-					else $image_url['copyright'] = $source['source_website'];
768
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
769
+						$exifCopyright = $this->getExifCopyright($url);
770
+					} else {
771
+						$exifCopyright = '';
772
+					}
773
+					if ($exifCopyright  != '') {
774
+						$image_url['copyright'] = $exifCopyright;
775
+					} elseif (isset($source['copyright'])) {
776
+						$image_url['copyright'] = $source['copyright'];
777
+					} else {
778
+						$image_url['copyright'] = $source['source_website'];
779
+					}
650 780
 					$image_url['source_website'] = $source['source_website'];
651 781
 					$image_url['source'] = $source['source'];
652 782
 					return $image_url;
653 783
 				}
654 784
 			}
655 785
 			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
656
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
786
+		} else {
787
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
788
+		}
657 789
 
658 790
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
659 791
 			$customsources = array();
@@ -679,18 +811,27 @@  discard block
 block discarded – undo
679 811
 					$image_url = array();
680 812
 					$image_url['thumbnail'] = $url_thumbnail;
681 813
 					$image_url['original'] = $url;
682
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
683
-					else $exifCopyright = '';
684
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
685
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
686
-					else $image_url['copyright'] = $source['source_website'];
814
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
815
+						$exifCopyright = $this->getExifCopyright($url);
816
+					} else {
817
+						$exifCopyright = '';
818
+					}
819
+					if ($exifCopyright  != '') {
820
+						$image_url['copyright'] = $exifCopyright;
821
+					} elseif (isset($source['copyright'])) {
822
+						$image_url['copyright'] = $source['copyright'];
823
+					} else {
824
+						$image_url['copyright'] = $source['source_website'];
825
+					}
687 826
 					$image_url['source_website'] = $source['source_website'];
688 827
 					$image_url['source'] = $source['source'];
689 828
 					return $image_url;
690 829
 				}
691 830
 			}
692 831
 			return false;
693
-		} else return false;
832
+		} else {
833
+			return false;
834
+		}
694 835
 	}
695 836
 }
696 837
 
Please login to merge, or discard this patch.