Completed
Push — master ( 150320...f1741a )
by Yannick
10:41
created
require/class.Spotter.php 1 patch
Braces   +735 added lines, -257 removed lines patch added patch discarded remove patch
@@ -72,7 +72,9 @@  discard block
 block discarded – undo
72 72
 		if (isset($filter[0]['source'])) {
73 73
 			$filters = array_merge($filters,$filter);
74 74
 		}
75
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
75
+		if (is_array($globalFilter)) {
76
+			$filter = array_merge($filter,$globalFilter);
77
+		}
76 78
 		$filter_query_join = '';
77 79
 		$filter_query_where = '';
78 80
 		foreach($filters as $flt) {
@@ -156,8 +158,11 @@  discard block
 block discarded – undo
156 158
 				$filter_query_where .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
157 159
 			}
158 160
 		}
159
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
160
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
161
+		if ($filter_query_where == '' && $where) {
162
+			$filter_query_where = ' WHERE';
163
+		} elseif ($filter_query_where != '' && $and) {
164
+			$filter_query_where .= ' AND';
165
+		}
161 166
 		if ($filter_query_where != '') {
162 167
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
163 168
 		}
@@ -180,10 +185,18 @@  discard block
 block discarded – undo
180 185
 		$Image = new Image($this->db);
181 186
 		$Schedule = new Schedule($this->db);
182 187
 		$ACARS = new ACARS($this->db);
183
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
184
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
185
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
186
-		if (!isset($globalVAM)) $globalVAM = FALSE;
188
+		if (!isset($globalIVAO)) {
189
+			$globalIVAO = FALSE;
190
+		}
191
+		if (!isset($globalVATSIM)) {
192
+			$globalVATSIM = FALSE;
193
+		}
194
+		if (!isset($globalphpVMS)) {
195
+			$globalphpVMS = FALSE;
196
+		}
197
+		if (!isset($globalVAM)) {
198
+			$globalVAM = FALSE;
199
+		}
187 200
 		date_default_timezone_set('UTC');
188 201
 		
189 202
 		if (!is_string($query))
@@ -230,21 +243,35 @@  discard block
 block discarded – undo
230 243
 			} else {
231 244
 				$temp_array['spotter_id'] = '';
232 245
 			}
233
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
234
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
246
+			if (isset($row['flightaware_id'])) {
247
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
248
+			}
249
+			if (isset($row['modes'])) {
250
+				$temp_array['modes'] = $row['modes'];
251
+			}
235 252
 			$temp_array['ident'] = $row['ident'];
236 253
 			if (isset($row['registration']) && $row['registration'] != '') {
237 254
 				$temp_array['registration'] = $row['registration'];
238 255
 			} elseif (isset($temp_array['modes'])) {
239 256
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
240
-			} else $temp_array['registration'] = '';
241
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
257
+			} else {
258
+				$temp_array['registration'] = '';
259
+			}
260
+			if (isset($row['aircraft_icao'])) {
261
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
262
+			}
242 263
 			
243 264
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
244 265
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
245
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
246
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
247
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
266
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
267
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
268
+			}
269
+			if (isset($row['latitude'])) {
270
+				$temp_array['latitude'] = $row['latitude'];
271
+			}
272
+			if (isset($row['longitude'])) {
273
+				$temp_array['longitude'] = $row['longitude'];
274
+			}
248 275
 			/*
249 276
 			if (Connection->tableExists('countries')) {
250 277
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -254,8 +281,12 @@  discard block
 block discarded – undo
254 281
 				}
255 282
 			}
256 283
 			*/
257
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
258
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
284
+			if (isset($row['waypoints'])) {
285
+				$temp_array['waypoints'] = $row['waypoints'];
286
+			}
287
+			if (isset($row['format_source'])) {
288
+				$temp_array['format_source'] = $row['format_source'];
289
+			}
259 290
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
260 291
 				$temp_array['route_stop'] = $row['route_stop'];
261 292
 				$allroute = explode(' ',$row['route_stop']);
@@ -271,13 +302,19 @@  discard block
 block discarded – undo
271 302
 					}
272 303
 				}
273 304
 			}
274
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
305
+			if (isset($row['altitude'])) {
306
+				$temp_array['altitude'] = $row['altitude'];
307
+			}
275 308
 			if (isset($row['heading'])) {
276 309
 				$temp_array['heading'] = $row['heading'];
277 310
 				$heading_direction = $this->parseDirection($row['heading']);
278
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
311
+				if (isset($heading_direction[0]['direction_fullname'])) {
312
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
313
+				}
314
+			}
315
+			if (isset($row['ground_speed'])) {
316
+				$temp_array['ground_speed'] = $row['ground_speed'];
279 317
 			}
280
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
281 318
 			$temp_array['image'] = "";
282 319
 			$temp_array['image_thumbnail'] = "";
283 320
 			$temp_array['image_source'] = "";
@@ -285,7 +322,9 @@  discard block
 block discarded – undo
285 322
  
286 323
 			if (isset($row['highlight'])) {
287 324
 				$temp_array['highlight'] = $row['highlight'];
288
-			} else $temp_array['highlight'] = '';
325
+			} else {
326
+				$temp_array['highlight'] = '';
327
+			}
289 328
 			
290 329
 			if (isset($row['date'])) {
291 330
 				$dateArray = $this->parseDateString($row['date']);
@@ -341,7 +380,9 @@  discard block
 block discarded – undo
341 380
 				
342 381
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
343 382
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
344
-					} else $temp_array['aircraft_shadow'] = 'default.png';
383
+					} else {
384
+						$temp_array['aircraft_shadow'] = 'default.png';
385
+					}
345 386
                                 } else {
346 387
                             		$temp_array['aircraft_shadow'] = 'default.png';
347 388
 					$temp_array['aircraft_name'] = 'N/A';
@@ -349,11 +390,17 @@  discard block
 block discarded – undo
349 390
                             	}
350 391
 			}
351 392
 			$fromsource = NULL;
352
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
353
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
354
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
355
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
356
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
393
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
394
+				$fromsource = $globalAirlinesSource;
395
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
396
+				$fromsource = 'vatsim';
397
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
398
+				$fromsource = 'ivao';
399
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
400
+				$fromsource = 'vatsim';
401
+			} elseif (isset($globalIVAO) && $globalIVAO) {
402
+				$fromsource = 'ivao';
403
+			}
357 404
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
358 405
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
359 406
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -376,12 +423,18 @@  discard block
 block discarded – undo
376 423
 				}
377 424
 			} else {
378 425
 				$temp_array['airline_icao'] = $row['airline_icao'];
379
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
380
-				else $temp_array['airline_iata'] = 'N/A';
426
+				if (isset($row['airline_iata'])) {
427
+					$temp_array['airline_iata'] = $row['airline_iata'];
428
+				} else {
429
+					$temp_array['airline_iata'] = 'N/A';
430
+				}
381 431
 				$temp_array['airline_name'] = $row['airline_name'];
382 432
 				$temp_array['airline_country'] = $row['airline_country'];
383
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
384
-				else $temp_array['airline_callsign'] = 'N/A';
433
+				if (isset($row['airline_callsign'])) {
434
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
435
+				} else {
436
+					$temp_array['airline_callsign'] = 'N/A';
437
+				}
385 438
 				$temp_array['airline_type'] = $row['airline_type'];
386 439
 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') {
387 440
 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']);
@@ -408,7 +461,9 @@  discard block
 block discarded – undo
408 461
 			}
409 462
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
410 463
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
411
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
464
+				if ($owner_info['owner'] != '') {
465
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
466
+				}
412 467
 				$temp_array['aircraft_base'] = $owner_info['base'];
413 468
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
414 469
 			}
@@ -416,9 +471,14 @@  discard block
 block discarded – undo
416 471
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
417 472
 			{
418 473
 				if ($globalIVAO) {
419
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
420
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
421
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
474
+					if (isset($temp_array['airline_icao'])) {
475
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
476
+					} else {
477
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
478
+					}
479
+				} else {
480
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
481
+				}
422 482
 				if (count($image_array) > 0) {
423 483
 					$temp_array['image'] = $image_array[0]['image'];
424 484
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -470,7 +530,9 @@  discard block
 block discarded – undo
470 530
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
471 531
 			if ($row['departure_airport_icao'] != '') {
472 532
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
473
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
533
+				if (!isset($departure_airport_array[0]['name'])) {
534
+					$departure_airport_array = $this->getAllAirportInfo('NA');
535
+				}
474 536
 			/*
475 537
 			} elseif ($row['departure_airport_name'] != '') {
476 538
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -478,7 +540,9 @@  discard block
 block discarded – undo
478 540
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
479 541
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
480 542
 			*/
481
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
543
+			} else {
544
+				$departure_airport_array = $this->getAllAirportInfo('NA');
545
+			}
482 546
 			if (isset($departure_airport_array[0]['name'])) {
483 547
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
484 548
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -498,8 +562,12 @@  discard block
 block discarded – undo
498 562
 			
499 563
 			if ($row['arrival_airport_icao'] != '') {
500 564
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
501
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
502
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
565
+				if (count($arrival_airport_array) == 0) {
566
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
567
+				}
568
+			} else {
569
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
570
+			}
503 571
 			if (isset($arrival_airport_array[0]['name'])) {
504 572
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
505 573
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -515,27 +583,45 @@  discard block
 block discarded – undo
515 583
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
516 584
 			}
517 585
 			*/
518
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
519
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
520
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
521
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
522
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
586
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
587
+				$temp_array['pilot_id'] = $row['pilot_id'];
588
+			}
589
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
590
+				$temp_array['pilot_name'] = $row['pilot_name'];
591
+			}
592
+			if (isset($row['source_name']) && $row['source_name'] != '') {
593
+				$temp_array['source_name'] = $row['source_name'];
594
+			}
595
+			if (isset($row['over_country']) && $row['over_country'] != '') {
596
+				$temp_array['over_country'] = $row['over_country'];
597
+			}
598
+			if (isset($row['distance']) && $row['distance'] != '') {
599
+				$temp_array['distance'] = $row['distance'];
600
+			}
523 601
 			if (isset($row['squawk'])) {
524 602
 				$temp_array['squawk'] = $row['squawk'];
525 603
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
526 604
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
527
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
605
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
606
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
607
+					}
528 608
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
529 609
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
530
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
531
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
610
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
611
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
612
+					}
613
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
614
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
615
+				}
532 616
 			}
533 617
     			
534 618
 			$temp_array['query_number_rows'] = $num_rows;
535 619
 			
536 620
 			$spotter_array[] = $temp_array;
537 621
 		}
538
-		if ($num_rows == 0) return array();
622
+		if ($num_rows == 0) {
623
+			return array();
624
+		}
539 625
 		$spotter_array[0]['query_number_rows'] = $num_rows;
540 626
 		return $spotter_array;
541 627
 	}	
@@ -568,7 +654,9 @@  discard block
 block discarded – undo
568 654
 				foreach ($q_array as $q_item){
569 655
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
570 656
 					$additional_query .= " AND (";
571
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
657
+					if (is_int($q_item)) {
658
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
659
+					}
572 660
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
573 661
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
574 662
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -589,7 +677,9 @@  discard block
 block discarded – undo
589 677
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
590 678
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
591 679
 					$translate = $Translation->ident2icao($q_item);
592
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
680
+					if ($translate != $q_item) {
681
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
682
+					}
593 683
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
594 684
 					$additional_query .= ")";
595 685
 				}
@@ -816,7 +906,9 @@  discard block
 block discarded – undo
816 906
 				date_default_timezone_set($globalTimezone);
817 907
 				$datetime = new DateTime();
818 908
 				$offset = $datetime->format('P');
819
-			} else $offset = '+00:00';
909
+			} else {
910
+				$offset = '+00:00';
911
+			}
820 912
 
821 913
 			if ($date_array[1] != "")
822 914
 			{
@@ -848,8 +940,12 @@  discard block
 block discarded – undo
848 940
 			{
849 941
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
850 942
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
851
-			} else $limit_query = "";
852
-		} else $limit_query = "";
943
+			} else {
944
+				$limit_query = "";
945
+			}
946
+		} else {
947
+			$limit_query = "";
948
+		}
853 949
 
854 950
 
855 951
 		if ($sort != "")
@@ -917,8 +1013,12 @@  discard block
 block discarded – undo
917 1013
 			{
918 1014
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
919 1015
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
920
-			} else $limit_query = "";
921
-		} else $limit_query = "";
1016
+			} else {
1017
+				$limit_query = "";
1018
+			}
1019
+		} else {
1020
+			$limit_query = "";
1021
+		}
922 1022
 		
923 1023
 		if ($sort != "")
