Completed
Push — master ( 4407ee...8e145a )
by Yannick
06:51
created
require/class.Spotter.php 1 patch
Braces   +718 added lines, -250 removed lines patch added patch discarded remove patch
@@ -69,7 +69,9 @@  discard block
 block discarded – undo
69 69
 				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
70 70
 			}
71 71
 		}
72
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
72
+		if (is_array($globalFilter)) {
73
+			$filter = array_merge($filter,$globalFilter);
74
+		}
73 75
 		$filter_query_join = '';
74 76
 		$filter_query_where = '';
75 77
 		foreach($filters as $flt) {
@@ -122,8 +124,11 @@  discard block
 block discarded – undo
122 124
 				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
123 125
 			}
124 126
 		}
125
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
126
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
127
+		if ($filter_query_where == '' && $where) {
128
+			$filter_query_where = ' WHERE';
129
+		} elseif ($filter_query_where != '' && $and) {
130
+			$filter_query_where .= ' AND';
131
+		}
127 132
 		$filter_query = $filter_query_join.$filter_query_where;
128 133
 		return $filter_query;
129 134
 	}
@@ -143,10 +148,18 @@  discard block
 block discarded – undo
143 148
 		$Image = new Image($this->db);
144 149
 		$Schedule = new Schedule($this->db);
145 150
 		$ACARS = new ACARS($this->db);
146
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
147
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
148
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
149
-		if (!isset($globalVAM)) $globalVAM = FALSE;
151
+		if (!isset($globalIVAO)) {
152
+			$globalIVAO = FALSE;
153
+		}
154
+		if (!isset($globalVATSIM)) {
155
+			$globalVATSIM = FALSE;
156
+		}
157
+		if (!isset($globalphpVMS)) {
158
+			$globalphpVMS = FALSE;
159
+		}
160
+		if (!isset($globalVAM)) {
161
+			$globalVAM = FALSE;
162
+		}
150 163
 		date_default_timezone_set('UTC');
151 164
 		
152 165
 		if (!is_string($query))
@@ -193,21 +206,35 @@  discard block
 block discarded – undo
193 206
 			} else {
194 207
 				$temp_array['spotter_id'] = '';
195 208
 			}
196
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
197
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
209
+			if (isset($row['flightaware_id'])) {
210
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
211
+			}
212
+			if (isset($row['modes'])) {
213
+				$temp_array['modes'] = $row['modes'];
214
+			}
198 215
 			$temp_array['ident'] = $row['ident'];
199 216
 			if (isset($row['registration']) && $row['registration'] != '') {
200 217
 				$temp_array['registration'] = $row['registration'];
201 218
 			} elseif (isset($temp_array['modes'])) {
202 219
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
203
-			} else $temp_array['registration'] = '';
204
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
220
+			} else {
221
+				$temp_array['registration'] = '';
222
+			}
223
+			if (isset($row['aircraft_icao'])) {
224
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
225
+			}
205 226
 			
206 227
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
207 228
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
208
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
209
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
210
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
229
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
230
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
231
+			}
232
+			if (isset($row['latitude'])) {
233
+				$temp_array['latitude'] = $row['latitude'];
234
+			}
235
+			if (isset($row['longitude'])) {
236
+				$temp_array['longitude'] = $row['longitude'];
237
+			}
211 238
 			/*
212 239
 			if (Connection->tableExists('countries')) {
213 240
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -217,8 +244,12 @@  discard block
 block discarded – undo
217 244
 				}
218 245
 			}
219 246
 			*/
220
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
221
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
247
+			if (isset($row['waypoints'])) {
248
+				$temp_array['waypoints'] = $row['waypoints'];
249
+			}
250
+			if (isset($row['format_source'])) {
251
+				$temp_array['format_source'] = $row['format_source'];
252
+			}
222 253
 			if (isset($row['route_stop'])) {
223 254
 				$temp_array['route_stop'] = $row['route_stop'];
224 255
 				if ($row['route_stop'] != '') {
@@ -237,13 +268,19 @@  discard block
 block discarded – undo
237 268
 					}
238 269
 				}
239 270
 			}
240
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
271
+			if (isset($row['altitude'])) {
272
+				$temp_array['altitude'] = $row['altitude'];
273
+			}
241 274
 			if (isset($row['heading'])) {
242 275
 				$temp_array['heading'] = $row['heading'];
243 276
 				$heading_direction = $this->parseDirection($row['heading']);
244
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
277
+				if (isset($heading_direction[0]['direction_fullname'])) {
278
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
279
+				}
280
+			}
281
+			if (isset($row['ground_speed'])) {
282
+				$temp_array['ground_speed'] = $row['ground_speed'];
245 283
 			}
246
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
247 284
 			$temp_array['image'] = "";
248 285
 			$temp_array['image_thumbnail'] = "";
249 286
 			$temp_array['image_source'] = "";
@@ -251,7 +288,9 @@  discard block
 block discarded – undo
251 288
  
252 289
 			if (isset($row['highlight'])) {
253 290
 				$temp_array['highlight'] = $row['highlight'];
254
-			} else $temp_array['highlight'] = '';
291
+			} else {
292
+				$temp_array['highlight'] = '';
293
+			}
255 294
 			
256 295
 			if (isset($row['date'])) {
257 296
 				$dateArray = $this->parseDateString($row['date']);
@@ -299,7 +338,9 @@  discard block
 block discarded – undo
299 338
 				
300 339
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
301 340
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
302
-					} else $temp_array['aircraft_shadow'] = 'default.png';
341
+					} else {
342
+						$temp_array['aircraft_shadow'] = 'default.png';
343
+					}
303 344
                                 } else {
304 345
                             		$temp_array['aircraft_shadow'] = 'default.png';
305 346
 					$temp_array['aircraft_name'] = 'N/A';
@@ -307,11 +348,17 @@  discard block
 block discarded – undo
307 348
                             	}
308 349
 			}
309 350
 			$fromsource = NULL;
310
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
311
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
312
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
313
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
314
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
351
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
352
+				$fromsource = $globalAirlinesSource;
353
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
354
+				$fromsource = 'vatsim';
355
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
356
+				$fromsource = 'ivao';
357
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
358
+				$fromsource = 'vatsim';
359
+			} elseif (isset($globalIVAO) && $globalIVAO) {
360
+				$fromsource = 'ivao';
361
+			}
315 362
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
316 363
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
317 364
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -334,12 +381,18 @@  discard block
 block discarded – undo
334 381
 				}
335 382
 			} else {
336 383
 				$temp_array['airline_icao'] = $row['airline_icao'];
337
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
338
-				else $temp_array['airline_iata'] = 'N/A';
384
+				if (isset($row['airline_iata'])) {
385
+					$temp_array['airline_iata'] = $row['airline_iata'];
386
+				} else {
387
+					$temp_array['airline_iata'] = 'N/A';
388
+				}
339 389
 				$temp_array['airline_name'] = $row['airline_name'];
340 390
 				$temp_array['airline_country'] = $row['airline_country'];
341
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
342
-				else $temp_array['airline_callsign'] = 'N/A';
391
+				if (isset($row['airline_callsign'])) {
392
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
393
+				} else {
394
+					$temp_array['airline_callsign'] = 'N/A';
395
+				}
343 396
 				$temp_array['airline_type'] = $row['airline_type'];
344 397
 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') {
345 398
 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']);
@@ -366,7 +419,9 @@  discard block
 block discarded – undo
366 419
 			}
367 420
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
368 421
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
369
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
422
+				if ($owner_info['owner'] != '') {
423
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
424
+				}
370 425
 				$temp_array['aircraft_base'] = $owner_info['base'];
371 426
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
372 427
 			}
@@ -374,9 +429,14 @@  discard block
 block discarded – undo
374 429
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
375 430
 			{
376 431
 				if ($globalIVAO) {
377
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
378
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
379
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
432
+					if (isset($temp_array['airline_icao'])) {
433
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
434
+					} else {
435
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
436
+					}
437
+				} else {
438
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
439
+				}
380 440
 				if (count($image_array) > 0) {
381 441
 					$temp_array['image'] = $image_array[0]['image'];
382 442
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -428,7 +488,9 @@  discard block
 block discarded – undo
428 488
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
429 489
 			if ($row['departure_airport_icao'] != '') {
430 490
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
431
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
491
+				if (!isset($departure_airport_array[0]['name'])) {
492
+					$departure_airport_array = $this->getAllAirportInfo('NA');
493
+				}
432 494
 			/*
433 495
 			} elseif ($row['departure_airport_name'] != '') {
434 496
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -436,7 +498,9 @@  discard block
 block discarded – undo
436 498
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
437 499
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
438 500
 			*/
439
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
501
+			} else {
502
+				$departure_airport_array = $this->getAllAirportInfo('NA');
503
+			}
440 504
 			if (isset($departure_airport_array[0]['name'])) {
441 505
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
442 506
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -456,8 +520,12 @@  discard block
 block discarded – undo
456 520
 			
457 521
 			if ($row['arrival_airport_icao'] != '') {
458 522
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
459
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
460
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
523
+				if (count($arrival_airport_array) == 0) {
524
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
525
+				}
526
+			} else {
527
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
528
+			}
461 529
 			if (isset($arrival_airport_array[0]['name'])) {
462 530
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
463 531
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -473,27 +541,45 @@  discard block
 block discarded – undo
473 541
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
474 542
 			}
475 543
 			*/
476
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
477
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
478
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
479
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
480
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
544
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
545
+				$temp_array['pilot_id'] = $row['pilot_id'];
546
+			}
547
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
548
+				$temp_array['pilot_name'] = $row['pilot_name'];
549
+			}
550
+			if (isset($row['source_name']) && $row['source_name'] != '') {
551
+				$temp_array['source_name'] = $row['source_name'];
552
+			}
553
+			if (isset($row['over_country']) && $row['over_country'] != '') {
554
+				$temp_array['over_country'] = $row['over_country'];
555
+			}
556
+			if (isset($row['distance']) && $row['distance'] != '') {
557
+				$temp_array['distance'] = $row['distance'];
558
+			}
481 559
 			if (isset($row['squawk'])) {
482 560
 				$temp_array['squawk'] = $row['squawk'];
483 561
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
484 562
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
485
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
563
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
564
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
565
+					}
486 566
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
487 567
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
488
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
489
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
568
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
569
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
570
+					}
571
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
572
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
573
+				}
490 574
 			}
491 575
     			
492 576
 			$temp_array['query_number_rows'] = $num_rows;
493 577
 			
494 578
 			$spotter_array[] = $temp_array;
495 579
 		}
496
-		if ($num_rows == 0) return array();
580
+		if ($num_rows == 0) {
581
+			return array();
582
+		}
497 583
 		$spotter_array[0]['query_number_rows'] = $num_rows;
498 584
 		return $spotter_array;
499 585
 	}	
@@ -526,7 +612,9 @@  discard block
 block discarded – undo
526 612
 				foreach ($q_array as $q_item){
527 613
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
528 614
 					$additional_query .= " AND (";
529
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
615
+					if (is_int($q_item)) {
616
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
617
+					}
530 618
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
531 619
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
532 620
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -547,7 +635,9 @@  discard block
 block discarded – undo
547 635
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
548 636
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
549 637
 					$translate = $Translation->ident2icao($q_item);
550
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
638
+					if ($translate != $q_item) {
639
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
640
+					}
551 641
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
552 642
 					$additional_query .= ")";
553 643
 				}
@@ -774,7 +864,9 @@  discard block
 block discarded – undo
774 864
 				date_default_timezone_set($globalTimezone);
775 865
 				$datetime = new DateTime();
776 866
 				$offset = $datetime->format('P');
777
-			} else $offset = '+00:00';
867
+			} else {
868
+				$offset = '+00:00';
869
+			}
778 870
 
779 871
 			if ($date_array[1] != "")
780 872
 			{
@@ -806,8 +898,12 @@  discard block
 block discarded – undo
806 898
 			{
807 899
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
808 900
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
809
-			} else $limit_query = "";
810
-		} else $limit_query = "";
901
+			} else {
902
+				$limit_query = "";
903
+			}
904
+		} else {
905
+			$limit_query = "";
906
+		}
811 907
 
812 908
 
813 909
 		if ($sort != "")
@@ -875,8 +971,12 @@  discard block
 block discarded – undo
875 971
 			{
876 972
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
877 973
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
878
-			} else $limit_query = "";
879
-		} else $limit_query = "";
974
+			} else {
975
+				$limit_query = "";
976
+			}
977
+		} else {
978
+			$limit_query = "";
979
+		}
880 980
 		
881 981
 		if ($sort != "")
882 982
 		{
@@ -1200,7 +1300,9 @@  discard block
 block discarded – undo
1200 1300
 		global $global_query;
1201 1301
 		
1202 1302
 		date_default_timezone_set('UTC');
1203
-		if ($id == '') return array();
1303
+		if ($id == '') {
1304
+			return array();
1305
+		}
1204 1306
 		$additional_query = "spotter_output.spotter_id = :id";
1205 1307
 		$query_values = array(':id' => $id);
1206 1308
 
@@ -1937,7 +2039,9 @@  discard block
 block discarded – undo
1937 2039
 		{
1938 2040
 			$highlight = $row['highlight'];
1939 2041
 		}
1940
-		if (isset($highlight)) return $highlight;
2042
+		if (isset($highlight)) {
2043
+			return $highlight;
2044
+		}
1941 2045
 	}
1942 2046
 
1943 2047
 	
@@ -1965,7 +2069,9 @@  discard block
 block discarded – undo
1965 2069
 		$sth->closeCursor();
1966 2070
 		if (count($row) > 0) {
1967 2071
 			return $row['usage'];
1968
-		} else return '';
2072
+		} else {
2073
+			return '';
2074
+		}
1969 2075
 	}
1970 2076
 
1971 2077
 	/**
@@ -1990,7 +2096,9 @@  discard block
 block discarded – undo
1990 2096
 		$sth->closeCursor();
1991 2097
 		if (count($row) > 0) {
1992 2098
 			return $row['icao'];
1993
-		} else return '';
2099
+		} else {
2100
+			return '';
2101
+		}
1994 2102
 	}
1995 2103
 
1996 2104
 	/**
@@ -2018,7 +2126,9 @@  discard block
 block discarded – undo
2018 2126
 			$airport_longitude = $row['longitude'];
2019 2127
 			$Common = new Common();
2020 2128
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2021
-		} else return '';
2129
+		} else {
2130
+			return '';
2131
+		}
2022 2132
 	}
2023 2133
 	
2024 2134
 	/**
@@ -2130,7 +2240,9 @@  discard block
 block discarded – undo
2130 2240
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2131 2241
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2132 2242
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2133
-		} else return array();
2243
+		} else {
2244
+			return array();
2245
+		}
2134 2246
 		if ($globalDBdriver == 'mysql') {
2135 2247
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
2136 2248
 		} else {
@@ -2165,7 +2277,9 @@  discard block
 block discarded – undo
2165 2277
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2166 2278
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2167 2279
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2168
-		} else return array();
2280
+		} else {
2281
+			return array();
2282
+		}
2169 2283
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2170 2284
 		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2171 2285
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2200,7 +2314,9 @@  discard block
 block discarded – undo
2200 2314
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2201 2315
 	{
2202 2316
 		global $globalUseRealAirlines;
2203
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2317
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2318
+			$fromsource = NULL;
2319
+		}
2204 2320
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2205 2321
 		if ($airline_icao == 'NA') {
2206 2322
 			$airline_array = array();
@@ -2269,7 +2385,9 @@  discard block
 block discarded – undo
2269 2385
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2270 2386
 	{
2271 2387
 		global $globalUseRealAirlines;
2272
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2388
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2389
+			$fromsource = NULL;
2390
+		}
2273 2391
 		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2274 2392
 		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2275 2393
 		$sth = $this->db->prepare($query);
@@ -2285,7 +2403,9 @@  discard block
 block discarded – undo
2285 2403
 			$sth->execute(array(':fromsource' => $fromsource));
2286 2404
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
2287 2405
 			$sth->closeCursor();
2288
-			if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name);
2406
+			if ($row['nb'] == 0) {
2407
+				$result = $this->getAllAirlineInfoByName($airline_name);
2408
+			}
2289 2409
 		}
2290 2410
 		return $result;
2291 2411
 	}
@@ -2348,15 +2468,20 @@  discard block
 block discarded – undo
2348 2468
 				'A320-211' => 'A320',
2349 2469
 				'747-8i' => 'B748',
2350 2470
 				'A380' => 'A388');
2351
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2471
+		if (isset($all_aircraft[$aircraft_type])) {
2472
+			return $all_aircraft[$aircraft_type];
2473
+		}
2352 2474
 
2353 2475
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2354 2476
 		$aircraft_type = strtoupper($aircraft_type);
2355 2477
 		$sth = $this->db->prepare($query);
2356 2478
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2357 2479
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2358
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2359
-		else return '';
2480
+		if (isset($result[0]['icao'])) {
2481
+			return $result[0]['icao'];
2482
+		} else {
2483
+			return '';
2484
+		}
2360 2485
 	}
2361 2486
 	
2362 2487
 	/**
@@ -2379,9 +2504,13 @@  discard block
 block discarded – undo
2379 2504
 		$sth->closeCursor();
2380 2505
 		if (isset($row['icaotypecode'])) {
2381 2506
 			$icao = $row['icaotypecode'];
2382
-			if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao];
2507
+			if (isset($this->aircraft_correct_icaotype[$icao])) {
2508
+				$icao = $this->aircraft_correct_icaotype[$icao];
2509
+			}
2383 2510
 			return $icao;
2384
-		} else return '';
2511
+		} else {
2512
+			return '';
2513
+		}
2385 2514
 	}
2386 2515
 
2387 2516
 	/**
@@ -2404,7 +2533,9 @@  discard block
 block discarded – undo
2404 2533
 		$sth->closeCursor();
2405 2534
 		if (isset($row['icaotypecode'])) {
2406 2535
 			return $row['icaotypecode'];
2407
-		} else return '';
2536
+		} else {
2537
+			return '';
2538
+		}
2408 2539
 	}
2409 2540
 
2410 2541
 	/**
@@ -2450,7 +2581,9 @@  discard block
 block discarded – undo
2450 2581
 		$sth->closeCursor();
2451 2582
 		if (isset($row['operator_correct'])) {
2452 2583
 			return $row['operator_correct'];
2453
-		} else return $operator;
2584
+		} else {
2585
+			return $operator;
2586
+		}
2454 2587
 	}
2455 2588
 
2456 2589
 	/**
@@ -2463,7 +2596,9 @@  discard block
 block discarded – undo
2463 2596
 	public function getRouteInfo($callsign)
2464 2597
 	{
2465 2598
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2466
-                if ($callsign == '') return array();
2599
+                if ($callsign == '') {
2600
+                	return array();
2601
+                }
2467 2602
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2468 2603
 		
2469 2604
 		$sth = $this->db->prepare($query);
@@ -2473,7 +2608,9 @@  discard block
 block discarded – undo
2473 2608
 		$sth->closeCursor();
2474 2609
 		if (count($row) > 0) {
2475 2610
 			return $row;
2476
-		} else return array();
2611
+		} else {
2612
+			return array();
2613
+		}
2477 2614
 	}
2478 2615
 	
2479 2616
 	/**
@@ -2526,7 +2663,9 @@  discard block
 block discarded – undo
2526 2663
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2527 2664
 			$sth->closeCursor();
2528 2665
 			return $result;
2529
-		} else return array();
2666
+		} else {
2667
+			return array();
2668
+		}
2530 2669
 	}
2531 2670
 	
2532 2671
   
@@ -2685,8 +2824,11 @@  discard block
 block discarded – undo
2685 2824
 		$query .= " ORDER BY spotter_output.source_name ASC";
2686 2825
 
2687 2826
 		$sth = $this->db->prepare($query);
2688
-		if (!empty($query_values)) $sth->execute($query_values);
2689
-		else $sth->execute();
2827
+		if (!empty($query_values)) {
2828
+			$sth->execute($query_values);
2829
+		} else {
2830
+			$sth->execute();
2831
+		}
2690 2832
 
2691 2833
 		$source_array = array();
2692 2834
 		$temp_array = array();
@@ -2719,9 +2861,13 @@  discard block
 block discarded – undo
2719 2861
 								WHERE spotter_output.airline_icao <> '' 
2720 2862
 								ORDER BY spotter_output.airline_name ASC";
2721 2863
 			*/