924 1024
 		{
@@ -1242,7 +1342,9 @@  discard block
 block discarded – undo
1242 1342
 		global $global_query;
1243 1343
 		
1244 1344
 		date_default_timezone_set('UTC');
1245
-		if ($id == '') return array();
1345
+		if ($id == '') {
1346
+			return array();
1347
+		}
1246 1348
 		$additional_query = "spotter_output.spotter_id = :id";
1247 1349
 		$query_values = array(':id' => $id);
1248 1350
 
@@ -1357,8 +1459,11 @@  discard block
 block discarded – undo
1357 1459
 		if ($sort != "")
1358 1460
 		{
1359 1461
 			$search_orderby_array = $this->getOrderBy();
1360
-			if (isset($search_orderby_array[$sort]['sql'])) $orderby_query = $search_orderby_array[$sort]['sql'];
1361
-			else $orderby_query = " ORDER BY spotter_output.date DESC";
1462
+			if (isset($search_orderby_array[$sort]['sql'])) {
1463
+				$orderby_query = $search_orderby_array[$sort]['sql'];
1464
+			} else {
1465
+				$orderby_query = " ORDER BY spotter_output.date DESC";
1466
+			}
1362 1467
 		} else {
1363 1468
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1364 1469
 		}
@@ -1983,7 +2088,9 @@  discard block
 block discarded – undo
1983 2088
 		{
1984 2089
 			$highlight = $row['highlight'];
1985 2090
 		}
1986
-		if (isset($highlight)) return $highlight;
2091
+		if (isset($highlight)) {
2092
+			return $highlight;
2093
+		}
1987 2094
 	}
1988 2095
 
1989 2096
 	
@@ -2011,7 +2118,9 @@  discard block
 block discarded – undo
2011 2118
 		$sth->closeCursor();
2012 2119
 		if (count($row) > 0) {
2013 2120
 			return $row['usage'];
2014
-		} else return '';
2121
+		} else {
2122
+			return '';
2123
+		}
2015 2124
 	}
2016 2125
 
2017 2126
 	/**
@@ -2036,7 +2145,9 @@  discard block
 block discarded – undo
2036 2145
 		$sth->closeCursor();
2037 2146
 		if (count($row) > 0) {
2038 2147
 			return $row['icao'];
2039
-		} else return '';
2148
+		} else {
2149
+			return '';
2150
+		}
2040 2151
 	}
2041 2152
 
2042 2153
 	/**
@@ -2064,7 +2175,9 @@  discard block
 block discarded – undo
2064 2175
 			$airport_longitude = $row['longitude'];
2065 2176
 			$Common = new Common();
2066 2177
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2067
-		} else return '';
2178
+		} else {
2179
+			return '';
2180
+		}
2068 2181
 	}
2069 2182
 	
2070 2183
 	/**
@@ -2176,7 +2289,9 @@  discard block
 block discarded – undo
2176 2289
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2177 2290
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2178 2291
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2179
-		} else return array();
2292
+		} else {
2293
+			return array();
2294
+		}
2180 2295
 		if ($globalDBdriver == 'mysql') {
2181 2296
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
2182 2297
 		} else {
@@ -2211,7 +2326,9 @@  discard block
 block discarded – undo
2211 2326
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2212 2327
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2213 2328
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2214
-		} else return array();
2329
+		} else {
2330
+			return array();
2331
+		}
2215 2332
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2216 2333
 		$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.")";
2217 2334
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2246,7 +2363,9 @@  discard block
 block discarded – undo
2246 2363
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2247 2364
 	{
2248 2365
 		global $globalUseRealAirlines;
2249
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2366
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2367
+			$fromsource = NULL;
2368
+		}
2250 2369
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2251 2370
 		if ($airline_icao == 'NA') {
2252 2371
 			$airline_array = array();
@@ -2315,7 +2434,9 @@  discard block
 block discarded – undo
2315 2434
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2316 2435
 	{
2317 2436
 		global $globalUseRealAirlines;
2318
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2437
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2438
+			$fromsource = NULL;
2439
+		}
2319 2440
 		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2320 2441
 		$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";
2321 2442
 		$sth = $this->db->prepare($query);
@@ -2331,7 +2452,9 @@  discard block
 block discarded – undo
2331 2452
 			$sth->execute(array(':fromsource' => $fromsource));
2332 2453
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
2333 2454
 			$sth->closeCursor();
2334
-			if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name);
2455
+			if ($row['nb'] == 0) {
2456
+				$result = $this->getAllAirlineInfoByName($airline_name);
2457
+			}
2335 2458
 		}
2336 2459
 		return $result;
2337 2460
 	}
@@ -2394,15 +2517,20 @@  discard block
 block discarded – undo
2394 2517
 				'A320-211' => 'A320',
2395 2518
 				'747-8i' => 'B748',
2396 2519
 				'A380' => 'A388');
2397
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2520
+		if (isset($all_aircraft[$aircraft_type])) {
2521
+			return $all_aircraft[$aircraft_type];
2522
+		}
2398 2523
 
2399 2524
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2400 2525
 		$aircraft_type = strtoupper($aircraft_type);
2401 2526
 		$sth = $this->db->prepare($query);
2402 2527
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2403 2528
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2404
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2405
-		else return '';
2529
+		if (isset($result[0]['icao'])) {
2530
+			return $result[0]['icao'];
2531
+		} else {
2532
+			return '';
2533
+		}
2406 2534
 	}
2407 2535
 	
2408 2536
 	/**
@@ -2430,11 +2558,15 @@  discard block
 block discarded – undo
2430 2558
 		$sth->closeCursor();
2431 2559
 		if (isset($row['icaotypecode'])) {
2432 2560
 			$icao = $row['icaotypecode'];
2433
-			if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao];
2561
+			if (isset($this->aircraft_correct_icaotype[$icao])) {
2562
+				$icao = $this->aircraft_correct_icaotype[$icao];
2563
+			}
2434 2564
 			return $icao;
2435 2565
 		} elseif ($source_type == 'flarm') {
2436 2566
 			return $this->getAllAircraftType($aircraft_modes);
2437
-		} else  return '';
2567
+		} else {
2568
+			return '';
2569
+		}
2438 2570
 	}
2439 2571
 
2440 2572
 	/**
@@ -2457,7 +2589,9 @@  discard block
 block discarded – undo
2457 2589
 		$sth->closeCursor();
2458 2590
 		if (isset($row['icaotypecode'])) {
2459 2591
 			return $row['icaotypecode'];
2460
-		} else return '';
2592
+		} else {
2593
+			return '';
2594
+		}
2461 2595
 	}
2462 2596
 
2463 2597
 	/**
@@ -2503,7 +2637,9 @@  discard block
 block discarded – undo
2503 2637
 		$sth->closeCursor();
2504 2638
 		if (isset($row['operator_correct'])) {
2505 2639
 			return $row['operator_correct'];
2506
-		} else return $operator;
2640
+		} else {
2641
+			return $operator;
2642
+		}
2507 2643
 	}
2508 2644
 
2509 2645
 	/**
@@ -2516,7 +2652,9 @@  discard block
 block discarded – undo
2516 2652
 	public function getRouteInfo($callsign)
2517 2653
 	{
2518 2654
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2519
-                if ($callsign == '') return array();
2655
+                if ($callsign == '') {
2656
+                	return array();
2657
+                }
2520 2658
 		$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";
2521 2659
 		
2522 2660
 		$sth = $this->db->prepare($query);
@@ -2526,7 +2664,9 @@  discard block
 block discarded – undo
2526 2664
 		$sth->closeCursor();
2527 2665
 		if (count($row) > 0) {
2528 2666
 			return $row;
2529
-		} else return array();
2667
+		} else {
2668
+			return array();
2669
+		}
2530 2670
 	}
2531 2671
 	
2532 2672
 	/**
@@ -2579,7 +2719,9 @@  discard block
 block discarded – undo
2579 2719
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2580 2720
 			$sth->closeCursor();
2581 2721
 			return $result;
2582
-		} else return array();
2722
+		} else {
2723
+			return array();
2724
+		}
2583 2725
 	}
2584 2726
 	
2585 2727
   
@@ -2738,8 +2880,11 @@  discard block
 block discarded – undo
2738 2880
 		$query .= " ORDER BY spotter_output.source_name ASC";
2739 2881
 
2740 2882
 		$sth = $this->db->prepare($query);
2741
-		if (!empty($query_values)) $sth->execute($query_values);
2742
-		else $sth->execute();
2883
+		if (!empty($query_values)) {
2884
+			$sth->execute($query_values);
2885
+		} else {
2886
+			$sth->execute();
2887
+		}
2743 2888
 
2744 2889
 		$source_array = array();
2745 2890
 		$temp_array = array();
@@ -2772,9 +2917,13 @@  discard block
 block discarded – undo
2772 2917
 								WHERE spotter_output.airline_icao <> '' 
2773 2918
 								ORDER BY spotter_output.airline_name ASC";
2774 2919
 			*/
2775
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2776
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2777
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2920
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2921
+				$forsource = $globalAirlinesSource;
2922
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2923
+				$forsource = 'vatsim';
2924
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2925
+				$forsource = 'ivao';
2926
+			}
2778 2927
 			if ($forsource === NULL) {
2779 2928
 				$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";
2780 2929
 				$query_data = array();
@@ -2817,9 +2966,13 @@  discard block
 block discarded – undo
2817 2966
 	{
2818 2967
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2819 2968
 		$filter_query = $this->getFilter($filters,true,true);
2820
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2821
-		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2822
-		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2969
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2970
+			$forsource = $globalAirlinesSource;
2971
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
2972
+			$forsource = 'vatsim';
2973
+		} elseif (isset($globalIVAO) && $globalIVAO) {
2974
+			$forsource = 'ivao';
2975
+		}
2823 2976
 		if ($forsource === NULL) {
2824 2977
 			$query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC";
2825 2978
 			$query_data = array();
@@ -3130,7 +3283,9 @@  discard block
 block discarded – undo
3130 3283
 			date_default_timezone_set($globalTimezone);
3131 3284
 			$datetime = new DateTime();
3132 3285
 			$offset = $datetime->format('P');
3133
-		} else $offset = '+00:00';
3286
+		} else {
3287
+			$offset = '+00:00';
3288
+		}
3134 3289
 		if ($airport_icao == '') {
3135 3290
 			if ($globalDBdriver == 'mysql') {
3136 3291
 				$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";
@@ -3162,7 +3317,9 @@  discard block
 block discarded – undo
3162 3317
 			date_default_timezone_set($globalTimezone);
3163 3318
 			$datetime = new DateTime();
3164 3319
 			$offset = $datetime->format('P');
3165
-		} else $offset = '+00:00';
3320
+		} else {
3321
+			$offset = '+00:00';
3322
+		}
3166 3323
 		if ($airport_icao == '') {
3167 3324
 			if ($globalDBdriver == 'mysql') {
3168 3325
 				$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";
@@ -3195,7 +3352,9 @@  discard block
 block discarded – undo
3195 3352
 			date_default_timezone_set($globalTimezone);
3196 3353
 			$datetime = new DateTime();
3197 3354
 			$offset = $datetime->format('P');
3198
-		} else $offset = '+00:00';
3355
+		} else {
3356
+			$offset = '+00:00';
3357
+		}
3199 3358
 		if ($airport_icao == '') {
3200 3359
 			if ($globalDBdriver == 'mysql') {
3201 3360
 				$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 
@@ -3234,7 +3393,9 @@  discard block
 block discarded – undo
3234 3393
 			date_default_timezone_set($globalTimezone);
3235 3394
 			$datetime = new DateTime();
3236 3395
 			$offset = $datetime->format('P');
3237
-		} else $offset = '+00:00';
3396
+		} else {
3397
+			$offset = '+00:00';
3398
+		}
3238 3399
 		if ($airport_icao == '') {
3239 3400
 			if ($globalDBdriver == 'mysql') {
3240 3401
 				$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 
@@ -3279,7 +3440,9 @@  discard block
 block discarded – undo
3279 3440
 			date_default_timezone_set($globalTimezone);
3280 3441
 			$datetime = new DateTime();
3281 3442
 			$offset = $datetime->format('P');
3282
-		} else $offset = '+00:00';
3443
+		} else {
3444
+			$offset = '+00:00';
3445
+		}
3283 3446
 		if ($airport_icao == '') {
3284 3447
 			if ($globalDBdriver == 'mysql') {
3285 3448
 				$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";
@@ -3314,7 +3477,9 @@  discard block
 block discarded – undo
3314 3477
 			date_default_timezone_set($globalTimezone);
3315 3478
 			$datetime = new DateTime();
3316 3479
 			$offset = $datetime->format('P');
3317
-		} else $offset = '+00:00';
3480
+		} else {
3481
+			$offset = '+00:00';
3482
+		}
3318 3483
 		if ($airport_icao == '') {
3319 3484
 			if ($globalDBdriver == 'mysql') {
3320 3485
 				$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 
@@ -3356,7 +3521,9 @@  discard block
 block discarded – undo
3356 3521
 			date_default_timezone_set($globalTimezone);
3357 3522
 			$datetime = new DateTime();
3358 3523
 			$offset = $datetime->format('P');
3359
-		} else $offset = '+00:00';
3524
+		} else {
3525
+			$offset = '+00:00';
3526
+		}
3360 3527
 		if ($airport_icao == '') {
3361 3528
 			if ($globalDBdriver == 'mysql') {
3362 3529
 				$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";
@@ -3390,7 +3557,9 @@  discard block
 block discarded – undo
3390 3557
 			date_default_timezone_set($globalTimezone);
3391 3558
 			$datetime = new DateTime();
3392 3559
 			$offset = $datetime->format('P');
3393
-		} else $offset = '+00:00';
3560
+		} else {
3561
+			$offset = '+00:00';
3562
+		}
3394 3563
 		if ($airport_icao == '') {
3395 3564
 			if ($globalDBdriver == 'mysql') {
3396 3565
 				$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 
@@ -3438,7 +3607,9 @@  discard block
 block discarded – undo
3438 3607
 			date_default_timezone_set($globalTimezone);
3439 3608
 			$datetime = new DateTime();
3440 3609
 			$offset = $datetime->format('P');
3441
-		} else $offset = '+00:00';
3610
+		} else {
3611
+			$offset = '+00:00';
3612
+		}
3442 3613
 
3443 3614
 		if ($globalDBdriver == 'mysql') {
3444 3615
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3558,7 +3729,9 @@  discard block
 block discarded – undo
3558 3729
 	*/	
3559 3730
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3560 3731
 	{
3561
-		if ($groundspeed == '') $groundspeed = NULL;
3732
+		if ($groundspeed == '') {
3733
+			$groundspeed = NULL;
3734
+		}
3562 3735
 		$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';
3563 3736
                 $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);
3564 3737
 
@@ -3608,10 +3781,18 @@  discard block
 block discarded – undo
3608 3781
 		$Image = new Image($this->db);
3609 3782
 		$Common = new Common();
3610 3783
 		
3611
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3612
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3613
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3614
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3784
+		if (!isset($globalIVAO)) {
3785
+			$globalIVAO = FALSE;
3786
+		}
3787
+		if (!isset($globalVATSIM)) {
3788
+			$globalVATSIM = FALSE;
3789
+		}
3790
+		if (!isset($globalphpVMS)) {
3791
+			$globalphpVMS = FALSE;
3792
+		}
3793
+		if (!isset($globalVAM)) {
3794
+			$globalVAM = FALSE;
3795
+		}
3615 3796
 		date_default_timezone_set('UTC');
3616 3797
 		
3617 3798
 		//getting the registration
@@ -3624,23 +3805,33 @@  discard block
 block discarded – undo
3624 3805
 				if ($ModeS != '') {
3625 3806
 					$timeelapsed = microtime(true);
3626 3807
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type);
3627
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3808
+					if ($globalDebugTimeElapsed) {
3809
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3810
+					}
3628 3811
 				} else {
3629 3812
 					$myhex = explode('-',$flightaware_id);
3630 3813
 					if (count($myhex) > 0) {
3631 3814
 						$timeelapsed = microtime(true);
3632 3815
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type);
3633
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3816
+						if ($globalDebugTimeElapsed) {
3817
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3818
+						}
3634 3819
 					}
3635 3820
 				}
3636 3821
 			}
3637 3822
 		}
3638 3823
 		$fromsource = NULL;
3639
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3640
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3641
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3642
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3643
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3824
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3825
+			$fromsource = $globalAirlinesSource;
3826
+		} elseif ($format_source == 'vatsimtxt') {
3827
+			$fromsource = 'vatsim';
3828
+		} elseif ($format_source == 'whazzup') {
3829
+			$fromsource = 'ivao';
3830
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3831
+			$fromsource = 'vatsim';
3832
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3833
+			$fromsource = 'ivao';
3834
+		}
3644 3835
 		//getting the airline information
3645 3836
 		if ($ident != "")
3646 3837
 		{
@@ -3664,15 +3855,21 @@  discard block
 block discarded – undo
3664 3855
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3665 3856
 						$airline_array = $this->getAllAirlineInfo("NA");
3666 3857
 					}
3667
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3858
+					if ($globalDebugTimeElapsed) {
3859
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3860
+					}
3668 3861
 
3669 3862
 				} else {
3670 3863
 					$timeelapsed = microtime(true);
3671 3864
 					$airline_array = $this->getAllAirlineInfo("NA");
3672
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3865
+					if ($globalDebugTimeElapsed) {
3866
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3867
+					}
3673 3868
 				}
3674 3869
 			}
3675
-		} else $airline_array = array();
3870
+		} else {
3871
+			$airline_array = array();
3872
+		}
3676 3873
 		
3677 3874
 		//getting the aircraft information
3678 3875
 		$aircraft_array = array();
@@ -3686,27 +3883,37 @@  discard block
 block discarded – undo
3686 3883
 				{
3687 3884
 					$timeelapsed = microtime(true);
3688 3885
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3689
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3886
+					if ($globalDebugTimeElapsed) {
3887
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3888
+					}
3690 3889
 				} else {
3691 3890
 					$timeelapsed = microtime(true);
3692 3891
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3693
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3892
+					if ($globalDebugTimeElapsed) {
3893
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3894
+					}
3694 3895
 				}
3695 3896
 			}
3696 3897
 		} else {
3697 3898
 			if ($ModeS != '') {
3698 3899
 				$timeelapsed = microtime(true);
3699 3900
 				$aircraft_icao = $this->getAllAircraftType($ModeS,$source_type);
3700
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3901
+				if ($globalDebugTimeElapsed) {
3902
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3903
+				}
3701 3904
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3702 3905
 				{
3703 3906
 					$timeelapsed = microtime(true);
3704 3907
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3705
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3908
+					if ($globalDebugTimeElapsed) {
3909
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3910
+					}
3706 3911
 				} else {
3707 3912
 					$timeelapsed = microtime(true);
3708 3913
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3709
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3914
+					if ($globalDebugTimeElapsed) {
3915
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3916
+					}
3710 3917
 				}
3711 3918
 			}
3712 3919
 		}
@@ -3722,7 +3929,9 @@  discard block
 block discarded – undo
3722 3929
 			} else {
3723 3930
 				$timeelapsed = microtime(true);
3724 3931
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3725
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3932
+				if ($globalDebugTimeElapsed) {
3933
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3934
+				}
3726 3935
 			}
3727 3936
 		}
3728 3937
 		
@@ -3737,7 +3946,9 @@  discard block
 block discarded – undo
3737 3946
 			} else {
3738 3947
 				$timeelapsed = microtime(true);
3739 3948
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3740
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3949
+				if ($globalDebugTimeElapsed) {
3950
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3951
+				}
3741 3952
 			}
3742 3953
 		}
3743 3954
 
@@ -3771,7 +3982,9 @@  discard block
 block discarded – undo
3771 3982
 			{
3772 3983
 				return false;
3773 3984
 			}
3774
-		} else $altitude = 0;
3985
+		} else {
3986
+			$altitude = 0;
3987
+		}
3775 3988
 		
3776 3989
 		if ($heading != "")
3777 3990
 		{
@@ -3800,7 +4013,9 @@  discard block
 block discarded – undo
3800 4013
 		{
3801 4014
 			$timeelapsed = microtime(true);
3802 4015
 			$image_array = $Image->getSpotterImage($registration);
3803
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4016
+			if ($globalDebugTimeElapsed) {
4017
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4018
+			}
3804 4019
 			if (!isset($image_array[0]['registration']))
3805 4020
 			{
3806 4021
 				//echo "Add image !!!! \n";
@@ -3808,14 +4023,21 @@  discard block
 block discarded – undo
3808 4023
 			}
3809 4024
 			$timeelapsed = microtime(true);
3810 4025
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3811
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3812
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
4026
+			if ($globalDebugTimeElapsed) {
4027
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4028
+			}
4029
+			if ($owner_info['owner'] != '') {
4030
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
4031
+			}
3813 4032
 		}
3814 4033
     
3815 4034
 		if ($globalIVAO && $aircraft_icao != '')
3816 4035
 		{
3817
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
-            		else $airline_icao = '';
4036
+            		if (isset($airline_array[0]['icao'])) {
4037
+            			$airline_icao = $airline_array[0]['icao'];
4038
+            		} else {
4039
+            			$airline_icao = '';
4040
+            		}
3819 4041
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3820 4042
 			if (!isset($image_array[0]['registration']))
3821 4043
 			{
@@ -3860,16 +4082,28 @@  discard block
 block discarded – undo
3860 4082
                 {
3861 4083
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3862 4084
                 }
3863
-                if ($registration == '') $registration = 'NA';
4085
+                if ($registration == '') {
4086
+                	$registration = 'NA';
4087
+                }
3864 4088
                 if ($latitude == '' && $longitude == '') {
3865 4089
             		$latitude = 0;
3866 4090
             		$longitude = 0;
3867 4091
             	}
3868
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
4092
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
4093
+                	$squawk = NULL;
4094
+                }
4095
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
4096
+                	$verticalrate = NULL;
4097
+                }
4098
+                if ($heading == '' || $Common->isInteger($heading) === false) {
4099
+                	$heading = 0;
4100
+                }
4101
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
4102
+                	$groundspeed = 0;
4103
+                }
4104
+                if (!isset($aircraft_owner)) {
4105
+                	$aircraft_owner = NULL;
4106
+                }
3873 4107
                 $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) 
3874 4108
                 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)";
3875 4109
 
@@ -3880,9 +4114,13 @@  discard block
 block discarded – undo
3880 4114
 		if ($airline_type == '') {
3881 4115
 			$timeelapsed = microtime(true);
3882 4116
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4117
+			if ($globalDebugTimeElapsed) {
4118
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4119
+			}
4120
+		}
4121
+		if ($airline_type == null) {
4122
+			$airline_type = '';
3884 4123
 		}
3885
-		if ($airline_type == null) $airline_type = '';
3886 4124
                 $aircraft_type = $aircraft_array[0]['type'];
3887 4125
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888 4126
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -4046,7 +4284,9 @@  discard block
 block discarded – undo
4046 4284
 			}
4047 4285
 		}
4048 4286
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
4049
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4287
+		if ($limit) {
4288
+			$query .= " LIMIT 10 OFFSET 0";
4289
+		}
4050 4290
 
4051 4291
 		$sth = $this->db->prepare($query);
4052 4292
 		$sth->execute($query_values);
@@ -4119,7 +4359,9 @@  discard block
 block discarded – undo
4119 4359
 		}
4120 4360
 		
4121 4361
 		$query .= " GROUP BY spotter_output.pilot_id,s.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4122
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4362
+		if ($limit) {
4363
+			$query .= " LIMIT 10 OFFSET 0";
4364
+		}
4123 4365
       
4124 4366
 		
4125 4367
 		$sth = $this->db->prepare($query);
@@ -4163,7 +4405,9 @@  discard block
 block discarded – undo
4163 4405
 			}
4164 4406
 		}
4165 4407
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4166
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4408
+		if ($limit) {
4409
+			$query .= " LIMIT 10 OFFSET 0";
4410
+		}
4167 4411
       
4168 4412
 		
4169 4413
 		$sth = $this->db->prepare($query);
@@ -4239,7 +4483,9 @@  discard block
 block discarded – undo
4239 4483
 			}
4240 4484
 		}
4241 4485
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
4242
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4486
+		if ($limit) {
4487
+			$query .= " LIMIT 10 OFFSET 0";
4488
+		}
4243 4489
 		
4244 4490
 		$sth = $this->db->prepare($query);
4245 4491
 		$sth->execute($query_values);
@@ -4281,7 +4527,9 @@  discard block
 block discarded – undo
4281 4527
 			}
4282 4528
 		}
4283 4529
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
4284
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4530
+		if ($limit) {
4531
+			$query .= " LIMIT 10 OFFSET 0";
4532
+		}
4285 4533
       
4286 4534
 		
4287 4535
 		$sth = $this->db->prepare($query);
@@ -4525,7 +4773,9 @@  discard block
 block discarded – undo
4525 4773
 			date_default_timezone_set($globalTimezone);
4526 4774
 			$datetime = new DateTime($date);
4527 4775
 			$offset = $datetime->format('P');
4528
-		} else $offset = '+00:00';
4776
+		} else {
4777
+			$offset = '+00:00';
4778
+		}
4529 4779
 
4530 4780
 		if ($globalDBdriver == 'mysql') {
4531 4781
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4573,7 +4823,9 @@  discard block
 block discarded – undo
4573 4823
 			date_default_timezone_set($globalTimezone);
4574 4824
 			$datetime = new DateTime($date);
4575 4825
 			$offset = $datetime->format('P');
4576
-		} else $offset = '+00:00';
4826
+		} else {
4827
+			$offset = '+00:00';
4828
+		}
4577 4829
 		
4578 4830
 		if ($globalDBdriver == 'mysql') {
4579 4831
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4693,9 +4945,13 @@  discard block
 block discarded – undo
4693 4945
 		$sth = $this->db->prepare($query);
4694 4946
 		$sth->execute($query_values);
4695 4947
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4696
-		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4697
-		elseif ($result[0]['duration'] == '') return 0;
4698
-		else return $result[0]['duration'];
4948
+		if (is_numeric($result[0]['duration'])) {
4949
+			return gmdate('H:i:s',$result[0]['duration']);
4950
+		} elseif ($result[0]['duration'] == '') {
4951
+			return 0;
4952
+		} else {
4953
+			return $result[0]['duration'];
4954
+		}
4699 4955
 	}
4700 4956
 