2722
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2723
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2724
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2864
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2865
+				$forsource = $globalAirlinesSource;
2866
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2867
+				$forsource = 'vatsim';
2868
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2869
+				$forsource = 'ivao';
2870
+			}
2725 2871
 			if ($forsource === NULL) {
2726 2872
 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC";
2727 2873
 				$query_data = array();
@@ -2764,9 +2910,13 @@  discard block
 block discarded – undo
2764 2910
 	{
2765 2911
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2766 2912
 		$filter_query = $this->getFilter($filters,true,true);
2767
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2768
-		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2769
-		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2913
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2914
+			$forsource = $globalAirlinesSource;
2915
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
2916
+			$forsource = 'vatsim';
2917
+		} elseif (isset($globalIVAO) && $globalIVAO) {
2918
+			$forsource = 'ivao';
2919
+		}
2770 2920
 		if ($forsource === NULL) {
2771 2921
 			$query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC";
2772 2922
 			$query_data = array();
@@ -3041,7 +3191,9 @@  discard block
 block discarded – undo
3041 3191
 			date_default_timezone_set($globalTimezone);
3042 3192
 			$datetime = new DateTime();
3043 3193
 			$offset = $datetime->format('P');
3044
-		} else $offset = '+00:00';
3194
+		} else {
3195
+			$offset = '+00:00';
3196
+		}
3045 3197
 		if ($airport_icao == '') {
3046 3198
 			if ($globalDBdriver == 'mysql') {
3047 3199
 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3073,7 +3225,9 @@  discard block
 block discarded – undo
3073 3225
 			date_default_timezone_set($globalTimezone);
3074 3226
 			$datetime = new DateTime();
3075 3227
 			$offset = $datetime->format('P');
3076
-		} else $offset = '+00:00';
3228
+		} else {
3229
+			$offset = '+00:00';
3230
+		}
3077 3231
 		if ($airport_icao == '') {
3078 3232
 			if ($globalDBdriver == 'mysql') {
3079 3233
 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3106,7 +3260,9 @@  discard block
 block discarded – undo
3106 3260
 			date_default_timezone_set($globalTimezone);
3107 3261
 			$datetime = new DateTime();
3108 3262
 			$offset = $datetime->format('P');
3109
-		} else $offset = '+00:00';
3263
+		} else {
3264
+			$offset = '+00:00';
3265
+		}
3110 3266
 		if ($airport_icao == '') {
3111 3267
 			if ($globalDBdriver == 'mysql') {
3112 3268
 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3145,7 +3301,9 @@  discard block
 block discarded – undo
3145 3301
 			date_default_timezone_set($globalTimezone);
3146 3302
 			$datetime = new DateTime();
3147 3303
 			$offset = $datetime->format('P');
3148
-		} else $offset = '+00:00';
3304
+		} else {
3305
+			$offset = '+00:00';
3306
+		}
3149 3307
 		if ($airport_icao == '') {
3150 3308
 			if ($globalDBdriver == 'mysql') {
3151 3309
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3190,7 +3348,9 @@  discard block
 block discarded – undo
3190 3348
 			date_default_timezone_set($globalTimezone);
3191 3349
 			$datetime = new DateTime();
3192 3350
 			$offset = $datetime->format('P');
3193
-		} else $offset = '+00:00';
3351
+		} else {
3352
+			$offset = '+00:00';
3353
+		}
3194 3354
 		if ($airport_icao == '') {
3195 3355
 			if ($globalDBdriver == 'mysql') {
3196 3356
 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3225,7 +3385,9 @@  discard block
 block discarded – undo
3225 3385
 			date_default_timezone_set($globalTimezone);
3226 3386
 			$datetime = new DateTime();
3227 3387
 			$offset = $datetime->format('P');
3228
-		} else $offset = '+00:00';
3388
+		} else {
3389
+			$offset = '+00:00';
3390
+		}
3229 3391
 		if ($airport_icao == '') {
3230 3392
 			if ($globalDBdriver == 'mysql') {
3231 3393
 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3267,7 +3429,9 @@  discard block
 block discarded – undo
3267 3429
 			date_default_timezone_set($globalTimezone);
3268 3430
 			$datetime = new DateTime();
3269 3431
 			$offset = $datetime->format('P');
3270
-		} else $offset = '+00:00';
3432
+		} else {
3433
+			$offset = '+00:00';
3434
+		}
3271 3435
 		if ($airport_icao == '') {
3272 3436
 			if ($globalDBdriver == 'mysql') {
3273 3437
 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3301,7 +3465,9 @@  discard block
 block discarded – undo
3301 3465
 			date_default_timezone_set($globalTimezone);
3302 3466
 			$datetime = new DateTime();
3303 3467
 			$offset = $datetime->format('P');
3304
-		} else $offset = '+00:00';
3468
+		} else {
3469
+			$offset = '+00:00';
3470
+		}
3305 3471
 		if ($airport_icao == '') {
3306 3472
 			if ($globalDBdriver == 'mysql') {
3307 3473
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3349,7 +3515,9 @@  discard block
 block discarded – undo
3349 3515
 			date_default_timezone_set($globalTimezone);
3350 3516
 			$datetime = new DateTime();
3351 3517
 			$offset = $datetime->format('P');
3352
-		} else $offset = '+00:00';
3518
+		} else {
3519
+			$offset = '+00:00';
3520
+		}
3353 3521
 
3354 3522
 		if ($globalDBdriver == 'mysql') {
3355 3523
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3469,7 +3637,9 @@  discard block
 block discarded – undo
3469 3637
 	*/	
3470 3638
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3471 3639
 	{
3472
-		if ($groundspeed == '') $groundspeed = NULL;
3640
+		if ($groundspeed == '') {
3641
+			$groundspeed = NULL;
3642
+		}
3473 3643
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3474 3644
                 $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3475 3645
 
@@ -3519,10 +3689,18 @@  discard block
 block discarded – undo
3519 3689
 		$Image = new Image($this->db);
3520 3690
 		$Common = new Common();
3521 3691
 		
3522
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3523
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3524
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3525
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3692
+		if (!isset($globalIVAO)) {
3693
+			$globalIVAO = FALSE;
3694
+		}
3695
+		if (!isset($globalVATSIM)) {
3696
+			$globalVATSIM = FALSE;
3697
+		}
3698
+		if (!isset($globalphpVMS)) {
3699
+			$globalphpVMS = FALSE;
3700
+		}
3701
+		if (!isset($globalVAM)) {
3702
+			$globalVAM = FALSE;
3703
+		}
3526 3704
 		date_default_timezone_set('UTC');
3527 3705
 		
3528 3706
 		//getting the registration
@@ -3535,23 +3713,33 @@  discard block
 block discarded – undo
3535 3713
 				if ($ModeS != '') {
3536 3714
 					$timeelapsed = microtime(true);
3537 3715
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3538
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3716
+					if ($globalDebugTimeElapsed) {
3717
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3718
+					}
3539 3719
 				} else {
3540 3720
 					$myhex = explode('-',$flightaware_id);
3541 3721
 					if (count($myhex) > 0) {
3542 3722
 						$timeelapsed = microtime(true);
3543 3723
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3544
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3724
+						if ($globalDebugTimeElapsed) {
3725
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3726
+						}
3545 3727
 					}
3546 3728
 				}
3547 3729
 			}
3548 3730
 		}
3549 3731
 		$fromsource = NULL;
3550
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3551
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3552
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3553
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3554
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3732
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3733
+			$fromsource = $globalAirlinesSource;
3734
+		} elseif ($format_source == 'vatsimtxt') {
3735
+			$fromsource = 'vatsim';
3736
+		} elseif ($format_source == 'whazzup') {
3737
+			$fromsource = 'ivao';
3738
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3739
+			$fromsource = 'vatsim';
3740
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3741
+			$fromsource = 'ivao';
3742
+		}
3555 3743
 		//getting the airline information
3556 3744
 		if ($ident != "")
3557 3745
 		{
@@ -3575,15 +3763,21 @@  discard block
 block discarded – undo
3575 3763
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3576 3764
 						$airline_array = $this->getAllAirlineInfo("NA");
3577 3765
 					}
3578
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3766
+					if ($globalDebugTimeElapsed) {
3767
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3768
+					}
3579 3769
 
3580 3770
 				} else {
3581 3771
 					$timeelapsed = microtime(true);
3582 3772
 					$airline_array = $this->getAllAirlineInfo("NA");
3583
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3773
+					if ($globalDebugTimeElapsed) {
3774
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3775
+					}
3584 3776
 				}
3585 3777
 			}
3586
-		} else $airline_array = array();
3778
+		} else {
3779
+			$airline_array = array();
3780
+		}
3587 3781
 		
3588 3782
 		//getting the aircraft information
3589 3783
 		$aircraft_array = array();
@@ -3597,27 +3791,37 @@  discard block
 block discarded – undo
3597 3791
 				{
3598 3792
 					$timeelapsed = microtime(true);
3599 3793
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3600
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3794
+					if ($globalDebugTimeElapsed) {
3795
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3796
+					}
3601 3797
 				} else {
3602 3798
 					$timeelapsed = microtime(true);
3603 3799
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3604
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3800
+					if ($globalDebugTimeElapsed) {
3801
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3802
+					}
3605 3803
 				}
3606 3804
 			}
3607 3805
 		} else {
3608 3806
 			if ($ModeS != '') {
3609 3807
 				$timeelapsed = microtime(true);
3610 3808
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3611
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3809
+				if ($globalDebugTimeElapsed) {
3810
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3811
+				}
3612 3812
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3613 3813
 				{
3614 3814
 					$timeelapsed = microtime(true);
3615 3815
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3616
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3816
+					if ($globalDebugTimeElapsed) {
3817
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3818
+					}
3617 3819
 				} else {
3618 3820
 					$timeelapsed = microtime(true);
3619 3821
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3620
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3822
+					if ($globalDebugTimeElapsed) {
3823
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3824
+					}
3621 3825
 				}
3622 3826
 			}
3623 3827
 		}
@@ -3633,7 +3837,9 @@  discard block
 block discarded – undo
3633 3837
 			} else {
3634 3838
 				$timeelapsed = microtime(true);
3635 3839
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3636
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3840
+				if ($globalDebugTimeElapsed) {
3841
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3842
+				}
3637 3843
 			}
3638 3844
 		}