4701 4957
 	/**
@@ -4784,8 +5040,11 @@  discard block
 block discarded – undo
4784 5040
 		$sth = $this->db->prepare($query);
4785 5041
 		$sth->execute($query_values);
4786 5042
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4787
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4788
-		else return $result[0]['duration'];
5043
+		if (is_int($result[0]['duration'])) {
5044
+			return gmdate('H:i:s',$result[0]['duration']);
5045
+		} else {
5046
+			return $result[0]['duration'];
5047
+		}
4789 5048
 	}
4790 5049
 
4791 5050
 	/**
@@ -4990,7 +5249,9 @@  discard block
 block discarded – undo
4990 5249
 		}
4991 5250
 		$query .= " GROUP BY spotter_output.airline_country, countries.iso3
4992 5251
 					ORDER BY airline_country_count DESC";
4993
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5252
+		if ($limit) {
5253
+			$query .= " LIMIT 10 OFFSET 0";
5254
+		}
4994 5255
       
4995 5256
 		$sth = $this->db->prepare($query);
4996 5257
 		$sth->execute($query_values);
@@ -5019,7 +5280,9 @@  discard block
 block discarded – undo
5019 5280
 		global $globalDBdriver;
5020 5281
 		//$filter_query = $this->getFilter($filters,true,true);
5021 5282
 		$Connection= new Connection($this->db);
5022
-		if (!$Connection->tableExists('countries')) return array();
5283
+		if (!$Connection->tableExists('countries')) {
5284
+			return array();
5285
+		}
5023 5286
 		/*
5024 5287
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
5025 5288
 					FROM countries c, spotter_output s
@@ -5051,7 +5314,9 @@  discard block
 block discarded – undo
5051 5314
 		}
5052 5315
 		$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 ";
5053 5316
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
5054
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5317
+		if ($limit) {
5318
+			$query .= " LIMIT 10 OFFSET 0";
5319
+		}
5055 5320
       
5056 5321
 		
5057 5322
 		$sth = $this->db->prepare($query);
@@ -5128,7 +5393,9 @@  discard block
 block discarded – undo
5128 5393
 		}
5129 5394
 
5130 5395
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5131
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5396
+		if ($limit) {
5397
+			$query .= " LIMIT 10 OFFSET 0";
5398
+		}
5132 5399
  
5133 5400
 		$sth = $this->db->prepare($query);
5134 5401
 		$sth->execute($query_values);
@@ -5202,7 +5469,9 @@  discard block
 block discarded – undo
5202 5469
 		}
5203 5470
 
5204 5471
 		$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";
5205
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5472
+		if ($limit) {
5473
+			$query .= " LIMIT 10 OFFSET 0";
5474
+		}
5206 5475
  
5207 5476
 		$sth = $this->db->prepare($query);
5208 5477
 		$sth->execute($query_values);
@@ -5249,7 +5518,9 @@  discard block
 block discarded – undo
5249 5518
 		}
5250 5519
 
5251 5520
 		$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";
5252
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5521
+		if ($limit) {
5522
+			$query .= " LIMIT 10 OFFSET 0";
5523
+		}
5253 5524
  
5254 5525
 		$sth = $this->db->prepare($query);
5255 5526
 		$sth->execute();
@@ -5302,7 +5573,9 @@  discard block
 block discarded – undo
5302 5573
 			if($row['registration'] != "")
5303 5574
 			{
5304 5575
 				$image_array = $Image->getSpotterImage($row['registration']);
5305
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5576
+				if (isset($image_array[0]['image_thumbnail'])) {
5577
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5578
+				}
5306 5579
 			}
5307 5580
 			$temp_array['registration_count'] = $row['registration_count'];
5308 5581
 
@@ -5377,7 +5650,9 @@  discard block
 block discarded – undo
5377 5650
 			if($row['registration'] != "")
5378 5651
 			{
5379 5652
 				$image_array = $Image->getSpotterImage($row['registration']);
5380
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5653
+				if (isset($image_array[0]['image_thumbnail'])) {
5654
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5655
+				}
5381 5656
 			}
5382 5657
 			$temp_array['registration_count'] = $row['registration_count'];
5383 5658
 
@@ -5484,7 +5759,9 @@  discard block
 block discarded – undo
5484 5759
 			if($row['registration'] != "")
5485 5760
 			{
5486 5761
 				$image_array = $Image->getSpotterImage($row['registration']);
5487
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5762
+				if (isset($image_array[0]['image_thumbnail'])) {
5763
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5764
+				}
5488 5765
 			}
5489 5766
 			$temp_array['registration_count'] = $row['registration_count'];
5490 5767
 			$aircraft_array[] = $temp_array;
@@ -5609,7 +5886,9 @@  discard block
 block discarded – undo
5609 5886
 			date_default_timezone_set($globalTimezone);
5610 5887
 			$datetime = new DateTime($date);
5611 5888
 			$offset = $datetime->format('P');
5612
-		} else $offset = '+00:00';
5889
+		} else {
5890
+			$offset = '+00:00';
5891
+		}
5613 5892
 
5614 5893
 		if ($globalDBdriver == 'mysql') {
5615 5894
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -5656,7 +5935,9 @@  discard block
 block discarded – undo
5656 5935
 			date_default_timezone_set($globalTimezone);
5657 5936
 			$datetime = new DateTime($date);
5658 5937
 			$offset = $datetime->format('P');
5659
-		} else $offset = '+00:00';
5938
+		} else {
5939
+			$offset = '+00:00';
5940
+		}
5660 5941
 
5661 5942
 		if ($globalDBdriver == 'mysql') {
5662 5943
 			$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 
@@ -5685,7 +5966,9 @@  discard block
 block discarded – undo
5685 5966
 			if($row['registration'] != "")
5686 5967
 			{
5687 5968
 				$image_array = $Image->getSpotterImage($row['registration']);
5688
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5969
+				if (isset($image_array[0]['image_thumbnail'])) {
5970
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5971
+				}
5689 5972
 			}
5690 5973
 			$temp_array['registration_count'] = $row['registration_count'];
5691 5974
  
@@ -5710,7 +5993,9 @@  discard block
 block discarded – undo
5710 5993
 			date_default_timezone_set($globalTimezone);
5711 5994
 			$datetime = new DateTime($date);
5712 5995
 			$offset = $datetime->format('P');
5713
-		} else $offset = '+00:00';
5996
+		} else {
5997
+			$offset = '+00:00';
5998
+		}
5714 5999
 
5715 6000
 		if ($globalDBdriver == 'mysql') {
5716 6001
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5906,8 +6191,11 @@  discard block
 block discarded – undo
5906 6191
 			if($row['registration'] != "")
5907 6192
 			{
5908 6193
 				$image_array = $Image->getSpotterImage($row['registration']);
5909
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5910
-				else $temp_array['image_thumbnail'] = '';
6194
+				if (isset($image_array[0]['image_thumbnail'])) {
6195
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6196
+				} else {
6197
+					$temp_array['image_thumbnail'] = '';
6198
+				}
5911 6199
 			}
5912 6200
 			$temp_array['registration_count'] = $row['registration_count'];
5913 6201
 			$aircraft_array[] = $temp_array;
@@ -5981,8 +6269,11 @@  discard block
 block discarded – undo
5981 6269
 			if($row['registration'] != "")
5982 6270
 			{
5983 6271
 				$image_array = $Image->getSpotterImage($row['registration']);
5984
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5985
-				else $temp_array['image_thumbnail'] = '';
6272
+				if (isset($image_array[0]['image_thumbnail'])) {
6273
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6274
+				} else {
6275
+					$temp_array['image_thumbnail'] = '';
6276
+				}
5986 6277
 			}
5987 6278
 			$temp_array['registration_count'] = $row['registration_count'];
5988 6279
 			$aircraft_array[] = $temp_array;
@@ -6056,8 +6347,11 @@  discard block
 block discarded – undo
6056 6347
 			if($row['registration'] != "")
6057 6348
 			{
6058 6349
 				$image_array = $Image->getSpotterImage($row['registration']);
6059
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6060
-				else $temp_array['image_thumbnail'] = '';
6350
+				if (isset($image_array[0]['image_thumbnail'])) {
6351
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6352
+				} else {
6353
+					$temp_array['image_thumbnail'] = '';
6354
+				}
6061 6355
 			}
6062 6356
 			$temp_array['registration_count'] = $row['registration_count'];
6063 6357
 			$aircraft_array[] = $temp_array;
@@ -6268,7 +6562,9 @@  discard block
 block discarded – undo
6268 6562
 			if($row['registration'] != "")
6269 6563
 			{
6270 6564
 				$image_array = $Image->getSpotterImage($row['registration']);
6271
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6565
+				if (isset($image_array[0]['image_thumbnail'])) {
6566
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6567
+				}
6272 6568
 			}
6273 6569
 			$temp_array['registration_count'] = $row['registration_count'];
6274 6570
           
@@ -6385,7 +6681,9 @@  discard block
 block discarded – undo
6385 6681
 			if($row['registration'] != "")
6386 6682
 			{
6387 6683
 				$image_array = $Image->getSpotterImage($row['registration']);
6388
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6684
+				if (isset($image_array[0]['image_thumbnail'])) {
6685
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6686
+				}
6389 6687
 			}
6390 6688
 			$temp_array['registration_count'] = $row['registration_count'];
6391 6689
           
@@ -6551,7 +6849,9 @@  discard block
 block discarded – undo
6551 6849
 			}
6552 6850
 		}
6553 6851
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6554
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6852
+		if ($limit) {
6853
+			$query .= " LIMIT 10 OFFSET 0";
6854
+		}
6555 6855
 		
6556 6856
 		$sth = $this->db->prepare($query);
6557 6857
 		$sth->execute($query_values);
@@ -6570,7 +6870,9 @@  discard block
 block discarded – undo
6570 6870
 			if($row['registration'] != "")
6571 6871
 			{
6572 6872
 				$image_array = $Image->getSpotterImage($row['registration']);
6573
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6873
+				if (isset($image_array[0]['image_thumbnail'])) {
6874
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6875
+				}
6574 6876
 			}
6575 6877
           
6576 6878
 			$aircraft_array[] = $temp_array;
@@ -6611,7 +6913,9 @@  discard block
 block discarded – undo
6611 6913
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6612 6914
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6613 6915
                 $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";
6614
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6916
+		if ($limit) {
6917
+			$query .= " LIMIT 10 OFFSET 0";
6918
+		}
6615 6919
 		
6616 6920
 		$sth = $this->db->prepare($query);
6617 6921
 		$sth->execute();
@@ -6631,7 +6935,9 @@  discard block
 block discarded – undo
6631 6935
 			if($row['registration'] != "")
6632 6936
 			{
6633 6937
 				$image_array = $Image->getSpotterImage($row['registration']);
6634
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6938
+				if (isset($image_array[0]['image_thumbnail'])) {
6939
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6940
+				}
6635 6941
 			}
6636 6942
           
6637 6943
 			$aircraft_array[] = $temp_array;
@@ -6697,7 +7003,9 @@  discard block
 block discarded – undo
6697 7003
 		}
6698 7004
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, airport.latitude, airport.longitude
6699 7005
 				ORDER BY airport_departure_icao_count DESC";
6700
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7006
+		if ($limit) {
7007
+			$query .= " LIMIT 10 OFFSET 0";
7008
+		}
6701 7009
 
6702 7010
 		$sth = $this->db->prepare($query);
6703 7011
 		$sth->execute($query_values);
@@ -6749,7 +7057,9 @@  discard block
 block discarded – undo
6749 7057
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6750 7058
                 $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
6751 7059
 				ORDER BY airport_departure_icao_count DESC";
6752
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7060
+		if ($limit) {
7061
+			$query .= " LIMIT 10 OFFSET 0";
7062
+		}
6753 7063
       
6754 7064
 		$sth = $this->db->prepare($query);
6755 7065
 		$sth->execute();
@@ -6827,7 +7137,9 @@  discard block
 block discarded – undo
6827 7137
 		}
6828 7138
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude
6829 7139
 				ORDER BY airport_departure_icao_count DESC";
6830
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7140
+		if ($limit) {
7141
+			$query .= " LIMIT 10 OFFSET 0";
7142
+		}
6831 7143
     		//echo $query;
6832 7144
 		$sth = $this->db->prepare($query);
6833 7145
 		$sth->execute($query_values);
@@ -6881,7 +7193,9 @@  discard block
 block discarded – undo
6881 7193
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6882 7194
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6883 7195
 				ORDER BY airport_departure_icao_count DESC";
6884
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7196
+		if ($limit) {
7197
+			$query .= " LIMIT 10 OFFSET 0";
7198
+		}
6885 7199
       
6886 7200
 		$sth = $this->db->prepare($query);
6887 7201
 		$sth->execute();
@@ -7274,7 +7588,9 @@  discard block
 block discarded – undo
7274 7588
 			date_default_timezone_set($globalTimezone);
7275 7589
 			$datetime = new DateTime($date);
7276 7590
 			$offset = $datetime->format('P');
7277
-		} else $offset = '+00:00';
7591
+		} else {
7592
+			$offset = '+00:00';
7593
+		}
7278 7594
 
7279 7595
 		if ($globalDBdriver == 'mysql') {
7280 7596
 			$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 
@@ -7324,7 +7640,9 @@  discard block
 block discarded – undo
7324 7640
 			date_default_timezone_set($globalTimezone);
7325 7641
 			$datetime = new DateTime($date);
7326 7642
 			$offset = $datetime->format('P');
7327
-		} else $offset = '+00:00';
7643
+		} else {
7644
+			$offset = '+00:00';
7645
+		}
7328 7646
 
7329 7647
 		if ($globalDBdriver == 'mysql') {
7330 7648
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -7673,7 +7991,9 @@  discard block
 block discarded – undo
7673 7991
 		}
7674 7992
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, airport.latitude, airport.longitude
7675 7993
 					ORDER BY airport_arrival_icao_count DESC";
7676
-		if ($limit) $query .= " LIMIT 10";
7994
+		if ($limit) {
7995
+			$query .= " LIMIT 10";
7996
+		}
7677 7997
       
7678 7998
 		
7679 7999
 		$sth = $this->db->prepare($query);
@@ -7695,7 +8015,9 @@  discard block
 block discarded – undo
7695 8015
 			if ($icaoaskey) {
7696 8016
 				$icao = $row['arrival_airport_icao'];
7697 8017
 				$airport_array[$icao] = $temp_array;
7698
-			} else $airport_array[] = $temp_array;
8018
+			} else {
8019
+				$airport_array[] = $temp_array;
8020
+			}
7699 8021
 		}
7700 8022
 
7701 8023
 		return $airport_array;
@@ -7732,7 +8054,9 @@  discard block
 block discarded – undo
7732 8054
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7733 8055
                 $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, countries.iso3
7734 8056
 					ORDER BY airport_arrival_icao_count DESC";
7735
-		if ($limit) $query .= " LIMIT 10";
8057
+		if ($limit) {
8058
+			$query .= " LIMIT 10";
8059
+		}
7736 8060
       
7737 8061
 		
7738 8062
 		$sth = $this->db->prepare($query);
@@ -7754,7 +8078,9 @@  discard block
 block discarded – undo
7754 8078
 			if ($icaoaskey) {
7755 8079
 				$icao = $row['arrival_airport_icao'];
7756 8080
 				$airport_array[$icao] = $temp_array;
7757
-			} else $airport_array[] = $temp_array;
8081
+			} else {
8082
+				$airport_array[] = $temp_array;
8083
+			}
7758 8084
 		}
7759 8085
 
7760 8086
 		return $airport_array;
@@ -7817,7 +8143,9 @@  discard block
 block discarded – undo
7817 8143
 		}
7818 8144
 		$query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude
7819 8145
 					ORDER BY airport_arrival_icao_count DESC";
7820
-		if ($limit) $query .= " LIMIT 10";
8146
+		if ($limit) {
8147
+			$query .= " LIMIT 10";
8148
+		}
7821 8149
       
7822 8150
 		
7823 8151
 		$sth = $this->db->prepare($query);
@@ -7836,7 +8164,9 @@  discard block
 block discarded – undo
7836 8164
 			if ($icaoaskey) {
7837 8165
 				$icao = $row['arrival_airport_icao'];
7838 8166
 				$airport_array[$icao] = $temp_array;
7839
-			} else $airport_array[] = $temp_array;
8167
+			} else {
8168
+				$airport_array[] = $temp_array;
8169
+			}
7840 8170
 		}
7841 8171
 
7842 8172
 		return $airport_array;
@@ -7873,7 +8203,9 @@  discard block
 block discarded – undo
7873 8203
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7874 8204
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7875 8205
 					ORDER BY airport_arrival_icao_count DESC";
7876
-		if ($limit) $query .= " LIMIT 10";
8206
+		if ($limit) {
8207
+			$query .= " LIMIT 10";
8208
+		}
7877 8209
       
7878 8210
 		
7879 8211
 		$sth = $this->db->prepare($query);
@@ -7894,7 +8226,9 @@  discard block
 block discarded – undo
7894 8226
 			if ($icaoaskey) {
7895 8227
 				$icao = $row['arrival_airport_icao'];
7896 8228
 				$airport_array[$icao] = $temp_array;
7897
-			} else $airport_array[] = $temp_array;
8229
+			} else {
8230
+				$airport_array[] = $temp_array;
8231
+			}
7898 8232
 		}
7899 8233
 
7900 8234
 		return $airport_array;
@@ -8274,7 +8608,9 @@  discard block
 block discarded – undo
8274 8608
 			date_default_timezone_set($globalTimezone);
8275 8609
 			$datetime = new DateTime($date);
8276 8610
 			$offset = $datetime->format('P');
8277
-		} else $offset = '+00:00';
8611
+		} else {
8612
+			$offset = '+00:00';
8613
+		}
8278 8614
 
8279 8615
 		if ($globalDBdriver == 'mysql') {
8280 8616
 			$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 
@@ -8324,7 +8660,9 @@  discard block
 block discarded – undo
8324 8660
 			date_default_timezone_set($globalTimezone);
8325 8661
 			$datetime = new DateTime($date);
8326 8662
 			$offset = $datetime->format('P');
8327
-		} else $offset = '+00:00';
8663
+		} else {
8664
+			$offset = '+00:00';
8665
+		}
8328 8666
 
8329 8667
 		if ($globalDBdriver == 'mysql') {
8330 8668
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -8715,7 +9053,9 @@  discard block
 block discarded – undo
8715 9053
 		}
8716 9054
 		$query .= " GROUP BY spotter_output.arrival_airport_country, countries.iso3
8717 9055
 					ORDER BY airport_arrival_country_count DESC";
8718
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9056
+		if ($limit) {
9057
+			$query .= " LIMIT 10 OFFSET 0";
9058
+		}
8719 9059
       
8720 9060
 		
8721 9061
 		$sth = $this->db->prepare($query);
@@ -9003,7 +9343,9 @@  discard block
 block discarded – undo
9003 9343
 			date_default_timezone_set($globalTimezone);
9004 9344
 			$datetime = new DateTime($date);
9005 9345
 			$offset = $datetime->format('P');
9006
-		} else $offset = '+00:00';
9346
+		} else {
9347
+			$offset = '+00:00';
9348
+		}
9007 9349
 		
9008 9350
 		if ($globalDBdriver == 'mysql') {
9009 9351
 			$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
@@ -9259,12 +9601,18 @@  discard block
 block discarded – undo
9259 9601
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9260 9602
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9261 9603
 		 if ($olderthanmonths > 0) {
9262
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9263
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9604
+			if ($globalDBdriver == 'mysql') {
9605
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9606
+			} else {
9607
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9608
+			}
9264 9609
 		}
9265 9610
 		if ($sincedate != '') {
9266
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
9267
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9611
+			if ($globalDBdriver == 'mysql') {
9612
+				$query .= " AND spotter_output.date > '".$sincedate."'";
9613
+			} else {
9614
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9615
+			}
9268 9616
 		}
9269 9617
 		$query_values = array();
9270 9618
 		if ($year != '') {
@@ -9295,7 +9643,9 @@  discard block
 block discarded – undo
9295 9643
 			}
9296 9644
 		}
9297 9645
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9298
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9646
+		if ($limit) {
9647
+			$query .= " LIMIT 10 OFFSET 0";
9648
+		}
9299 9649
       		
9300 9650
 		$sth = $this->db->prepare($query);
9301 9651
 		$sth->execute($query_values);
@@ -9329,15 +9679,23 @@  discard block
 block discarded – undo
9329 9679
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9330 9680
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
9331 9681
 		 if ($olderthanmonths > 0) {
9332
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9333
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9682
+			if ($globalDBdriver == 'mysql') {
9683
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9684
+			} else {
9685
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9686
+			}
9334 9687
 		}
9335 9688
 		if ($sincedate != '') {
9336
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
9337
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9689
+			if ($globalDBdriver == 'mysql') {
9690
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
9691
+			} else {
9692
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9693
+			}
9338 9694
 		}
9339 9695
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9340
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9696
+		if ($limit) {
9697
+			$query .= " LIMIT 10 OFFSET 0";
9698
+		}
9341 9699
       		
9342 9700
 		$sth = $this->db->prepare($query);
9343 9701
 		$sth->execute();
@@ -9374,7 +9732,9 @@  discard block
 block discarded – undo
9374 9732
 			date_default_timezone_set($globalTimezone);
9375 9733
 			$datetime = new DateTime();
9376 9734
 			$offset = $datetime->format('P');
9377
-		} else $offset = '+00:00';
9735
+		} else {
9736
+			$offset = '+00:00';
9737
+		}
9378 9738
 
9379 9739
 		if ($globalDBdriver == 'mysql') {
9380 9740
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9423,7 +9783,9 @@  discard block
 block discarded – undo
9423 9783
 			date_default_timezone_set($globalTimezone);
9424 9784
 			$datetime = new DateTime();
9425 9785
 			$offset = $datetime->format('P');
9426
-		} else $offset = '+00:00';
9786
+		} else {
9787
+			$offset = '+00:00';
9788
+		}
9427 9789
 		$filter_query = $this->getFilter($filters,true,true);
9428 9790
 		if ($globalDBdriver == 'mysql') {
9429 9791
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9472,7 +9834,9 @@  discard block
 block discarded – undo
9472 9834
 			date_default_timezone_set($globalTimezone);
9473 9835
 			$datetime = new DateTime();
9474 9836
 			$offset = $datetime->format('P');
9475
-		} else $offset = '+00:00';
9837
+		} else {
9838
+			$offset = '+00:00';
9839
+		}
9476 9840
 		$filter_query = $this->getFilter($filters,true,true);
9477 9841
 		if ($globalDBdriver == 'mysql') {
9478 9842
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9518,7 +9882,9 @@  discard block
 block discarded – undo
9518 9882
 			date_default_timezone_set($globalTimezone);
9519 9883
 			$datetime = new DateTime();
9520 9884
 			$offset = $datetime->format('P');
9521
-		} else $offset = '+00:00';
9885
+		} else {
9886
+			$offset = '+00:00';
9887
+		}
9522 9888
 		$filter_query = $this->getFilter($filters,true,true);
9523 9889
 		if ($globalDBdriver == 'mysql') {
9524 9890
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9566,7 +9932,9 @@  discard block
 block discarded – undo
9566 9932
 			date_default_timezone_set($globalTimezone);
9567 9933
 			$datetime = new DateTime();
9568 9934
 			$offset = $datetime->format('P');
9569
-		} else $offset = '+00:00';
9935
+		} else {
9936
+			$offset = '+00:00';
9937
+		}
9570 9938
 		
9571 9939
 		if ($globalDBdriver == 'mysql') {
9572 9940
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9614,7 +9982,9 @@  discard block
 block discarded – undo
9614 9982
 			date_default_timezone_set($globalTimezone);
9615 9983
 			$datetime = new DateTime();
9616 9984
 			$offset = $datetime->format('P');
9617
-		} else $offset = '+00:00';
9985
+		} else {
9986
+			$offset = '+00:00';
9987
+		}
9618 9988
 
9619 9989
 		if ($globalDBdriver == 'mysql') {
9620 9990
 			$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
@@ -9661,7 +10031,9 @@  discard block
 block discarded – undo
9661 10031
 			date_default_timezone_set($globalTimezone);
9662 10032
 			$datetime = new DateTime();
9663 10033
 			$offset = $datetime->format('P');
9664
-		} else $offset = '+00:00';
10034
+		} else {
10035
+			$offset = '+00:00';
10036
+		}
9665 10037
 
9666 10038
 		if ($globalDBdriver == 'mysql') {
9667 10039
 			$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
@@ -9709,7 +10081,9 @@  discard block
 block discarded – undo
9709 10081
 			date_default_timezone_set($globalTimezone);
9710 10082
 			$datetime = new DateTime();
9711 10083
 			$offset = $datetime->format('P');
9712
-		} else $offset = '+00:00';
10084
+		} else {
10085
+			$offset = '+00:00';
10086
+		}
9713 10087
 		$filter_query = $this->getFilter($filters,true,true);
9714 10088
 		if ($globalDBdriver == 'mysql') {
9715 10089
 			$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
@@ -9754,7 +10128,9 @@  discard block
 block discarded – undo
9754 10128
 			date_default_timezone_set($globalTimezone);
9755 10129
 			$datetime = new DateTime();
9756 10130
 			$offset = $datetime->format('P');
9757
-		} else $offset = '+00:00';
10131
+		} else {
10132
+			$offset = '+00:00';
10133
+		}
9758 10134
 		$filter_query = $this->getFilter($filters,true,true);
9759 10135
 
9760 10136
 		if ($globalDBdriver == 'mysql') {
@@ -9801,7 +10177,9 @@  discard block
 block discarded – undo
9801 10177
 			date_default_timezone_set($globalTimezone);
9802 10178
 			$datetime = new DateTime();
9803 10179
 			$offset = $datetime->format('P');
9804
-		} else $offset = '+00:00';
10180
+		} else {
10181
+			$offset = '+00:00';
10182
+		}
9805 10183
 
9806 10184
 		if ($globalDBdriver == 'mysql') {
9807 10185
 			$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
@@ -9847,7 +10225,9 @@  discard block
 block discarded – undo
9847 10225
 			date_default_timezone_set($globalTimezone);
9848 10226
 			$datetime = new DateTime();
9849 10227
 			$offset = $datetime->format('P');
9850
-		} else $offset = '+00:00';
10228
+		} else {
10229
+			$offset = '+00:00';
10230
+		}
9851 10231
 		$filter_query = $this->getFilter($filters,true,true);
9852 10232
 
9853 10233
 		if ($globalDBdriver == 'mysql') {
@@ -9894,7 +10274,9 @@  discard block
 block discarded – undo
9894 10274
 			date_default_timezone_set($globalTimezone);
9895 10275
 			$datetime = new DateTime();
9896 10276
 			$offset = $datetime->format('P');
9897
-		} else $offset = '+00:00';
10277
+		} else {
10278
+			$offset = '+00:00';
10279
+		}
9898 10280
 
9899 10281
 		if ($globalDBdriver == 'mysql') {
9900 10282
 			$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
@@ -9941,7 +10323,9 @@  discard block
 block discarded – undo
9941 10323
 			date_default_timezone_set($globalTimezone);
9942 10324
 			$datetime = new DateTime();
9943 10325
 			$offset = $datetime->format('P');
9944
-		} else $offset = '+00:00';
10326
+		} else {
10327
+			$offset = '+00:00';
10328
+		}
9945 10329
 
9946 10330
 		if ($globalDBdriver == 'mysql') {
9947 10331
 			$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
@@ -9986,7 +10370,9 @@  discard block
 block discarded – undo
9986 10370
 			date_default_timezone_set($globalTimezone);
9987 10371
 			$datetime = new DateTime();
9988 10372
 			$offset = $datetime->format('P');
9989
-		} else $offset = '+00:00';
10373
+		} else {
10374
+			$offset = '+00:00';
10375
+		}
9990 10376
 		$filter_query = $this->getFilter($filters,true,true);
9991 10377
 
9992 10378
 		if ($globalDBdriver == 'mysql') {
@@ -10034,7 +10420,9 @@  discard block
 block discarded – undo
10034 10420
 			date_default_timezone_set($globalTimezone);
10035 10421
 			$datetime = new DateTime();
10036 10422
 			$offset = $datetime->format('P');
10037
-		} else $offset = '+00:00';
10423
+		} else {
10424
+			$offset = '+00:00';
10425
+		}
10038 10426
 
10039 10427
 		if ($globalDBdriver == 'mysql') {
10040 10428
 			$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
@@ -10080,7 +10468,9 @@  discard block
 block discarded – undo
10080 10468
 			date_default_timezone_set($globalTimezone);
10081 10469
 			$datetime = new DateTime();
10082 10470
 			$offset = $datetime->format('P');
10083
-		} else $offset = '+00:00';
10471
+		} else {
10472
+			$offset = '+00:00';
10473
+		}
10084 10474
 		$filter_query = $this->getFilter($filters,true,true);
10085 10475
 
10086 10476
 		if ($globalDBdriver == 'mysql') {
@@ -10128,7 +10518,9 @@  discard block
 block discarded – undo
10128 10518
 			date_default_timezone_set($globalTimezone);
10129 10519
 			$datetime = new DateTime();
10130 10520
 			$offset = $datetime->format('P');
10131
-		} else $offset = '+00:00';
10521
+		} else {
10522
+			$offset = '+00:00';
10523
+		}
10132 10524
 
10133 10525
 		if ($globalDBdriver == 'mysql') {
10134 10526
 			$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
@@ -10175,7 +10567,9 @@  discard block
 block discarded – undo
10175 10567
 			date_default_timezone_set($globalTimezone);
10176 10568
 			$datetime = new DateTime();
10177 10569
 			$offset = $datetime->format('P');
10178
-		} else $offset = '+00:00';
10570
+		} else {
10571
+			$offset = '+00:00';
10572
+		}
10179 10573
 		$filter_query = $this->getFilter($filters,true,true);
10180 10574
 		if ($globalDBdriver == 'mysql') {
10181 10575
 			$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
@@ -10224,7 +10618,9 @@  discard block
 block discarded – undo
10224 10618
 			date_default_timezone_set($globalTimezone);
10225 10619
 			$datetime = new DateTime();
10226 10620
 			$offset = $datetime->format('P');
10227
-		} else $offset = '+00:00';
10621
+		} else {
10622
+			$offset = '+00:00';
10623
+		}
10228 10624
 
10229 10625
 		$orderby_sql = '';
10230 10626
 		if ($orderby == "hour")
@@ -10290,7 +10686,9 @@  discard block
 block discarded – undo
10290 10686
 			date_default_timezone_set($globalTimezone);
10291 10687
 			$datetime = new DateTime();
10292 10688
 			$offset = $datetime->format('P');
10293
-		} else $offset = '+00:00';
10689
+		} else {
10690
+			$offset = '+00:00';
10691
+		}
10294 10692
 
10295 10693
 		$orderby_sql = '';
10296 10694
 		if ($orderby == "hour")
@@ -10357,7 +10755,9 @@  discard block
 block discarded – undo
10357 10755
 			date_default_timezone_set($globalTimezone);
10358 10756
 			$datetime = new DateTime();
10359 10757
 			$offset = $datetime->format('P');
10360
-		} else $offset = '+00:00';
10758
+		} else {
10759
+			$offset = '+00:00';
10760
+		}
10361 10761
 
10362 10762
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10363 10763
 
@@ -10408,7 +10808,9 @@  discard block
 block discarded – undo
10408 10808
 			date_default_timezone_set($globalTimezone);
10409 10809
 			$datetime = new DateTime();
10410 10810
 			$offset = $datetime->format('P');
10411
-		} else $offset = '+00:00';
10811
+		} else {
10812
+			$offset = '+00:00';
10813
+		}
10412 10814
 
10413 10815
 		if ($globalDBdriver == 'mysql') {
10414 10816
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10455,7 +10857,9 @@  discard block
 block discarded – undo
10455 10857
 			date_default_timezone_set($globalTimezone);
10456 10858
 			$datetime = new DateTime();
10457 10859
 			$offset = $datetime->format('P');
10458
-		} else $offset = '+00:00';
10860
+		} else {
10861
+			$offset = '+00:00';
10862
+		}
10459 10863
 
10460 10864
 		if ($globalDBdriver == 'mysql') {
10461 10865
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10502,7 +10906,9 @@  discard block
 block discarded – undo
10502 10906
 			date_default_timezone_set($globalTimezone);
10503 10907
 			$datetime = new DateTime();
10504 10908
 			$offset = $datetime->format('P');
10505
-		} else $offset = '+00:00';
10909
+		} else {
10910
+			$offset = '+00:00';
10911
+		}
10506 10912
 
10507 10913
 		if ($globalDBdriver == 'mysql') {
10508 10914
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10550,7 +10956,9 @@  discard block
 block discarded – undo
10550 10956
 			date_default_timezone_set($globalTimezone);
10551 10957
 			$datetime = new DateTime();
10552 10958
 			$offset = $datetime->format('P');
10553
-		} else $offset = '+00:00';
10959
+		} else {
10960
+			$offset = '+00:00';
10961
+		}
10554 10962
 
10555 10963
 		if ($globalDBdriver == 'mysql') {
10556 10964
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10598,7 +11006,9 @@  discard block
 block discarded – undo
10598 11006
 			date_default_timezone_set($globalTimezone);
10599 11007
 			$datetime = new DateTime($date);
10600 11008
 			$offset = $datetime->format('P');
10601
-		} else $offset = '+00:00';
11009
+		} else {
11010
+			$offset = '+00:00';
11011
+		}
10602 11012
 
10603 11013
 		if ($globalDBdriver == 'mysql') {
10604 11014
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10646,7 +11056,9 @@  discard block
 block discarded – undo
10646 11056
 			date_default_timezone_set($globalTimezone);
10647 11057
 			$datetime = new DateTime();
10648 11058
 			$offset = $datetime->format('P');
10649
-		} else $offset = '+00:00';
11059
+		} else {
11060
+			$offset = '+00:00';
11061
+		}
10650 11062
 
10651 11063
 		if ($globalDBdriver == 'mysql') {
10652 11064
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10693,7 +11105,9 @@  discard block
 block discarded – undo
10693 11105
 			date_default_timezone_set($globalTimezone);
10694 11106
 			$datetime = new DateTime();
10695 11107
 			$offset = $datetime->format('P');
10696
-		} else $offset = '+00:00';
11108
+		} else {
11109
+			$offset = '+00:00';
11110
+		}
10697 11111
 
10698 11112
 		if ($globalDBdriver == 'mysql') {
10699 11113
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10740,7 +11154,9 @@  discard block
 block discarded – undo
10740 11154
 			date_default_timezone_set($globalTimezone);
10741 11155
 			$datetime = new DateTime();
10742 11156
 			$offset = $datetime->format('P');
10743
-		} else $offset = '+00:00';
11157
+		} else {
11158
+			$offset = '+00:00';
11159
+		}
10744 11160
 
10745 11161
 		if ($globalDBdriver == 'mysql') {
10746 11162
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10790,7 +11206,9 @@  discard block
 block discarded – undo
10790 11206
 			date_default_timezone_set($globalTimezone);
10791 11207
 			$datetime = new DateTime();
10792 11208
 			$offset = $datetime->format('P');
10793
-		} else $offset = '+00:00';
11209
+		} else {
11210
+			$offset = '+00:00';
11211
+		}
10794 11212
 
10795 11213
 		if ($globalDBdriver == 'mysql') {
10796 11214
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10837,7 +11255,9 @@  discard block
 block discarded – undo
10837 11255
 			date_default_timezone_set($globalTimezone);
10838 11256
 			$datetime = new DateTime();
10839 11257
 			$offset = $datetime->format('P');
10840
-		} else $offset = '+00:00';
11258
+		} else {
11259
+			$offset = '+00:00';
11260
+		}
10841 11261
 
10842 11262
 		if ($globalDBdriver == 'mysql') {
10843 11263
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11048,8 +11468,11 @@  discard block
 block discarded – undo
11048 11468
 				$query_values = array_merge($query_values,array(':month' => $month));
11049 11469
 			}
11050 11470
 		}
11051
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
11052
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11471
+		if (empty($query_values)) {
11472
+			$queryi .= $this->getFilter($filters);
11473
+		} else {
11474
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11475
+		}
11053 11476
 		
11054 11477
 		$sth = $this->db->prepare($queryi);
11055 11478
 		$sth->execute($query_values);
@@ -11127,8 +11550,11 @@  discard block
 block discarded – undo
11127 11550
 				$query_values = array_merge($query_values,array(':month' => $month));
11128 11551
 			}
11129 11552
 		}
11130
-                if ($query == '') $queryi .= $this->getFilter($filters);
11131
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11553
+                if ($query == '') {
11554
+                	$queryi .= $this->getFilter($filters);
11555
+                } else {
11556
+                	$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11557
+                }
11132 11558
 
11133 11559
 
11134 11560
 		$sth = $this->db->prepare($queryi);
@@ -11151,7 +11577,9 @@  discard block
 block discarded – undo
11151 11577
 			date_default_timezone_set($globalTimezone);
11152 11578
 			$datetime = new DateTime();
11153 11579
 			$offset = $datetime->format('P');
11154
-		} else $offset = '+00:00';
11580
+		} else {
11581
+			$offset = '+00:00';
11582
+		}
11155 11583
 
11156 11584
 		if ($globalDBdriver == 'mysql') {
11157 11585
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11337,7 +11765,9 @@  discard block
 block discarded – undo
11337 11765
 	*/
11338 11766
 	public function parseDirection($direction = 0)
11339 11767
 	{
11340
-		if ($direction == '') $direction = 0;
11768
+		if ($direction == '') {
11769
+			$direction = 0;
11770
+		}
11341 11771
 		$direction_array = array();
11342 11772
 		$temp_array = array();
11343 11773
 
@@ -11438,7 +11868,9 @@  discard block
 block discarded – undo
11438 11868
 		if (isset($result->AirlineFlightInfoResult))
11439 11869
 		{
11440 11870
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
11441
-		} else return '';
11871
+		} else {
11872
+			return '';
11873
+		}
11442 11874
 		
11443 11875
 		$registration = $this->convertAircraftRegistration($registration);
11444 11876
 		
@@ -11472,7 +11904,9 @@  discard block
 block discarded – undo
11472 11904
 		    return $row['registration'];
11473 11905
 		} elseif ($source_type == 'flarm') {
11474 11906
 			return $this->getAircraftRegistrationBymodeS($aircraft_modes);
11475
-		} else return '';
11907
+		} else {
11908
+			return '';
11909
+		}
11476 11910
 	
11477 11911
 	}
11478 11912
 
@@ -11499,11 +11933,16 @@  discard block
 block discarded – undo
11499 11933
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11500 11934
 		$sth->closeCursor();