3639 3845
 		
@@ -3648,7 +3854,9 @@  discard block
 block discarded – undo
3648 3854
 			} else {
3649 3855
 				$timeelapsed = microtime(true);
3650 3856
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3651
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3857
+				if ($globalDebugTimeElapsed) {
3858
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3859
+				}
3652 3860
 			}
3653 3861
 		}
3654 3862
 
@@ -3682,7 +3890,9 @@  discard block
 block discarded – undo
3682 3890
 			{
3683 3891
 				return false;
3684 3892
 			}
3685
-		} else $altitude = 0;
3893
+		} else {
3894
+			$altitude = 0;
3895
+		}
3686 3896
 		
3687 3897
 		if ($heading != "")
3688 3898
 		{
@@ -3711,7 +3921,9 @@  discard block
 block discarded – undo
3711 3921
 		{
3712 3922
 			$timeelapsed = microtime(true);
3713 3923
 			$image_array = $Image->getSpotterImage($registration);
3714
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3924
+			if ($globalDebugTimeElapsed) {
3925
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3926
+			}
3715 3927
 			if (!isset($image_array[0]['registration']))
3716 3928
 			{
3717 3929
 				//echo "Add image !!!! \n";
@@ -3719,14 +3931,21 @@  discard block
 block discarded – undo
3719 3931
 			}
3720 3932
 			$timeelapsed = microtime(true);
3721 3933
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3722
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3723
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3934
+			if ($globalDebugTimeElapsed) {
3935
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3936
+			}
3937
+			if ($owner_info['owner'] != '') {
3938
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
3939
+			}
3724 3940
 		}
3725 3941
     
3726 3942
 		if ($globalIVAO && $aircraft_icao != '')
3727 3943
 		{
3728
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3729
-            		else $airline_icao = '';
3944
+            		if (isset($airline_array[0]['icao'])) {
3945
+            			$airline_icao = $airline_array[0]['icao'];
3946
+            		} else {
3947
+            			$airline_icao = '';
3948
+            		}
3730 3949
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3731 3950
 			if (!isset($image_array[0]['registration']))
3732 3951
 			{
@@ -3771,16 +3990,28 @@  discard block
 block discarded – undo
3771 3990
                 {
3772 3991
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3773 3992
                 }
3774
-                if ($registration == '') $registration = 'NA';
3993
+                if ($registration == '') {
3994
+                	$registration = 'NA';
3995
+                }
3775 3996
                 if ($latitude == '' && $longitude == '') {
3776 3997
             		$latitude = 0;
3777 3998
             		$longitude = 0;
3778 3999
             	}
3779
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3780
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3781
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3782
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3783
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
4000
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
4001
+                	$squawk = NULL;
4002
+                }
4003
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
4004
+                	$verticalrate = NULL;
4005
+                }
4006
+                if ($heading == '' || $Common->isInteger($heading) === false) {
4007
+                	$heading = 0;
4008
+                }
4009
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
4010
+                	$groundspeed = 0;
4011
+                }
4012
+                if (!isset($aircraft_owner)) {
4013
+                	$aircraft_owner = NULL;
4014
+                }
3784 4015
                 $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3785 4016
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3786 4017
 
@@ -3791,9 +4022,13 @@  discard block
 block discarded – undo
3791 4022
 		if ($airline_type == '') {
3792 4023
 			$timeelapsed = microtime(true);
3793 4024
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3794
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4025
+			if ($globalDebugTimeElapsed) {
4026
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4027
+			}
4028
+		}
4029
+		if ($airline_type == null) {
4030
+			$airline_type = '';
3795 4031
 		}
3796
-		if ($airline_type == null) $airline_type = '';
3797 4032
                 $aircraft_type = $aircraft_array[0]['type'];
3798 4033
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3799 4034
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -3957,7 +4192,9 @@  discard block
 block discarded – undo
3957 4192
 			}
3958 4193
 		}
3959 4194
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
3960
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4195
+		if ($limit) {
4196
+			$query .= " LIMIT 10 OFFSET 0";
4197
+		}
3961 4198
 
3962 4199
 		$sth = $this->db->prepare($query);
3963 4200
 		$sth->execute($query_values);
@@ -4030,7 +4267,9 @@  discard block
 block discarded – undo
4030 4267
 		}
4031 4268
 		
4032 4269
 		$query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4033
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4270
+		if ($limit) {
4271
+			$query .= " LIMIT 10 OFFSET 0";
4272
+		}
4034 4273
       
4035 4274
 		
4036 4275
 		$sth = $this->db->prepare($query);
@@ -4074,7 +4313,9 @@  discard block
 block discarded – undo
4074 4313
 			}
4075 4314
 		}
4076 4315
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4077
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4316
+		if ($limit) {
4317
+			$query .= " LIMIT 10 OFFSET 0";
4318
+		}
4078 4319
       
4079 4320
 		
4080 4321
 		$sth = $this->db->prepare($query);
@@ -4150,7 +4391,9 @@  discard block
 block discarded – undo
4150 4391
 			}
4151 4392
 		}
4152 4393
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
4153
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4394
+		if ($limit) {
4395
+			$query .= " LIMIT 10 OFFSET 0";
4396
+		}
4154 4397
 		
4155 4398
 		$sth = $this->db->prepare($query);
4156 4399
 		$sth->execute($query_values);
@@ -4192,7 +4435,9 @@  discard block
 block discarded – undo
4192 4435
 			}
4193 4436
 		}
4194 4437
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
4195
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4438
+		if ($limit) {
4439
+			$query .= " LIMIT 10 OFFSET 0";
4440
+		}
4196 4441
       
4197 4442
 		
4198 4443
 		$sth = $this->db->prepare($query);
@@ -4435,7 +4680,9 @@  discard block
 block discarded – undo
4435 4680
 			date_default_timezone_set($globalTimezone);
4436 4681
 			$datetime = new DateTime($date);
4437 4682
 			$offset = $datetime->format('P');
4438
-		} else $offset = '+00:00';
4683
+		} else {
4684
+			$offset = '+00:00';
4685
+		}
4439 4686
 
4440 4687
 		if ($globalDBdriver == 'mysql') {
4441 4688
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4483,7 +4730,9 @@  discard block
 block discarded – undo
4483 4730
 			date_default_timezone_set($globalTimezone);
4484 4731
 			$datetime = new DateTime($date);
4485 4732
 			$offset = $datetime->format('P');
4486
-		} else $offset = '+00:00';
4733
+		} else {
4734
+			$offset = '+00:00';
4735
+		}
4487 4736
 		
4488 4737
 		if ($globalDBdriver == 'mysql') {
4489 4738
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4759,7 +5008,9 @@  discard block
 block discarded – undo
4759 5008
 		}
4760 5009
 		$query .= " GROUP BY spotter_output.airline_country
4761 5010
 					ORDER BY airline_country_count DESC";
4762
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5011
+		if ($limit) {
5012
+			$query .= " LIMIT 10 OFFSET 0";
5013
+		}
4763 5014
       
4764 5015
 		$sth = $this->db->prepare($query);
4765 5016
 		$sth->execute($query_values);
@@ -4787,7 +5038,9 @@  discard block
 block discarded – undo
4787 5038
 		global $globalDBdriver;
4788 5039
 		//$filter_query = $this->getFilter($filters,true,true);
4789 5040
 		$Connection= new Connection($this->db);