11501 11935
 		if (count($row) > 0) {
11502
-			if ($row['type_flight'] == null) return '';
11503
-			else return $row['type_flight'];
11936
+			if ($row['type_flight'] == null) {
11937
+				return '';
11938
+			} else {
11939
+				return $row['type_flight'];
11940
+			}
11504 11941
 		} elseif ($source_type == 'flarm') {
11505 11942
 			return $this->getAircraftTypeBymodeS($aircraft_modes);
11506
-		} else return '';
11943
+		} else {
11944
+			return '';
11945
+		}
11507 11946
 	
11508 11947
 	}
11509 11948
 
@@ -11521,7 +11960,9 @@  discard block
 block discarded – undo
11521 11960
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11522 11961
 	
11523 11962
 		$Connection = new Connection($this->db);
11524
-		if (!$Connection->tableExists('countries')) return '';
11963
+		if (!$Connection->tableExists('countries')) {
11964
+			return '';
11965
+		}
11525 11966
 	
11526 11967
 		try {
11527 11968
 			/*
@@ -11541,9 +11982,13 @@  discard block
 block discarded – undo
11541 11982
 			$sth->closeCursor();
11542 11983
 			if (count($row) > 0) {
11543 11984
 				return $row;
11544
-			} else return '';
11985
+			} else {
11986
+				return '';
11987
+			}
11545 11988
 		} catch (PDOException $e) {
11546
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
11989
+			if (isset($globalDebug) && $globalDebug) {
11990
+				echo 'Error : '.$e->getMessage()."\n";
11991
+			}
11547 11992
 			return '';
11548 11993
 		}
11549 11994
 	
@@ -11561,7 +12006,9 @@  discard block
 block discarded – undo
11561 12006
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11562 12007
 	
11563 12008
 		$Connection = new Connection($this->db);
11564
-		if (!$Connection->tableExists('countries')) return '';
12009
+		if (!$Connection->tableExists('countries')) {
12010
+			return '';
12011
+		}
11565 12012
 	
11566 12013
 		try {
11567 12014
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -11573,9 +12020,13 @@  discard block
 block discarded – undo
11573 12020
 			$sth->closeCursor();
11574 12021
 			if (count($row) > 0) {
11575 12022
 				return $row;
11576
-			} else return '';
12023
+			} else {
12024
+				return '';
12025
+			}
11577 12026
 		} catch (PDOException $e) {
11578
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
12027
+			if (isset($globalDebug) && $globalDebug) {
12028
+				echo 'Error : '.$e->getMessage()."\n";
12029
+			}
11579 12030
 			return '';
11580 12031
 		}
11581 12032
 	
@@ -11825,7 +12276,9 @@  discard block
 block discarded – undo
11825 12276
 	{
11826 12277
 		global $globalBitlyAccessToken;
11827 12278
 		
11828
-		if ($globalBitlyAccessToken == '') return $url;
12279
+		if ($globalBitlyAccessToken == '') {
12280
+			return $url;
12281
+		}
11829 12282
         
11830 12283
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
11831 12284
 		
@@ -11974,7 +12427,9 @@  discard block
 block discarded – undo
11974 12427
 		
11975 12428
 
11976 12429
 		// routes
11977
-		if ($globalDebug) print "Routes...\n";
12430
+		if ($globalDebug) {
12431
+			print "Routes...\n";
12432
+		}
11978 12433
 		if ($globalDBdriver == 'mysql') {
11979 12434
 			$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)";
11980 12435
 		} else {
@@ -11993,7 +12448,9 @@  discard block
 block discarded – undo
11993 12448
 			}
11994 12449
 		}
11995 12450
 		
11996
-		if ($globalDebug) print "Airlines...\n";
12451
+		if ($globalDebug) {
12452
+			print "Airlines...\n";
12453
+		}
11997 12454
 		//airlines
11998 12455
 		if ($globalDBdriver == 'mysql') {
11999 12456
 			$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)";
@@ -12007,10 +12464,15 @@  discard block
 block discarded – undo
12007 12464
 			if (is_numeric(substr($row['ident'], -1, 1)))
12008 12465
 			{
12009 12466
 				$fromsource = NULL;
12010
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
12011
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
12012
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
12013
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12467
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
12468
+					$fromsource = 'vatsim';
12469
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
12470
+					$fromsource = 'ivao';
12471
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
12472
+					$fromsource = 'vatsim';
12473
+				} elseif (isset($globalIVAO) && $globalIVAO) {
12474
+					$fromsource = 'ivao';
12475
+				}
12014 12476
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
12015 12477
 				if (isset($airline_array[0]['name'])) {
12016 12478
 					$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";
@@ -12020,13 +12482,17 @@  discard block
 block discarded – undo
12020 12482
 			}
12021 12483
 		}
12022 12484
 
12023
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
12485
+		if ($globalDebug) {
12486
+			print "Remove Duplicate in aircraft_modes...\n";
12487
+		}
12024 12488
 		//duplicate modes
12025 12489
 		$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";
12026 12490
 		$sth = $this->db->prepare($query);
12027 12491
 		$sth->execute();
12028 12492
 		
12029
-		if ($globalDebug) print "Aircraft...\n";
12493
+		if ($globalDebug) {
12494
+			print "Aircraft...\n";
12495
+		}
12030 12496
 		//aircraft
12031 12497
 		if ($globalDBdriver == 'mysql') {
12032 12498
 			$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)";
@@ -12069,26 +12535,38 @@  discard block
 block discarded – undo
12069 12535
 				 if (isset($closestAirports[0])) {
12070 12536
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
12071 12537
 						$airport_icao = $closestAirports[0]['icao'];
12072
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12538
+						if ($globalDebug) {
12539
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12540
+						}
12073 12541
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
12074 12542
 						foreach ($closestAirports as $airport) {
12075 12543
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
12076 12544
 								$airport_icao = $airport['icao'];
12077
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12545
+								if ($globalDebug) {
12546
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12547
+								}
12078 12548
 								break;
12079 12549
 							}
12080 12550
 						}
12081 12551
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
12082 12552
 						$airport_icao = $closestAirports[0]['icao'];
12083
-						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";
12553
+						if ($globalDebug) {
12554
+							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";
12555
+						}
12084 12556
 					} else {
12085
-						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";
12557
+						if ($globalDebug) {
12558
+							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";
12559
+						}
12086 12560
 					}
12087 12561
 				} else {
12088
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12562
+					if ($globalDebug) {
12563
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12564
+					}
12089 12565
 				}
12090 12566
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
12091
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12567
+					if ($globalDebug) {
12568
+						echo "Updating airport to ".$airport_icao."...\n";
12569
+					}
12092 12570
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12093 12571
 					$sthu = $this->db->prepare($update_query);
12094 12572
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +343 added lines, -121 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 107
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,12 +213,16 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
     	    if (isset($flight['lastupdate'])) {
187 221
         	if ($flight['lastupdate'] < (time()-3000)) {
188 222
             	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
223
+            		if ($globalDebug) {
224
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
225
+            		}
190 226
 			/*
191 227
 			$SpotterLive = new SpotterLive();
192 228
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -197,7 +233,9 @@  discard block
 block discarded – undo
197 233
             		    $Spotter = new Spotter($this->db);
198 234
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 235
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
200
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
236
+				if ($globalDebug && $result != 'success') {
237
+					echo '!!! ERROR : '.$result."\n";
238
+				}
201 239
 			    }
202 240
 			// Put in archive
203 241
 //				$Spotter->db = null;
@@ -212,8 +250,10 @@  discard block
 block discarded – undo
212 250
     public function add($line) {
213 251
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB;
214 252
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
216
-/*
253
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
254
+		$globalCoordMinChange = '0.02';
255
+	}
256
+	/*
217 257
 	$Spotter = new Spotter();
218 258
 	$dbc = $Spotter->db;
219 259
 	$SpotterLive = new SpotterLive($dbc);
@@ -241,11 +281,15 @@  discard block
 block discarded – undo
241 281
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242 282
 		    $current_date = date('Y-m-d');
243 283
 		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
284
+		    if ($source == '' || $line['format_source'] == 'aprs') {
285
+		    	$source = $line['format_source'];
286
+		    }
245 287
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246 288
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247 289
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
290
+		    } else {
291
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
292
+		    }
249 293
 		}
250 294
 		
251 295
 		/*
@@ -261,22 +305,35 @@  discard block
 block discarded – undo
261 305
 		//$this->db = $dbc;
262 306
 
263 307
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
308
+	        if (!isset($line['id'])) {
309
+	        	$id = trim($line['hex']);
310
+	        } else {
311
+	        	$id = trim($line['id']);
312
+	        }
266 313
 		
267 314
 		if (!isset($this->all_flights[$id])) {
268 315
 		    $this->all_flights[$id] = array();
269 316
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270 317
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
318
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
319
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
320
+		    }
272 321
 		    if (!isset($line['id'])) {
273
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
322
+			if (!isset($globalDaemon)) {
323
+				$globalDaemon = TRUE;
324
+			}
325
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
275 326
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
276
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
327
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
328
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
329
+			}
277 330
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
331
+		     } else {
332
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
333
+		     }
334
+		    if ($globalAllFlights !== FALSE) {
335
+		    	$dataFound = true;
336
+		    }
280 337
 		}
281 338
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -298,12 +355,20 @@  discard block
 block discarded – undo
298 355
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 356
 			    }
300 357
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
358
+			    if ($globalDebugTimeElapsed) {
359
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+			    }
361
+			    if ($aircraft_icao != '') {
362
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
363
+			    }
303 364
 			}
304 365
 		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
366
+		    if ($globalAllFlights !== FALSE) {
367
+		    	$dataFound = true;
368
+		    }
369
+		    if ($globalDebug) {
370
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
371
+		    }
307 372
 		}
308 373
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 374
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -314,15 +379,24 @@  discard block
 block discarded – undo
314 379
 				$Spotter = new Spotter($this->db);
315 380
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
316 381
 				$Spotter->db = null;
317
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
382
+				if ($aircraft_icao != '') {
383
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
384
+				}
318 385
 			}
319 386
 		}
320 387
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
321
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
322
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
323
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
324
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
325
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
388
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
389
+				$aircraft_icao = 'GLID';
390
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
391
+				$aircraft_icao = 'UHEL';
392
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
393
+				$aircraft_icao = 'TOWPLANE';
394
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
395
+				$aircraft_icao = 'POWAIRC';
396
+			}
397
+			if (isset($aircraft_icao)) {
398
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
399
+			}
326 400
 		}
327 401
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
328 402
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -332,8 +406,11 @@  discard block
 block discarded – undo
332 406
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
333 407
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
334 408
 		    } else {
335
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
336
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
409
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
410
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
411
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
412
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
413
+				}
337 414
 				/*
338 415
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
339 416
 				print_r($this->all_flights[$id]);
@@ -366,15 +443,25 @@  discard block
 block discarded – undo
366 443
 			    $timeelapsed = microtime(true);
367 444
             		    $Spotter = new Spotter($this->db);
368 445
             		    $fromsource = NULL;
369
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
370
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
371
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
372
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
373
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
446
+            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
447
+            		    	$fromsource = $globalAirlinesSource;
448
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
449
+            		    	$fromsource = 'vatsim';
450
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
451
+			    	$fromsource = 'ivao';
452
+			    } elseif (isset($globalVATSIM) && $globalVATSIM) {
453
+			    	$fromsource = 'vatsim';
454
+			    } elseif (isset($globalIVAO) && $globalIVAO) {
455
+			    	$fromsource = 'ivao';
456
+			    }
374 457
             		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
375
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
458
+			    if ($globalDebug && $result != 'success') {
459
+			    	echo '!!! ERROR : '.$result."\n";
460
+			    }
376 461
 			    $Spotter->db = null;
377
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
462
+			    if ($globalDebugTimeElapsed) {
463
+			    	echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
464
+			    }
378 465
 			}
379 466
 		    }
380 467
 
@@ -386,7 +473,9 @@  discard block
 block discarded – undo
386 473
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
387 474
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
388 475
   */
389
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
476
+		    if (!isset($this->all_flights[$id]['id'])) {
477
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
478
+		    }
390 479
 
391 480
 		    //$putinarchive = true;
392 481
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -404,7 +493,9 @@  discard block
 block discarded – undo
404 493
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
405 494
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
406 495
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
407
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
496
+				if ($globalDebugTimeElapsed) {
497
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
498
+				}
408 499
                         }