4790
-		if (!$Connection->tableExists('countries')) return array();
5041
+		if (!$Connection->tableExists('countries')) {
5042
+			return array();
5043
+		}
4791 5044
 		/*
4792 5045
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
4793 5046
 					FROM countries c, spotter_output s
@@ -4819,7 +5072,9 @@  discard block
 block discarded – undo
4819 5072
 		}
4820 5073
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country ";
4821 5074
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
4822
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5075
+		if ($limit) {
5076
+			$query .= " LIMIT 10 OFFSET 0";
5077
+		}
4823 5078
       
4824 5079
 		
4825 5080
 		$sth = $this->db->prepare($query);
@@ -4896,7 +5151,9 @@  discard block
 block discarded – undo
4896 5151
 		}
4897 5152
 
4898 5153
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4899
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5154
+		if ($limit) {
5155
+			$query .= " LIMIT 10 OFFSET 0";
5156
+		}
4900 5157
  
4901 5158
 		$sth = $this->db->prepare($query);
4902 5159
 		$sth->execute($query_values);
@@ -4970,7 +5227,9 @@  discard block
 block discarded – undo
4970 5227
 		}
4971 5228
 
4972 5229
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4973
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5230
+		if ($limit) {
5231
+			$query .= " LIMIT 10 OFFSET 0";
5232
+		}
4974 5233
  
4975 5234
 		$sth = $this->db->prepare($query);
4976 5235
 		$sth->execute($query_values);
@@ -5017,7 +5276,9 @@  discard block
 block discarded – undo
5017 5276
 		}
5018 5277
 
5019 5278
 		$query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5020
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5279
+		if ($limit) {
5280
+			$query .= " LIMIT 10 OFFSET 0";
5281
+		}
5021 5282
  
5022 5283
 		$sth = $this->db->prepare($query);
5023 5284
 		$sth->execute();
@@ -5070,7 +5331,9 @@  discard block
 block discarded – undo
5070 5331
 			if($row['registration'] != "")
5071 5332
 			{
5072 5333
 				$image_array = $Image->getSpotterImage($row['registration']);
5073
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5334
+				if (isset($image_array[0]['image_thumbnail'])) {
5335
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5336
+				}
5074 5337
 			}
5075 5338
 			$temp_array['registration_count'] = $row['registration_count'];
5076 5339
 
@@ -5145,7 +5408,9 @@  discard block
 block discarded – undo
5145 5408
 			if($row['registration'] != "")
5146 5409
 			{
5147 5410
 				$image_array = $Image->getSpotterImage($row['registration']);
5148
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5411
+				if (isset($image_array[0]['image_thumbnail'])) {
5412
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5413
+				}
5149 5414
 			}
5150 5415
 			$temp_array['registration_count'] = $row['registration_count'];
5151 5416
 
@@ -5252,7 +5517,9 @@  discard block
 block discarded – undo
5252 5517
 			if($row['registration'] != "")
5253 5518
 			{
5254 5519
 				$image_array = $Image->getSpotterImage($row['registration']);
5255
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5520
+				if (isset($image_array[0]['image_thumbnail'])) {
5521
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5522
+				}
5256 5523
 			}
5257 5524
 			$temp_array['registration_count'] = $row['registration_count'];
5258 5525
 			$aircraft_array[] = $temp_array;
@@ -5377,7 +5644,9 @@  discard block
 block discarded – undo
5377 5644
 			date_default_timezone_set($globalTimezone);
5378 5645
 			$datetime = new DateTime($date);
5379 5646
 			$offset = $datetime->format('P');
5380
-		} else $offset = '+00:00';
5647
+		} else {
5648
+			$offset = '+00:00';
5649
+		}
5381 5650
 
5382 5651
 		if ($globalDBdriver == 'mysql') {
5383 5652
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -5424,7 +5693,9 @@  discard block
 block discarded – undo
5424 5693
 			date_default_timezone_set($globalTimezone);
5425 5694
 			$datetime = new DateTime($date);
5426 5695
 			$offset = $datetime->format('P');
5427
-		} else $offset = '+00:00';
5696
+		} else {
5697
+			$offset = '+00:00';
5698
+		}
5428 5699
 
5429 5700
 		if ($globalDBdriver == 'mysql') {
5430 5701
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
@@ -5453,7 +5724,9 @@  discard block
 block discarded – undo
5453 5724
 			if($row['registration'] != "")
5454 5725
 			{
5455 5726
 				$image_array = $Image->getSpotterImage($row['registration']);
5456
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5727
+				if (isset($image_array[0]['image_thumbnail'])) {
5728
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5729
+				}
5457 5730
 			}
5458 5731
 			$temp_array['registration_count'] = $row['registration_count'];
5459 5732
  
@@ -5478,7 +5751,9 @@  discard block
 block discarded – undo
5478 5751
 			date_default_timezone_set($globalTimezone);
5479 5752
 			$datetime = new DateTime($date);
5480 5753
 			$offset = $datetime->format('P');
5481
-		} else $offset = '+00:00';
5754
+		} else {
5755
+			$offset = '+00:00';
5756
+		}
5482 5757
 
5483 5758
 		if ($globalDBdriver == 'mysql') {
5484 5759
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5616,8 +5891,11 @@  discard block
 block discarded – undo
5616 5891
 			if($row['registration'] != "")
5617 5892
 			{
5618 5893
 				$image_array = $Image->getSpotterImage($row['registration']);
5619
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5620
-				else $temp_array['image_thumbnail'] = '';
5894
+				if (isset($image_array[0]['image_thumbnail'])) {
5895
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5896
+				} else {
5897
+					$temp_array['image_thumbnail'] = '';
5898
+				}
5621 5899
 			}
5622 5900
 			$temp_array['registration_count'] = $row['registration_count'];
5623 5901
 			$aircraft_array[] = $temp_array;
@@ -5660,8 +5938,11 @@  discard block
 block discarded – undo
5660 5938
 			if($row['registration'] != "")
5661 5939
 			{
5662 5940
 				$image_array = $Image->getSpotterImage($row['registration']);
5663
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5664
-				else $temp_array['image_thumbnail'] = '';
5941
+				if (isset($image_array[0]['image_thumbnail'])) {
5942
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5943
+				} else {
5944
+					$temp_array['image_thumbnail'] = '';
5945
+				}
5665 5946
 			}
5666 5947
 			$temp_array['registration_count'] = $row['registration_count'];
5667 5948
 			$aircraft_array[] = $temp_array;
@@ -5704,8 +5985,11 @@  discard block
 block discarded – undo
5704 5985
 			if($row['registration'] != "")
5705 5986
 			{
5706 5987
 				$image_array = $Image->getSpotterImage($row['registration']);
5707
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5708
-				else $temp_array['image_thumbnail'] = '';
5988
+				if (isset($image_array[0]['image_thumbnail'])) {
5989
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5990
+				} else {
5991
+					$temp_array['image_thumbnail'] = '';
5992
+				}
5709 5993
 			}
5710 5994
 			$temp_array['registration_count'] = $row['registration_count'];
5711 5995
 			$aircraft_array[] = $temp_array;
@@ -5854,7 +6138,9 @@  discard block
 block discarded – undo
5854 6138
 			if($row['registration'] != "")
5855 6139
 			{
5856 6140
 				$image_array = $Image->getSpotterImage($row['registration']);
5857
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6141
+				if (isset($image_array[0]['image_thumbnail'])) {
6142
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6143
+				}
5858 6144
 			}
5859 6145
 			$temp_array['registration_count'] = $row['registration_count'];
5860 6146
           
@@ -5971,7 +6257,9 @@  discard block
 block discarded – undo
5971 6257
 			if($row['registration'] != "")
5972 6258
 			{
5973 6259
 				$image_array = $Image->getSpotterImage($row['registration']);
5974
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6260
+				if (isset($image_array[0]['image_thumbnail'])) {
6261
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6262
+				}
5975 6263
 			}
5976 6264
 			$temp_array['registration_count'] = $row['registration_count'];
5977 6265
           
@@ -6137,7 +6425,9 @@  discard block
 block discarded – undo
6137 6425
 			}
6138 6426
 		}
6139 6427
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6140
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6428
+		if ($limit) {
6429
+			$query .= " LIMIT 10 OFFSET 0";
6430
+		}
6141 6431
 		
6142 6432
 		$sth = $this->db->prepare($query);
6143 6433
 		$sth->execute($query_values);
@@ -6156,7 +6446,9 @@  discard block
 block discarded – undo
6156 6446
 			if($row['registration'] != "")
6157 6447
 			{
6158 6448
 				$image_array = $Image->getSpotterImage($row['registration']);
6159
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6449
+				if (isset($image_array[0]['image_thumbnail'])) {
6450
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6451
+				}
6160 6452
 			}
6161 6453
           
6162 6454
 			$aircraft_array[] = $temp_array;
@@ -6197,7 +6489,9 @@  discard block
 block discarded – undo
6197 6489
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6198 6490
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6199 6491
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6200
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6492
+		if ($limit) {
6493
+			$query .= " LIMIT 10 OFFSET 0";
6494
+		}
6201 6495
 		
6202 6496
 		$sth = $this->db->prepare($query);
6203 6497
 		$sth->execute();
@@ -6217,7 +6511,9 @@  discard block
 block discarded – undo
6217 6511
 			if($row['registration'] != "")
6218 6512
 			{
6219 6513
 				$image_array = $Image->getSpotterImage($row['registration']);
6220
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6514
+				if (isset($image_array[0]['image_thumbnail'])) {
6515
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6516
+				}
6221 6517
 			}
6222 6518
           
6223 6519
 			$aircraft_array[] = $temp_array;
@@ -6283,7 +6579,9 @@  discard block
 block discarded – undo
6283 6579
 		}
6284 6580
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6285 6581
 				ORDER BY airport_departure_icao_count DESC";
6286
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6582
+		if ($limit) {
6583
+			$query .= " LIMIT 10 OFFSET 0";
6584
+		}
6287 6585
 
6288 6586
 		$sth = $this->db->prepare($query);
6289 6587
 		$sth->execute($query_values);
@@ -6334,7 +6632,9 @@  discard block
 block discarded – undo
6334 6632
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6335 6633
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6336 6634
 				ORDER BY airport_departure_icao_count DESC";
6337
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6635
+		if ($limit) {
6636
+			$query .= " LIMIT 10 OFFSET 0";
6637
+		}
6338 6638
       
6339 6639
 		$sth = $this->db->prepare($query);
6340 6640
 		$sth->execute();
@@ -6412,7 +6712,9 @@  discard block
 block discarded – undo
6412 6712
 		}
6413 6713
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6414 6714
 				ORDER BY airport_departure_icao_count DESC";
6415
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6715
+		if ($limit) {
6716
+			$query .= " LIMIT 10 OFFSET 0";
6717
+		}
6416 6718
     		//echo $query;
6417 6719
 		$sth = $this->db->prepare($query);
6418 6720
 		$sth->execute($query_values);
@@ -6464,7 +6766,9 @@  discard block
 block discarded – undo
6464 6766
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6465 6767
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6466 6768
 				ORDER BY airport_departure_icao_count DESC";
6467
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6769
+		if ($limit) {
6770
+			$query .= " LIMIT 10 OFFSET 0";
6771
+		}
6468 6772
       
6469 6773
 		$sth = $this->db->prepare($query);
6470 6774
 		$sth->execute();
@@ -6859,7 +7163,9 @@  discard block
 block discarded – undo
6859 7163
 			date_default_timezone_set($globalTimezone);
6860 7164
 			$datetime = new DateTime($date);
6861 7165
 			$offset = $datetime->format('P');
6862
-		} else $offset = '+00:00';
7166
+		} else {
7167
+			$offset = '+00:00';
7168
+		}
6863 7169
 
6864 7170
 		if ($globalDBdriver == 'mysql') {
6865 7171
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
@@ -6909,7 +7215,9 @@  discard block
 block discarded – undo
6909 7215
 			date_default_timezone_set($globalTimezone);
6910 7216
 			$datetime = new DateTime($date);
6911 7217
 			$offset = $datetime->format('P');
6912
-		} else $offset = '+00:00';
7218
+		} else {
7219
+			$offset = '+00:00';
7220
+		}
6913 7221
 
6914 7222
 		if ($globalDBdriver == 'mysql') {
6915 7223
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -7258,7 +7566,9 @@  discard block
 block discarded – undo
7258 7566
 		}
7259 7567
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7260 7568
 					ORDER BY airport_arrival_icao_count DESC";
7261
-		if ($limit) $query .= " LIMIT 10";
7569
+		if ($limit) {
7570
+			$query .= " LIMIT 10";
7571
+		}
7262 7572
       
7263 7573
 		
7264 7574
 		$sth = $this->db->prepare($query);
@@ -7278,7 +7588,9 @@  discard block
 block discarded – undo
7278 7588
 			if ($icaoaskey) {
7279 7589
 				$icao = $row['arrival_airport_icao'];
7280 7590
 				$airport_array[$icao] = $temp_array;
7281
-			} else $airport_array[] = $temp_array;
7591
+			} else {
7592
+				$airport_array[] = $temp_array;
7593
+			}
7282 7594
 		}
7283 7595
 
7284 7596
 		return $airport_array;
@@ -7315,7 +7627,9 @@  discard block
 block discarded – undo
7315 7627
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7316 7628
                 $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7317 7629
 					ORDER BY airport_arrival_icao_count DESC";
7318
-		if ($limit) $query .= " LIMIT 10";
7630
+		if ($limit) {
7631
+			$query .= " LIMIT 10";
7632
+		}
7319 7633
       
7320 7634
 		
7321 7635
 		$sth = $this->db->prepare($query);
@@ -7336,7 +7650,9 @@  discard block
 block discarded – undo
7336 7650
 			if ($icaoaskey) {
7337 7651
 				$icao = $row['arrival_airport_icao'];
7338 7652
 				$airport_array[$icao] = $temp_array;
7339
-			} else $airport_array[] = $temp_array;
7653
+			} else {
7654
+				$airport_array[] = $temp_array;
7655
+			}
7340 7656
 		}
7341 7657
 
7342 7658
 		return $airport_array;
@@ -7399,7 +7715,9 @@  discard block
 block discarded – undo
7399 7715
 		}
7400 7716
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7401 7717
 					ORDER BY airport_arrival_icao_count DESC";
7402
-		if ($limit) $query .= " LIMIT 10";
7718
+		if ($limit) {
7719
+			$query .= " LIMIT 10";
7720
+		}
7403 7721
       
7404 7722
 		
7405 7723
 		$sth = $this->db->prepare($query);
@@ -7418,7 +7736,9 @@  discard block
 block discarded – undo
7418 7736
 			if ($icaoaskey) {
7419 7737
 				$icao = $row['arrival_airport_icao'];
7420 7738
 				$airport_array[$icao] = $temp_array;
7421
-			} else $airport_array[] = $temp_array;
7739
+			} else {
7740
+				$airport_array[] = $temp_array;
7741
+			}
7422 7742
 		}
7423 7743
 
7424 7744
 		return $airport_array;
@@ -7455,7 +7775,9 @@  discard block
 block discarded – undo
7455 7775
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7456 7776
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7457 7777
 					ORDER BY airport_arrival_icao_count DESC";
7458
-		if ($limit) $query .= " LIMIT 10";
7778
+		if ($limit) {
7779
+			$query .= " LIMIT 10";
7780
+		}
7459 7781
       
7460 7782
 		
7461 7783
 		$sth = $this->db->prepare($query);
@@ -7476,7 +7798,9 @@  discard block
 block discarded – undo
7476 7798
 			if ($icaoaskey) {
7477 7799
 				$icao = $row['arrival_airport_icao'];
7478 7800
 				$airport_array[$icao] = $temp_array;
7479
-			} else $airport_array[] = $temp_array;
7801
+			} else {
7802
+				$airport_array[] = $temp_array;
7803
+			}
7480 7804
 		}
7481 7805
 
7482 7806
 		return $airport_array;
@@ -7857,7 +8181,9 @@  discard block
 block discarded – undo
7857 8181
 			date_default_timezone_set($globalTimezone);
7858 8182
 			$datetime = new DateTime($date);
7859 8183
 			$offset = $datetime->format('P');
7860
-		} else $offset = '+00:00';
8184
+		} else {
8185
+			$offset = '+00:00';
8186
+		}
7861 8187
 
7862 8188
 		if ($globalDBdriver == 'mysql') {
7863 8189
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
@@ -7907,7 +8233,9 @@  discard block
 block discarded – undo
7907 8233
 			date_default_timezone_set($globalTimezone);
7908 8234
 			$datetime = new DateTime($date);
7909 8235
 			$offset = $datetime->format('P');
7910
-		} else $offset = '+00:00';
8236
+		} else {
8237
+			$offset = '+00:00';
8238
+		}
7911 8239
 
7912 8240
 		if ($globalDBdriver == 'mysql') {
7913 8241
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -8278,7 +8606,9 @@  discard block
 block discarded – undo
8278 8606
 		}
8279 8607
 		$query .= " GROUP BY spotter_output.arrival_airport_country
8280 8608
 					ORDER BY airport_arrival_country_count DESC";
8281
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
8609
+		if ($limit) {
8610
+			$query .= " LIMIT 10 OFFSET 0";
8611
+		}
8282 8612
       
8283 8613
 		
8284 8614
 		$sth = $this->db->prepare($query);
@@ -8565,7 +8895,9 @@  discard block
 block discarded – undo
8565 8895
 			date_default_timezone_set($globalTimezone);
8566 8896
 			$datetime = new DateTime($date);
8567 8897
 			$offset = $datetime->format('P');
8568
-		} else $offset = '+00:00';
8898
+		} else {
8899
+			$offset = '+00:00';
8900
+		}
8569 8901
 		
8570 8902
 		if ($globalDBdriver == 'mysql') {
8571 8903
 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
@@ -8821,12 +9153,18 @@  discard block
 block discarded – undo
8821 9153
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
8822 9154
                     FROM spotter_output".$filter_query." spotter_output.ident <> '' ";
8823 9155
 		 if ($olderthanmonths > 0) {
8824
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
8825
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9156
+			if ($globalDBdriver == 'mysql') {
9157
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9158
+			} else {
9159
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9160
+			}
8826 9161
 		}
8827 9162
 		if ($sincedate != '') {
8828
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
8829
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9163
+			if ($globalDBdriver == 'mysql') {
9164
+				$query .= " AND spotter_output.date > '".$sincedate."'";
9165
+			} else {
9166
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9167
+			}
8830 9168
 		}
8831 9169
 		$query_values = array();
8832 9170
 		if ($year != '') {
@@ -8857,7 +9195,9 @@  discard block
 block discarded – undo
8857 9195
 			}
8858 9196
 		}
8859 9197
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
8860
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9198
+		if ($limit) {
9199
+			$query .= " LIMIT 10 OFFSET 0";
9200
+		}
8861 9201
       		
8862 9202
 		$sth = $this->db->prepare($query);
8863 9203
 		$sth->execute($query_values);
@@ -8891,15 +9231,23 @@  discard block
 block discarded – undo
8891 9231
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
8892 9232
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
8893 9233
 		 if ($olderthanmonths > 0) {
8894
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
8895
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9234
+			if ($globalDBdriver == 'mysql') {
9235
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9236
+			} else {
9237
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9238
+			}
8896 9239
 		}
8897 9240
 		if ($sincedate != '') {
8898
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
8899
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9241
+			if ($globalDBdriver == 'mysql') {
9242
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
9243
+			} else {
9244
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9245
+			}
8900 9246
 		}
8901 9247
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
8902
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9248
+		if ($limit) {
9249
+			$query .= " LIMIT 10 OFFSET 0";
9250
+		}
8903 9251
       		
8904 9252
 		$sth = $this->db->prepare($query);
8905 9253
 		$sth->execute();
@@ -8936,7 +9284,9 @@  discard block
 block discarded – undo
8936 9284
 			date_default_timezone_set($globalTimezone);
8937 9285
 			$datetime = new DateTime();
8938 9286
 			$offset = $datetime->format('P');
8939
-		} else $offset = '+00:00';
9287
+		} else {
9288
+			$offset = '+00:00';
9289
+		}
8940 9290
 
8941 9291
 		if ($globalDBdriver == 'mysql') {
8942 9292
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -8985,7 +9335,9 @@  discard block
 block discarded – undo
8985 9335
 			date_default_timezone_set($globalTimezone);
8986 9336
 			$datetime = new DateTime();
8987 9337
 			$offset = $datetime->format('P');
8988
-		} else $offset = '+00:00';
9338
+		} else {
9339
+			$offset = '+00:00';
9340
+		}
8989 9341
 		$filter_query = $this->getFilter($filters,true,true);
8990 9342
 		if ($globalDBdriver == 'mysql') {
8991 9343
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9034,7 +9386,9 @@  discard block
 block discarded – undo
9034 9386
 			date_default_timezone_set($globalTimezone);
9035 9387
 			$datetime = new DateTime();
9036 9388
 			$offset = $datetime->format('P');
9037
-		} else $offset = '+00:00';
9389
+		} else {
9390
+			$offset = '+00:00';
9391
+		}
9038 9392
 		$filter_query = $this->getFilter($filters,true,true);
9039 9393
 		if ($globalDBdriver == 'mysql') {
9040 9394
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9080,7 +9434,9 @@  discard block
 block discarded – undo
9080 9434
 			date_default_timezone_set($globalTimezone);
9081 9435
 			$datetime = new DateTime();
9082 9436
 			$offset = $datetime->format('P');
9083
-		} else $offset = '+00:00';
9437
+		} else {
9438
+			$offset = '+00:00';
9439
+		}
9084 9440
 		$filter_query = $this->getFilter($filters,true,true);
9085 9441
 		if ($globalDBdriver == 'mysql') {
9086 9442
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9128,7 +9484,9 @@  discard block
 block discarded – undo
9128 9484
 			date_default_timezone_set($globalTimezone);
9129 9485
 			$datetime = new DateTime();
9130 9486
 			$offset = $datetime->format('P');
9131
-		} else $offset = '+00:00';
9487
+		} else {
9488
+			$offset = '+00:00';
9489
+		}
9132 9490
 		
9133 9491
 		if ($globalDBdriver == 'mysql') {
9134 9492
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9176,7 +9534,9 @@  discard block
 block discarded – undo
9176 9534
 			date_default_timezone_set($globalTimezone);
9177 9535
 			$datetime = new DateTime();
9178 9536
 			$offset = $datetime->format('P');
9179
-		} else $offset = '+00:00';
9537
+		} else {
9538
+			$offset = '+00:00';
9539
+		}
9180 9540
 
9181 9541
 		if ($globalDBdriver == 'mysql') {
9182 9542
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9223,7 +9583,9 @@  discard block
 block discarded – undo
9223 9583
 			date_default_timezone_set($globalTimezone);
9224 9584
 			$datetime = new DateTime();
9225 9585
 			$offset = $datetime->format('P');
9226
-		} else $offset = '+00:00';
9586
+		} else {
9587
+			$offset = '+00:00';
9588
+		}
9227 9589
 
9228 9590
 		if ($globalDBdriver == 'mysql') {
9229 9591
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9271,7 +9633,9 @@  discard block
 block discarded – undo
9271 9633
 			date_default_timezone_set($globalTimezone);
9272 9634
 			$datetime = new DateTime();
9273 9635
 			$offset = $datetime->format('P');
9274
-		} else $offset = '+00:00';
9636
+		} else {
9637
+			$offset = '+00:00';
9638
+		}
9275 9639
 		$filter_query = $this->getFilter($filters,true,true);
9276 9640
 		if ($globalDBdriver == 'mysql') {
9277 9641
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9316,7 +9680,9 @@  discard block
 block discarded – undo
9316 9680
 			date_default_timezone_set($globalTimezone);
9317 9681
 			$datetime = new DateTime();
9318 9682
 			$offset = $datetime->format('P');
9319
-		} else $offset = '+00:00';
9683
+		} else {
9684
+			$offset = '+00:00';
9685
+		}
9320 9686
 		$filter_query = $this->getFilter($filters,true,true);
9321 9687
 
9322 9688
 		if ($globalDBdriver == 'mysql') {
@@ -9363,7 +9729,9 @@  discard block
 block discarded – undo
9363 9729
 			date_default_timezone_set($globalTimezone);
9364 9730
 			$datetime = new DateTime();
9365 9731
 			$offset = $datetime->format('P');
9366
-		} else $offset = '+00:00';
9732
+		} else {
9733
+			$offset = '+00:00';
9734
+		}
9367 9735
 
9368 9736
 		if ($globalDBdriver == 'mysql') {
9369 9737
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
@@ -9409,7 +9777,9 @@  discard block
 block discarded – undo
9409 9777
 			date_default_timezone_set($globalTimezone);
9410 9778
 			$datetime = new DateTime();
9411 9779
 			$offset = $datetime->format('P');
9412
-		} else $offset = '+00:00';
9780
+		} else {
9781
+			$offset = '+00:00';
9782
+		}
9413 9783
 		$filter_query = $this->getFilter($filters,true,true);
9414 9784
 
9415 9785
 		if ($globalDBdriver == 'mysql') {
@@ -9456,7 +9826,9 @@  discard block
 block discarded – undo
9456 9826
 			date_default_timezone_set($globalTimezone);
9457 9827
 			$datetime = new DateTime();
9458 9828
 			$offset = $datetime->format('P');
9459
-		} else $offset = '+00:00';
9829
+		} else {
9830
+			$offset = '+00:00';
9831
+		}
9460 9832
 
9461 9833
 		if ($globalDBdriver == 'mysql') {
9462 9834
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
@@ -9503,7 +9875,9 @@  discard block
 block discarded – undo
9503 9875
 			date_default_timezone_set($globalTimezone);
9504 9876
 			$datetime = new DateTime();
9505 9877
 			$offset = $datetime->format('P');
9506
-		} else $offset = '+00:00';
9878
+		} else {
9879
+			$offset = '+00:00';
9880
+		}
9507 9881
 
9508 9882
 		if ($globalDBdriver == 'mysql') {
9509 9883
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
@@ -9548,7 +9922,9 @@  discard block
 block discarded – undo
9548 9922
 			date_default_timezone_set($globalTimezone);
9549 9923
 			$datetime = new DateTime();
9550 9924
 			$offset = $datetime->format('P');
9551
-		} else $offset = '+00:00';
9925
+		} else {
9926
+			$offset = '+00:00';
9927
+		}
9552 9928
 		$filter_query = $this->getFilter($filters,true,true);
9553 9929
 
9554 9930
 		if ($globalDBdriver == 'mysql') {
@@ -9596,7 +9972,9 @@  discard block
 block discarded – undo
9596 9972
 			date_default_timezone_set($globalTimezone);
9597 9973
 			$datetime = new DateTime();
9598 9974
 			$offset = $datetime->format('P');
9599
-		} else $offset = '+00:00';
9975
+		} else {
9976
+			$offset = '+00:00';
9977
+		}
9600 9978
 
9601 9979
 		if ($globalDBdriver == 'mysql') {
9602 9980
 			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
@@ -9642,7 +10020,9 @@  discard block
 block discarded – undo
9642 10020
 			date_default_timezone_set($globalTimezone);
9643 10021
 			$datetime = new DateTime();
9644 10022
 			$offset = $datetime->format('P');
9645
-		} else $offset = '+00:00';
10023
+		} else {
10024
+			$offset = '+00:00';
10025
+		}
9646 10026
 		$filter_query = $this->getFilter($filters,true,true);
9647 10027
 
9648 10028
 		if ($globalDBdriver == 'mysql') {
@@ -9690,7 +10070,9 @@  discard block
 block discarded – undo
9690 10070
 			date_default_timezone_set($globalTimezone);
9691 10071
 			$datetime = new DateTime();
9692 10072
 			$offset = $datetime->format('P');
9693
-		} else $offset = '+00:00';
10073
+		} else {
10074
+			$offset = '+00:00';
10075
+		}
9694 10076
 
9695 10077
 		if ($globalDBdriver == 'mysql') {
9696 10078
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
@@ -9737,7 +10119,9 @@  discard block
 block discarded – undo
9737 10119
 			date_default_timezone_set($globalTimezone);
9738 10120
 			$datetime = new DateTime();
9739 10121
 			$offset = $datetime->format('P');
9740
-		} else $offset = '+00:00';
10122
+		} else {
10123
+			$offset = '+00:00';
10124
+		}
9741 10125
 		$filter_query = $this->getFilter($filters,true,true);
9742 10126
 		if ($globalDBdriver == 'mysql') {
9743 10127
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -9786,7 +10170,9 @@  discard block
 block discarded – undo
9786 10170
 			date_default_timezone_set($globalTimezone);
9787 10171
 			$datetime = new DateTime();
9788 10172
 			$offset = $datetime->format('P');
9789
-		} else $offset = '+00:00';
10173
+		} else {
10174
+			$offset = '+00:00';
10175
+		}
9790 10176
 
9791 10177
 		$orderby_sql = '';
9792 10178
 		if ($orderby == "hour")
@@ -9852,7 +10238,9 @@  discard block
 block discarded – undo
9852 10238
 			date_default_timezone_set($globalTimezone);
9853 10239
 			$datetime = new DateTime();
9854 10240
 			$offset = $datetime->format('P');
9855
-		} else $offset = '+00:00';
10241
+		} else {
10242
+			$offset = '+00:00';
10243
+		}
9856 10244
 
9857 10245
 		$orderby_sql = '';
9858 10246
 		if ($orderby == "hour")
@@ -9919,7 +10307,9 @@  discard block
 block discarded – undo
9919 10307
 			date_default_timezone_set($globalTimezone);
9920 10308
 			$datetime = new DateTime();
9921 10309
 			$offset = $datetime->format('P');
9922
-		} else $offset = '+00:00';
10310
+		} else {
10311
+			$offset = '+00:00';
10312
+		}
9923 10313
 
9924 10314
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
9925 10315
 
@@ -9970,7 +10360,9 @@  discard block
 block discarded – undo
9970 10360
 			date_default_timezone_set($globalTimezone);
9971 10361
 			$datetime = new DateTime();
9972 10362
 			$offset = $datetime->format('P');
9973
-		} else $offset = '+00:00';
10363
+		} else {
10364
+			$offset = '+00:00';
10365
+		}
9974 10366
 
9975 10367
 		if ($globalDBdriver == 'mysql') {
9976 10368
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10017,7 +10409,9 @@  discard block
 block discarded – undo
10017 10409
 			date_default_timezone_set($globalTimezone);
10018 10410
 			$datetime = new DateTime();
10019 10411
 			$offset = $datetime->format('P');
10020
-		} else $offset = '+00:00';
10412
+		} else {
10413
+			$offset = '+00:00';
10414
+		}
10021 10415
 
10022 10416
 		if ($globalDBdriver == 'mysql') {
10023 10417
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10064,7 +10458,9 @@  discard block
 block discarded – undo
10064 10458
 			date_default_timezone_set($globalTimezone);
10065 10459
 			$datetime = new DateTime();
10066 10460
 			$offset = $datetime->format('P');
10067
-		} else $offset = '+00:00';
10461
+		} else {
10462
+			$offset = '+00:00';
10463
+		}
10068 10464
 
10069 10465
 		if ($globalDBdriver == 'mysql') {
10070 10466
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10112,7 +10508,9 @@  discard block
 block discarded – undo
10112 10508
 			date_default_timezone_set($globalTimezone);
10113 10509
 			$datetime = new DateTime();
10114 10510
 			$offset = $datetime->format('P');
10115
-		} else $offset = '+00:00';
10511
+		} else {
10512
+			$offset = '+00:00';
10513
+		}
10116 10514
 
10117 10515
 		if ($globalDBdriver == 'mysql') {
10118 10516
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10160,7 +10558,9 @@  discard block
 block discarded – undo
10160 10558
 			date_default_timezone_set($globalTimezone);
10161 10559
 			$datetime = new DateTime($date);
10162 10560
 			$offset = $datetime->format('P');
10163
-		} else $offset = '+00:00';
10561
+		} else {
10562
+			$offset = '+00:00';
10563
+		}
10164 10564
 
10165 10565
 		if ($globalDBdriver == 'mysql') {
10166 10566
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10208,7 +10608,9 @@  discard block
 block discarded – undo
10208 10608
 			date_default_timezone_set($globalTimezone);
10209 10609
 			$datetime = new DateTime();
10210 10610
 			$offset = $datetime->format('P');
10211
-		} else $offset = '+00:00';
10611
+		} else {
10612
+			$offset = '+00:00';
10613
+		}
10212 10614
 
10213 10615
 		if ($globalDBdriver == 'mysql') {
10214 10616
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10255,7 +10657,9 @@  discard block
 block discarded – undo
10255 10657
 			date_default_timezone_set($globalTimezone);
10256 10658
 			$datetime = new DateTime();
10257 10659
 			$offset = $datetime->format('P');
10258
-		} else $offset = '+00:00';
10660
+		} else {
10661
+			$offset = '+00:00';
10662
+		}
10259 10663
 
10260 10664
 		if ($globalDBdriver == 'mysql') {
10261 10665
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10302,7 +10706,9 @@  discard block
 block discarded – undo
10302 10706
 			date_default_timezone_set($globalTimezone);
10303 10707
 			$datetime = new DateTime();
10304 10708
 			$offset = $datetime->format('P');
10305
-		} else $offset = '+00:00';
10709
+		} else {
10710
+			$offset = '+00:00';
10711
+		}
10306 10712
 
10307 10713
 		if ($globalDBdriver == 'mysql') {
10308 10714
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10352,7 +10758,9 @@  discard block
 block discarded – undo
10352 10758
 			date_default_timezone_set($globalTimezone);
10353 10759
 			$datetime = new DateTime();
10354 10760
 			$offset = $datetime->format('P');
10355
-		} else $offset = '+00:00';
10761
+		} else {
10762
+			$offset = '+00:00';
10763
+		}
10356 10764
 
10357 10765
 		if ($globalDBdriver == 'mysql') {
10358 10766
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10399,7 +10807,9 @@  discard block
 block discarded – undo
10399 10807
 			date_default_timezone_set($globalTimezone);
10400 10808
 			$datetime = new DateTime();
10401 10809
 			$offset = $datetime->format('P');
10402
-		} else $offset = '+00:00';
10810
+		} else {
10811
+			$offset = '+00:00';
10812
+		}
10403 10813
 
10404 10814
 		if ($globalDBdriver == 'mysql') {
10405 10815
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10610,8 +11020,11 @@  discard block
 block discarded – undo
10610 11020
 				$query_values = array_merge($query_values,array(':month' => $month));
10611 11021
 			}
10612 11022
 		}
10613
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
10614
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11023
+		if (empty($query_values)) {
11024
+			$queryi .= $this->getFilter($filters);
11025
+		} else {
11026
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11027
+		}
10615 11028
 		
10616 11029
 		//echo $query;
10617 11030
 		$sth = $this->db->prepare($queryi);
@@ -10690,8 +11103,11 @@  discard block
 block discarded – undo
10690 11103
 				$query_values = array_merge($query_values,array(':month' => $month));
10691 11104
 			}
10692 11105
 		}
10693
-                if ($query == '') $queryi .= $this->getFilter($filters);
10694
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11106
+                if ($query == '') {
11107
+                	$queryi .= $this->getFilter($filters);
11108
+                } else {
11109
+                	$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11110
+                }
10695 11111
 
10696 11112
 
10697 11113
 		$sth = $this->db->prepare($queryi);
@@ -10714,7 +11130,9 @@  discard block
 block discarded – undo
10714 11130
 			date_default_timezone_set($globalTimezone);
10715 11131
 			$datetime = new DateTime();
10716 11132
 			$offset = $datetime->format('P');
10717
-		} else $offset = '+00:00';
11133
+		} else {
11134
+			$offset = '+00:00';
11135
+		}
10718 11136
 
10719 11137
 		if ($globalDBdriver == 'mysql') {
10720 11138
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10900,7 +11318,9 @@  discard block
 block discarded – undo
10900 11318
 	*/
10901 11319
 	public function parseDirection($direction = 0)
10902 11320
 	{
10903
-		if ($direction == '') $direction = 0;
11321
+		if ($direction == '') {
11322
+			$direction = 0;
11323
+		}
10904 11324
 		$direction_array = array();
10905 11325
 		$temp_array = array();
10906 11326
 
@@ -11001,7 +11421,9 @@  discard block
 block discarded – undo
11001 11421
 		if (isset($result->AirlineFlightInfoResult))
11002 11422
 		{
11003 11423
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
11004
-		} else return '';
11424
+		} else {
11425
+			return '';
11426
+		}
11005 11427
 		
11006 11428
 		$registration = $this->convertAircraftRegistration($registration);
11007 11429
 		
@@ -11030,7 +11452,9 @@  discard block
 block discarded – undo
11030 11452
 		if (count($row) > 0) {
11031 11453
 		    //return $row['Registration'];
11032 11454
 		    return $row['registration'];
11033
-		} else return '';
11455
+		} else {
11456
+			return '';
11457
+		}
11034 11458
 	
11035 11459
 	}
11036 11460
 
@@ -11053,9 +11477,14 @@  discard block
 block discarded – undo
11053 11477
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11054 11478
 		$sth->closeCursor();
11055 11479
 		if (count($row) > 0) {
11056
-		    if ($row['type_flight'] == null) return '';
11057
-		    else return $row['type_flight'];
11058
-		} else return '';
11480
+		    if ($row['type_flight'] == null) {
11481
+		    	return '';
11482
+		    } else {
11483
+		    	return $row['type_flight'];
11484
+		    }
11485
+		} else {
11486
+			return '';
11487
+		}
11059 11488
 	