409 500
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
410 501
 			$timeelapsed = microtime(true);
@@ -418,7 +509,9 @@  discard block
 block discarded – undo
418 509
 				$Translation->db = null;
419 510
 			    }
420 511
 			    $Spotter->db = null;
421
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
512
+			    if ($globalDebugTimeElapsed) {
513
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
514
+			    }
422 515
                     	}
423 516
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
424 517
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -427,9 +520,13 @@  discard block
 block discarded – undo
427 520
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
428 521
 		    	    }
429 522
 			}
430
-			if (!isset($globalFork)) $globalFork = TRUE;
523
+			if (!isset($globalFork)) {
524
+				$globalFork = TRUE;
525
+			}
431 526
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
432
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
527
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
528
+					$this->get_Schedule($id,trim($line['ident']));
529
+				}
433 530
 			}
434 531
 		    }
435 532
 		}
@@ -445,16 +542,23 @@  discard block
 block discarded – undo
445 542
 		    // use datetime
446 543
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
447 544
 			$speed = $speed*3.6;
448
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
449
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
545
+			if ($speed < 1000) {
546
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
547
+			}
548
+  			if ($globalDebug) {
549
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
550
+  			}
450 551
 		    }
451 552
 		}
452 553
 
453 554
 
454 555
 
455 556
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
456
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
457
-	    	    else unset($timediff);
557
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
558
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
559
+	    	    } else {
560
+	    	    	unset($timediff);
561
+	    	    }
458 562
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
459 563
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
460 564
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -463,15 +567,23 @@  discard block
 block discarded – undo
463 567
 				$this->all_flights[$id]['putinarchive'] = true;
464 568
 				$this->tmd = 0;
465 569
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
466
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
570
+				    if ($globalDebug) {
571
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
572
+				    }
467 573
 				    $timeelapsed = microtime(true);
468 574
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
469 575
 					$Spotter = new Spotter($this->db);
470 576
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
471
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
577
+					if (!empty($all_country)) {
578
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
579
+					}
472 580
 					$Spotter->db = null;