11060 11489
 	}
11061 11490
 
@@ -11073,7 +11502,9 @@  discard block
 block discarded – undo
11073 11502
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11074 11503
 	
11075 11504
 		$Connection = new Connection($this->db);
11076
-		if (!$Connection->tableExists('countries')) return '';
11505
+		if (!$Connection->tableExists('countries')) {
11506
+			return '';
11507
+		}
11077 11508
 	
11078 11509
 		try {
11079 11510
 			/*
@@ -11093,9 +11524,13 @@  discard block
 block discarded – undo
11093 11524
 			$sth->closeCursor();
11094 11525
 			if (count($row) > 0) {
11095 11526
 				return $row;
11096
-			} else return '';
11527
+			} else {
11528
+				return '';
11529
+			}
11097 11530
 		} catch (PDOException $e) {
11098
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
11531
+			if (isset($globalDebug) && $globalDebug) {
11532
+				echo 'Error : '.$e->getMessage()."\n";
11533
+			}
11099 11534
 			return '';
11100 11535
 		}
11101 11536
 	
@@ -11113,7 +11548,9 @@  discard block
 block discarded – undo
11113 11548
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11114 11549
 	
11115 11550
 		$Connection = new Connection($this->db);
11116
-		if (!$Connection->tableExists('countries')) return '';
11551
+		if (!$Connection->tableExists('countries')) {
11552
+			return '';
11553
+		}
11117 11554
 	
11118 11555
 		try {
11119 11556
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -11125,9 +11562,13 @@  discard block
 block discarded – undo
11125 11562
 			$sth->closeCursor();
11126 11563
 			if (count($row) > 0) {
11127 11564
 				return $row;
11128
-			} else return '';
11565
+			} else {
11566
+				return '';
11567
+			}
11129 11568
 		} catch (PDOException $e) {
11130
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
11569
+			if (isset($globalDebug) && $globalDebug) {
11570
+				echo 'Error : '.$e->getMessage()."\n";
11571
+			}
11131 11572
 			return '';
11132 11573
 		}
11133 11574
 	
@@ -11377,7 +11818,9 @@  discard block
 block discarded – undo
11377 11818
 	{
11378 11819
 		global $globalBitlyAccessToken;
11379 11820
 		
11380
-		if ($globalBitlyAccessToken == '') return $url;
11821
+		if ($globalBitlyAccessToken == '') {
11822
+			return $url;
11823
+		}
11381 11824
         
11382 11825
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
11383 11826
 		
@@ -11526,7 +11969,9 @@  discard block
 block discarded – undo
11526 11969
 		
11527 11970
 
11528 11971
 		// routes
11529
-		if ($globalDebug) print "Routes...\n";
11972
+		if ($globalDebug) {
11973
+			print "Routes...\n";
11974
+		}
11530 11975
 		if ($globalDBdriver == 'mysql') {
11531 11976
 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
11532 11977
 		} else {
@@ -11545,7 +11990,9 @@  discard block
 block discarded – undo
11545 11990
 			}
11546 11991
 		}
11547 11992
 		
11548
-		if ($globalDebug) print "Airlines...\n";
11993
+		if ($globalDebug) {
11994
+			print "Airlines...\n";
11995
+		}
11549 11996
 		//airlines
11550 11997
 		if ($globalDBdriver == 'mysql') {
11551 11998
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
@@ -11559,10 +12006,15 @@  discard block
 block discarded – undo
11559 12006
 			if (is_numeric(substr($row['ident'], -1, 1)))
11560 12007
 			{
11561 12008
 				$fromsource = NULL;
11562
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
11563
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
11564
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
11565
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12009
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
12010
+					$fromsource = 'vatsim';
12011
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
12012
+					$fromsource = 'ivao';
12013
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
12014
+					$fromsource = 'vatsim';
12015
+				} elseif (isset($globalIVAO) && $globalIVAO) {
12016
+					$fromsource = 'ivao';
12017
+				}
11566 12018
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
11567 12019
 				if (isset($airline_array[0]['name'])) {
11568 12020
 					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
@@ -11572,13 +12024,17 @@  discard block
 block discarded – undo
11572 12024
 			}
11573 12025
 		}
11574 12026
 
11575
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
12027
+		if ($globalDebug) {
12028
+			print "Remove Duplicate in aircraft_modes...\n";
12029
+		}
11576 12030
 		//duplicate modes
11577 12031
 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL";
11578 12032
 		$sth = $this->db->prepare($query);
11579 12033
 		$sth->execute();
11580 12034
 		
11581
-		if ($globalDebug) print "Aircraft...\n";
12035
+		if ($globalDebug) {
12036
+			print "Aircraft...\n";
12037
+		}
11582 12038
 		//aircraft
11583 12039
 		if ($globalDBdriver == 'mysql') {
11584 12040
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -11621,26 +12077,38 @@  discard block
 block discarded – undo
11621 12077
 				 if (isset($closestAirports[0])) {
11622 12078
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
11623 12079
 						$airport_icao = $closestAirports[0]['icao'];
11624
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12080
+						if ($globalDebug) {
12081
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12082
+						}
11625 12083
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
11626 12084
 						foreach ($closestAirports as $airport) {
11627 12085
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
11628 12086
 								$airport_icao = $airport['icao'];
11629
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12087
+								if ($globalDebug) {
12088
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12089
+								}
11630 12090
 								break;
11631 12091
 							}
11632 12092
 						}
11633 12093
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
11634 12094
 						$airport_icao = $closestAirports[0]['icao'];
11635
-						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12095
+						if ($globalDebug) {
12096
+							echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12097
+						}
11636 12098
 					} else {
11637
-						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12099
+						if ($globalDebug) {
12100
+							echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12101
+						}
11638 12102
 					}
11639 12103
 				} else {
11640
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12104
+					if ($globalDebug) {
12105
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12106
+					}
11641 12107
 				}
11642 12108
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
11643
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12109
+					if ($globalDebug) {
12110
+						echo "Updating airport to ".$airport_icao."...\n";
12111
+					}
11644 12112
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
11645 12113
 					$sthu = $this->db->prepare($update_query);
11646 12114
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.