473
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
474
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
581
+					if ($globalDebugTimeElapsed) {
582
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
583
+					}
584
+					if ($globalDebug) {
585
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
586
+					}
475 587
 				    }
476 588
 				}
477 589
 			    }
@@ -479,7 +591,9 @@  discard block
 block discarded – undo
479 591
 
480 592
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
481 593
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
482
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
594
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
595
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
596
+				}
483 597
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
484 598
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
485 599
 				    $dataFound = true;
@@ -501,9 +615,13 @@  discard block
 block discarded – undo
501 615
 			    */
502 616
 			}
503 617
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
504
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
618
+			    if ($line['longitude'] > 180) {
619
+			    	$line['longitude'] = $line['longitude'] - 360;
620
+			    }
505 621
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
506
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
622
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
623
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
624
+				}
507 625
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
508 626
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
509 627
 				    $dataFound = true;
@@ -534,7 +652,9 @@  discard block
 block discarded – undo
534 652
 		    }
535 653
 		}
536 654
 		if (isset($line['last_update']) && $line['last_update'] != '') {
537
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
655
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
656
+		    	$dataFound = true;
657
+		    }
538 658
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
539 659
 		}
540 660
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -556,41 +676,61 @@  discard block
 block discarded – undo
556 676
 			// Here we force archive of flight because after ground it's a new one (or should be)
557 677
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
558 678
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
559
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
560
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
561
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
679
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
680
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
681
+			} elseif (isset($line['id'])) {
682
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
683
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
684
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
685
+			}
686
+		    }
687
+		    if ($line['ground'] != 1) {
688
+		    	$line['ground'] = 0;
562 689
 		    }
563
-		    if ($line['ground'] != 1) $line['ground'] = 0;
564 690
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
565 691
 		    //$dataFound = true;
566 692
 		}
567 693
 		if (isset($line['squawk']) && $line['squawk'] != '') {
568 694
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
569
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
695
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
696
+			    	$this->all_flights[$id]['putinarchive'] = true;
697
+			    }
570 698
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
571 699
 			    $highlight = '';
572
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
573
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
574
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
700
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
701
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
702
+			    }
703
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
704
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
705
+			    }
706
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
707
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
708
+			    }
575 709
 			    if ($highlight != '') {
576 710
 				$timeelapsed = microtime(true);
577 711
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
578 712
 				    $Spotter = new Spotter($this->db);
579 713
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
580 714
 				    $Spotter->db = null;
581
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
715
+				    if ($globalDebugTimeElapsed) {
716
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
717
+				    }
582 718
 				}
583 719
 				//$putinarchive = true;
584 720
 				//$highlight = '';
585 721
 			    }
586 722
 			    
587
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
723
+		    } else {
724
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
725
+		    }
588 726
 		    //$dataFound = true;
589 727
 		}
590 728
 
591 729
 		if (isset($line['altitude']) && $line['altitude'] != '') {
592 730
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
593
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
731
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
732
+				$this->all_flights[$id]['putinarchive'] = true;
733
+			}
594 734
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
595 735
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
596 736
 			//$dataFound = true;
@@ -602,21 +742,30 @@  discard block
 block discarded – undo
602 742
 		}
603 743
 		
604 744
 		if (isset($line['heading']) && $line['heading'] != '') {
605
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
745
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
746
+		    	$this->all_flights[$id]['putinarchive'] = true;
747
+		    }
606 748
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
607 749
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
608 750
 		    //$dataFound = true;
609 751
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
610 752
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
611 753
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
612
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
613
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
754
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
755
+		    	$this->all_flights[$id]['putinarchive'] = true;
756
+		    }
757
+  		    if ($globalDebug) {
758
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
759
+  		    }
614 760
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
615 761
   		    // If not enough messages and ACARS set heading to 0
616 762
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
617 763
   		}
618
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
619
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
764
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
765
+			$dataFound = false;
766
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
767
+			$dataFound = false;
768
+		}
620 769
 
621 770
 //		print_r($this->all_flights[$id]);
622 771
 		//gets the callsign from the last hour
@@ -632,23 +781,38 @@  discard block
 block discarded – undo
632 781
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
633 782
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
634 783
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
635
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
784
+				    if ($globalDebug) {
785
+				    	echo "Check if aircraft is already in DB...";
786
+				    }
636 787
 				    $timeelapsed = microtime(true);
637 788
 				    $SpotterLive = new SpotterLive($this->db);
638 789
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
639 790
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
640
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
791
+					if ($globalDebugTimeElapsed) {
792
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
793
+					}
641 794
 				    } elseif (isset($line['id'])) {
642 795
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
643
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
796
+					if ($globalDebugTimeElapsed) {
797
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
798
+					}
644 799
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
645 800
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
646
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
647
-				    } else $recent_ident = '';
801
+					if ($globalDebugTimeElapsed) {
802
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
803
+					}
804
+				    } else {
805
+				    	$recent_ident = '';
806
+				    }
648 807
 				    $SpotterLive->db=null;
649
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
650
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
651
-				} else $recent_ident = '';
808
+				    if ($globalDebug && $recent_ident == '') {
809
+				    	echo " Not in DB.\n";
810
+				    } elseif ($globalDebug && $recent_ident != '') {
811
+				    	echo " Already in DB.\n";
812
+				    }
813
+				} else {
814
+					$recent_ident = '';
815
+				}
652 816
 			    } else {
653 817
 				$recent_ident = '';
654 818
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -656,7 +820,9 @@  discard block
 block discarded – undo
656 820
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
657 821
 			    if($recent_ident == "")
658 822
 			    {
659
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
823
+				if ($globalDebug) {
824
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
825
+				}
660 826
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
661 827
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
662 828
 				//adds the spotter data for the archive
@@ -700,31 +866,49 @@  discard block
 block discarded – undo
700 866
 				
701 867
 				if (!$ignoreImport) {
702 868
 				    $highlight = '';
703
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
704
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
705
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
706
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
869
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
870
+				    	$highlight = 'Squawk 7500 : Hijack';
871
+				    }
872
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
873
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
874
+				    }
875
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
876
+				    	$highlight = 'Squawk 7700 : Emergency';
877
+				    }
878
+				    if (!isset($this->all_flights[$id]['id'])) {
879
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
880
+				    }
707 881
 				    $timeelapsed = microtime(true);
708 882
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
709 883
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
710 884
 					    $Spotter = new Spotter($this->db);
711 885
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
712 886
 					    $Spotter->db = null;
713
-					    if ($globalDebug && isset($result)) echo $result."\n";
887
+					    if ($globalDebug && isset($result)) {
888
+					    	echo $result."\n";
889
+					    }
714 890
 					}
715 891
 				    }
716
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
892
+				    if ($globalDebugTimeElapsed) {
893
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
894
+				    }
717 895
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
718 896
 
719 897
 				    // Add source stat in DB
720 898
 				    $Stats = new Stats($this->db);
721 899
 				    if (!empty($this->stats)) {
722
-					if ($globalDebug) echo 'Add source stats : ';
900
+					if ($globalDebug) {
901
+						echo 'Add source stats : ';
902
+					}
723 903
 				        foreach($this->stats as $date => $data) {
724 904
 					    foreach($data as $source => $sourced) {
725 905
 					        //print_r($sourced);
726
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
727
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
906
+				    	        if (isset($sourced['polar'])) {
907
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
908
+				    	        }
909
+				    	        if (isset($sourced['hist'])) {
910
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
911
+				    	        }
728 912
 				    		if (isset($sourced['msg'])) {
729 913
 				    		    if (time() - $sourced['msg']['date'] > 10) {
730 914
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -737,13 +921,17 @@  discard block
 block discarded – undo
737 921
 			    			unset($this->stats[$date]);
738 922
 			    		    }
739 923
 				    	}
740
-				    	if ($globalDebug) echo 'Done'."\n";
924
+				    	if ($globalDebug) {
925
+				    		echo 'Done'."\n";
926
+				    	}
741 927
 
742 928
 				    }
743 929
 				    $Stats->db = null;
744 930
 				    }
745 931
 				    $this->del();
746
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
932
+				} elseif ($globalDebug) {
933
+					echo 'Ignore data'."\n";
934
+				}
747 935
 				//$ignoreImport = false;
748 936
 				$this->all_flights[$id]['addedSpotter'] = 1;
749 937
 				//print_r($this->all_flights[$id]);
@@ -760,7 +948,9 @@  discard block
 block discarded – undo
760 948
 			*/
761 949
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
762 950
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
763
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
951
+				    if ($globalDebug) {
952
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
953
+				    }
764 954
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
765 955
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
766 956
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -769,7 +959,9 @@  discard block
 block discarded – undo
769 959
 					    $SpotterLive->db=null;
770 960
 					}
771 961
 				    }
772
-				    if ($globalDebug) echo " Done\n";
962
+				    if ($globalDebug) {
963
+				    	echo " Done\n";
964
+				    }
773 965
 				    $this->last_delete = time();
774 966
 				}
775 967
 			    } else {
@@ -796,11 +988,17 @@  discard block
 block discarded – undo
796 988
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
797 989
 		    if ($globalDebug) {
798 990
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
799
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
800
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
991
+				if (isset($this->all_flights[$id]['source_name'])) {
992
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
993
+				} else {
994
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
995
+				}
801 996
 			} else {
802
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
803
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
997
+				if (isset($this->all_flights[$id]['source_name'])) {
998
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
999
+				} else {
1000
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1001
+				}
804 1002
 			}
805 1003
 		    }
806 1004
 		    $ignoreImport = false;
@@ -846,22 +1044,30 @@  discard block
 block discarded – undo
846 1044
 
847 1045
 		    if (!$ignoreImport) {
848 1046
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
849
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1047
+				if (!isset($this->all_flights[$id]['id'])) {
1048
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1049
+				}
850 1050
 				$timeelapsed = microtime(true);
851 1051
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
852 1052
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
853
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1053
+					if ($globalDebug) {
1054
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1055
+					}
854 1056
 					$SpotterLive = new SpotterLive($this->db);
855 1057
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
856 1058
 					$SpotterLive->db = null;
857
-					if ($globalDebug) echo $result."\n";
1059
+					if ($globalDebug) {
1060
+						echo $result."\n";
1061
+					}
858 1062
 				    }
859 1063
 				}
860 1064
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
861 1065
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
862 1066
 				}
863 1067
 				$this->all_flights[$id]['putinarchive'] = false;
864
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1068
+				if ($globalDebugTimeElapsed) {
1069
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1070
+				}
865 1071
 
866 1072
 				// Put statistics in $this->stats variable
867 1073
 				//if ($line['format_source'] != 'aprs') {
@@ -869,7 +1075,9 @@  discard block
 block discarded – undo
869 1075
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
870 1076
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
871 1077
 					$source = $this->all_flights[$id]['source_name'];
872
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1078
+					if ($source == '') {
1079
+						$source = $this->all_flights[$id]['format_source'];
1080
+					}
873 1081
 					if (!isset($this->source_location[$source])) {
874 1082
 						$Location = new Source();
875 1083
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -890,7 +1098,9 @@  discard block
 block discarded – undo
890 1098
 					$stats_heading = round($stats_heading/22.5);
891 1099
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
892 1100
 					$current_date = date('Y-m-d');
893
-					if ($stats_heading == 16) $stats_heading = 0;
1101
+					if ($stats_heading == 16) {
1102
+						$stats_heading = 0;
1103
+					}
894 1104
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
895 1105
 						for ($i=0;$i<=15;$i++) {
896 1106
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -908,7 +1118,9 @@  discard block
 block discarded – undo
908 1118
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
909 1119
 						    end($this->stats[$current_date][$source]['hist']);
910 1120
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
911
-						} else $mini = 0;
1121
+						} else {
1122
+							$mini = 0;
1123
+						}
912 1124
 						for ($i=$mini;$i<=$distance;$i+=10) {
913 1125
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
914 1126
 						}
@@ -920,19 +1132,27 @@  discard block
 block discarded – undo
920 1132
 				}
921 1133
 
922 1134
 				$this->all_flights[$id]['lastupdate'] = time();
923
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1135
+				if ($this->all_flights[$id]['putinarchive']) {
1136
+					$send = true;
1137
+				}
924 1138
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
925
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1139
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1140
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1141
+			}
926 1142
 			//$this->del();
927 1143
 			
928 1144
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
929 1145
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
930
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1146
+				if ($globalDebug) {
1147
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1148
+				}
931 1149
 				$SpotterLive = new SpotterLive($this->db);
932 1150
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
933 1151
 				$SpotterLive->db = null;
934 1152
 				//SpotterLive->deleteLiveSpotterData();
935
-				if ($globalDebug) echo " Done\n";
1153
+				if ($globalDebug) {
1154
+					echo " Done\n";
1155
+				}
936 1156
 				$this->last_delete_hourly = time();
937 1157
 			    } else {
938 1158
 				$this->del();
@@ -944,7 +1164,9 @@  discard block
 block discarded – undo
944 1164
 		    //$ignoreImport = false;
945 1165
 		}
946 1166
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
947
-		if ($send) return $this->all_flights[$id];
1167
+		if ($send) {
1168
+			return $this->all_flights[$id];
1169
+		}
948 1170
 	    }
949 1171
 	}
950 1172
     }
Please login to merge, or discard this patch.