Completed
Push — master ( e14a40...cfb98e )
by Yannick
54:46 queued 27:34
created
require/class.TSK.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 	*/
16 16
 	public function parse_xml($url) {
17 17
 		$Common = new Common();
18
-		$filedata = $Common->getData($url,'get','','','','','','',true);
18
+		$filedata = $Common->getData($url, 'get', '', '', '', '', '', '', true);
19 19
 		if ($filedata != '' && $filedata !== false) {
20 20
 			$xml = simplexml_load_string($filedata);
21 21
 			if ($xml !== false) {
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 	}
28 28
 
29 29
 	/**
30
-	* Add schedule data to database
31
-	* @param String $ident aircraft ident
32
-	* @param String $departure_airport_icao departure airport icao
33
-	* @param String $departure_airport_time departure airport time
34
-	* @param String $arrival_airport_icao arrival airport icao
35
-	* @param String $arrival_airport_time arrival airport time
30
+	 * Add schedule data to database
31
+	 * @param String $ident aircraft ident
32
+	 * @param String $departure_airport_icao departure airport icao
33
+	 * @param String $departure_airport_time departure airport time
34
+	 * @param String $arrival_airport_icao arrival airport icao
35
+	 * @param String $arrival_airport_time arrival airport time
36 36
 	/ @param String $source source of data
37
-	*/
37
+	 */
38 38
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
39 39
 		date_default_timezone_set('UTC');
40 40
 		$date = date("Y-m-d H:i:s",time());
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
 		}
51 51
 		if ($sth->fetchColumn() > 0) {
52 52
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
53
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
54
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
53
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
54
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
55 55
 			} elseif ($arrival_airport_time == '') {
56
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
57
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
56
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
57
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
58 58
 			} elseif ($departure_airport_time == '') {
59
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
60
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
59
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
60
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
61 61
 			} else {
62
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
63
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
64
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
62
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
63
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
64
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
65 65
 			}
66 66
 			try {
67 67
 				$sth = $this->db->prepare($query);
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 	*/
149 149
 	public function checkSchedule($ident) {
150 150
 		global $globalDBdriver;
151
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
152
-	        if ($globalDBdriver == 'mysql') {
151
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
152
+			if ($globalDBdriver == 'mysql') {
153 153
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
154 154
 		} else {
155 155
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident 
156 156
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
157 157
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
158 158
 		}
159
-	        $query_values = array(':ident' => $ident);
159
+			$query_values = array(':ident' => $ident);
160 160
 		 try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute($query_values);
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
 	}
170 170
 
171 171
 	/**
172
-	* Get flight info from Air France
173
-	* @param String $callsign The callsign
174
-	* @param String $date date we want flight number info
175
-	* @param String $carrier IATA code
176
-	* @return Flight departure and arrival airports and time
177
-	*/
172
+	 * Get flight info from Air France
173
+	 * @param String $callsign The callsign
174
+	 * @param String $date date we want flight number info
175
+	 * @param String $carrier IATA code
176
+	 * @return Flight departure and arrival airports and time
177
+	 */
178 178
 	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
179 179
 		$Common = new Common();
180 180
 		$check_date = new Datetime($date);
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 	}
211 211
 
212 212
 	/**
213
-	* Get flight info from EasyJet
214
-	* @param String $callsign The callsign
215
-	* @param String $date date we want flight number info
216
-	* @return Flight departure and arrival airports and time
217
-	*/
213
+	 * Get flight info from EasyJet
214
+	 * @param String $callsign The callsign
215
+	 * @param String $date date we want flight number info
216
+	 * @return Flight departure and arrival airports and time
217
+	 */
218 218
 	private function getEasyJet($callsign, $date = 'NOW') {
219 219
 		global $globalTimezone;
220 220
 		$Common = new Common();
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 	}
239 239
 
240 240
 	/**
241
-	* Get flight info from Ryanair
242
-	* @param String $callsign The callsign
243
-	* @return Flight departure and arrival airports and time
244
-	*/
241
+	 * Get flight info from Ryanair
242
+	 * @param String $callsign The callsign
243
+	 * @return Flight departure and arrival airports and time
244
+	 */
245 245
 	private function getRyanair($callsign) {
246 246
 		$Common = new Common();
247 247
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 	}
265 265
 
266 266
 	/**
267
-	* Get flight info from Swiss
268
-	* @param String $callsign The callsign
269
-	* @return Flight departure and arrival airports and time
270
-	*/
267
+	 * Get flight info from Swiss
268
+	 * @param String $callsign The callsign
269
+	 * @return Flight departure and arrival airports and time
270
+	 */
271 271
 	private function getSwiss($callsign) {
272 272
 		$Common = new Common();
273 273
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -296,11 +296,11 @@  discard block
 block discarded – undo
296 296
 	}
297 297
 	
298 298
 	/**
299
-	* Get flight info from British Airways API
300
-	* @param String $callsign The callsign
301
-	* @param String $date date we want flight number info
302
-	* @return Flight departure and arrival airports and time
303
-	*/
299
+	 * Get flight info from British Airways API
300
+	 * @param String $callsign The callsign
301
+	 * @param String $date date we want flight number info
302
+	 * @return Flight departure and arrival airports and time
303
+	 */
304 304
 	public function getBritishAirways($callsign, $date = 'NOW') {
305 305
 		global $globalBritishAirwaysKey;
306 306
 		$Common = new Common();
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 	}
325 325
 
326 326
 	/**
327
-	* Get flight info from Lutfhansa API
328
-	* @param String $callsign The callsign
329
-	* @param String $date date we want flight number info
330
-	* @return Flight departure and arrival airports and time
331
-	*/
327
+	 * Get flight info from Lutfhansa API
328
+	 * @param String $callsign The callsign
329
+	 * @param String $date date we want flight number info
330
+	 * @return Flight departure and arrival airports and time
331
+	 */
332 332
 	public function getLufthansa($callsign, $date = 'NOW') {
333 333
 		global $globalLufthansaKey;
334 334
 		$Common = new Common();
@@ -358,11 +358,11 @@  discard block
 block discarded – undo
358 358
 	}
359 359
 
360 360
 	/**
361
-	* Get flight info from Transavia API
362
-	* @param String $callsign The callsign
363
-	* @param String $date date we want flight number info
364
-	* @return Flight departure and arrival airports and time
365
-	*/
361
+	 * Get flight info from Transavia API
362
+	 * @param String $callsign The callsign
363
+	 * @param String $date date we want flight number info
364
+	 * @return Flight departure and arrival airports and time
365
+	 */
366 366
 	public function getTransavia($callsign, $date = 'NOW') {
367 367
 		global $globalTransaviaKey;
368 368
 		$Common = new Common();
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
 	}
389 389
 
390 390
 	/**
391
-	* Get flight info from Tunisair
392
-	* @param String $callsign The callsign
393
-	* @return Flight departure and arrival airports and time
394
-	*/
391
+	 * Get flight info from Tunisair
392
+	 * @param String $callsign The callsign
393
+	 * @return Flight departure and arrival airports and time
394
+	 */
395 395
 	public function getTunisair($callsign) {
396 396
 		$Common = new Common();
397 397
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
 	}
409 409
 
410 410
 	/**
411
-	* Get flight info from Vueling
412
-	* @param String $callsign The callsign
413
-	* @return Flight departure and arrival airports and time
414
-	*/
411
+	 * Get flight info from Vueling
412
+	 * @param String $callsign The callsign
413
+	 * @return Flight departure and arrival airports and time
414
+	 */
415 415
 	public function getVueling($callsign,$date = 'NOW') {
416 416
 		$Common = new Common();
417 417
 		$check_date = new Datetime($date);
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 	}
434 434
 
435 435
 	/**
436
-	* Get flight info from Iberia
437
-	* @param String $callsign The callsign
438
-	* @param String $date date we want flight number info
439
-	* @return Flight departure and arrival airports and time
440
-	*/
436
+	 * Get flight info from Iberia
437
+	 * @param String $callsign The callsign
438
+	 * @param String $date date we want flight number info
439
+	 * @return Flight departure and arrival airports and time
440
+	 */
441 441
 	public function getIberia($callsign, $date = 'NOW') {
442 442
 		$Common = new Common();
443 443
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
 	}
468 468
 
469 469
 	/**
470
-	* Get flight info from Star Alliance
471
-	* @param String $callsign The callsign
472
-	* @param String $date date we want flight number info
473
-	* @return Flight departure and arrival airports and time
474
-	*/
470
+	 * Get flight info from Star Alliance
471
+	 * @param String $callsign The callsign
472
+	 * @param String $date date we want flight number info
473
+	 * @return Flight departure and arrival airports and time
474
+	 */
475 475
 
476 476
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
477 477
 		$Common = new Common();
@@ -503,11 +503,11 @@  discard block
 block discarded – undo
503 503
 
504 504
 
505 505
 	/**
506
-	* Get flight info from Alitalia
507
-	* @param String $callsign The callsign
508
-	* @param String $date date we want flight number info
509
-	* @return Flight departure and arrival airports and time
510
-	*/
506
+	 * Get flight info from Alitalia
507
+	 * @param String $callsign The callsign
508
+	 * @param String $date date we want flight number info
509
+	 * @return Flight departure and arrival airports and time
510
+	 */
511 511
 	private function getAlitalia($callsign, $date = 'NOW') {
512 512
 		$Common = new Common();
513 513
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -526,11 +526,11 @@  discard block
 block discarded – undo
526 526
 	}
527 527
 
528 528
 	/**
529
-	* Get flight info from Brussels airlines
530
-	* @param String $callsign The callsign
531
-	* @param String $date date we want flight number info
532
-	* @return Flight departure and arrival airports and time
533
-	*/
529
+	 * Get flight info from Brussels airlines
530
+	 * @param String $callsign The callsign
531
+	 * @param String $date date we want flight number info
532
+	 * @return Flight departure and arrival airports and time
533
+	 */
534 534
 	private function getBrussels($callsign, $date = 'NOW') {
535 535
 		$Common = new Common();
536 536
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -540,24 +540,24 @@  discard block
 block discarded – undo
540 540
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
541 541
 		$data = $Common->getData($url);
542 542
 		if ($data != '') {
543
-		    //echo $data;
544
-		    $parsed_json = json_decode($data,true);
545
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
543
+			//echo $data;
544
+			$parsed_json = json_decode($data,true);
545
+			if (isset($parsed_json[0]['FromAirportCode'])) {
546 546
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
547 547
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
548 548
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
549 549
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
550 550
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
551
-		    }
551
+			}
552 552
 		}
553 553
 	}
554 554
 
555 555
 	/**
556
-	* Get flight info from FlightRadar24
557
-	* @param String $callsign The callsign
558
-	* @param String $date date we want flight number info
559
-	* @return Flight departure and arrival airports and time
560
-	*/
556
+	 * Get flight info from FlightRadar24
557
+	 * @param String $callsign The callsign
558
+	 * @param String $date date we want flight number info
559
+	 * @return Flight departure and arrival airports and time
560
+	 */
561 561
 /*
562 562
 	public function getFlightRadar24($callsign, $date = 'NOW') {
563 563
 		$Common = new Common();
@@ -586,11 +586,11 @@  discard block
 block discarded – undo
586 586
 	}
587 587
   */
588 588
 	/**
589
-	* Get flight info from Lufthansa
590
-	* @param String $callsign The callsign
591
-	* @param String $date date we want flight number info
592
-	* @return Flight departure and arrival airports and time
593
-	*/
589
+	 * Get flight info from Lufthansa
590
+	 * @param String $callsign The callsign
591
+	 * @param String $date date we want flight number info
592
+	 * @return Flight departure and arrival airports and time
593
+	 */
594 594
 
595 595
 /*	private function getLufthansa($callsign, $date = 'NOW') {
596 596
 		$Common = new Common();
@@ -618,10 +618,10 @@  discard block
 block discarded – undo
618 618
 	}
619 619
   */
620 620
 	/**
621
-	* Get flight info from flytap
622
-	* @param String $callsign The callsign
623
-	* @return Flight departure and arrival airports and time
624
-	*/
621
+	 * Get flight info from flytap
622
+	 * @param String $callsign The callsign
623
+	 * @return Flight departure and arrival airports and time
624
+	 */
625 625
 	private function getFlyTap($callsign) {
626 626
 		$Common = new Common();
627 627
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -644,10 +644,10 @@  discard block
 block discarded – undo
644 644
 	}
645 645
 
646 646
 	/**
647
-	* Get flight info from flightmapper
648
-	* @param String $callsign The callsign
649
-	* @return Flight departure and arrival airports and time
650
-	*/
647
+	 * Get flight info from flightmapper
648
+	 * @param String $callsign The callsign
649
+	 * @return Flight departure and arrival airports and time
650
+	 */
651 651
 	public function getFlightMapper($callsign) {
652 652
 		$Common = new Common();
653 653
 		$airline_icao = '';
@@ -675,11 +675,11 @@  discard block
 block discarded – undo
675 675
 				$aarr = '';
676 676
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
677 677
 				if ($n == 7) {
678
-				    $departureTime = $dhour;
679
-				    $arrivalTime = $ahour;
680
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
681
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
682
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
678
+					$departureTime = $dhour;
679
+					$arrivalTime = $ahour;
680
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
681
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
682
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
683 683
 				}
684 684
 			}
685 685
 		}
@@ -687,10 +687,10 @@  discard block
 block discarded – undo
687 687
 	}
688 688
 
689 689
 	/**
690
-	* Get flight info from flightaware
691
-	* @param String $callsign The callsign
692
-	* @return Flight departure and arrival airports and time
693
-	*/
690
+	 * Get flight info from flightaware
691
+	 * @param String $callsign The callsign
692
+	 * @return Flight departure and arrival airports and time
693
+	 */
694 694
 	public function getFlightAware($callsign) {
695 695
 		global $globalFlightAwareUsername, $globalFlightAwarePassword;
696 696
 		date_default_timezone_set('UTC');
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
716 716
 				if (isset($flight['origin'])) {
717 717
 					return array(
718
-					    'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
719
-					    'DepartureTime' => $flight['filed_departure_time']['time'],
720
-					    'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
721
-					    'ArrivalTime' => $flight['filed_arrival_time']['time'],
722
-					    'Source' => 'website_flightaware');
718
+						'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
719
+						'DepartureTime' => $flight['filed_departure_time']['time'],
720
+						'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
721
+						'ArrivalTime' => $flight['filed_arrival_time']['time'],
722
+						'Source' => 'website_flightaware');
723 723
 				}
724 724
 			}
725 725
 		}
@@ -732,21 +732,21 @@  discard block
 block discarded – undo
732 732
 			$flight = reset($flights['flights']);
733 733
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
734 734
 				return array(
735
-				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
736
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
737
-				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
738
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
739
-				    'Source' => 'website_flightaware');
735
+					'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
736
+					'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
737
+					'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
738
+					'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
739
+					'Source' => 'website_flightaware');
740 740
 			}
741 741
 		}
742 742
 		return array();
743 743
 	}
744 744
 
745 745
 	/**
746
-	* Get flight info from CostToTravel
747
-	* @param String $callsign The callsign
748
-	* @return Flight departure and arrival airports and time
749
-	*/
746
+	 * Get flight info from CostToTravel
747
+	 * @param String $callsign The callsign
748
+	 * @return Flight departure and arrival airports and time
749
+	 */
750 750
 	public function getCostToTravel($callsign) {
751 751
 		$Common = new Common();
752 752
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -769,11 +769,11 @@  discard block
 block discarded – undo
769 769
 	}
770 770
 
771 771
 	/**
772
-	* Get flight info from Air Canada
773
-	* @param String $callsign The callsign
774
-	* @param String $date date we want flight number info
775
-	* @return Flight departure and arrival airports and time
776
-	*/
772
+	 * Get flight info from Air Canada
773
+	 * @param String $callsign The callsign
774
+	 * @param String $date date we want flight number info
775
+	 * @return Flight departure and arrival airports and time
776
+	 */
777 777
 	private function getAirCanada($callsign,$date = 'NOW') {
778 778
 		$Common = new Common();
779 779
 		if (class_exists("DomDocument") === FALSE) return array();
@@ -798,11 +798,11 @@  discard block
 block discarded – undo
798 798
 	}
799 799
 
800 800
 	/**
801
-	* Get flight info from Vietnam Airlines
802
-	* @param String $callsign The callsign
803
-	* @param String $date date we want flight number info
804
-	* @return Flight departure and arrival airports and time
805
-	*/
801
+	 * Get flight info from Vietnam Airlines
802
+	 * @param String $callsign The callsign
803
+	 * @param String $date date we want flight number info
804
+	 * @return Flight departure and arrival airports and time
805
+	 */
806 806
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
807 807
 		$Common = new Common();
808 808
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -824,12 +824,12 @@  discard block
 block discarded – undo
824 824
 	}
825 825
 
826 826
 	/**
827
-	* Get flight info from Air Berlin
828
-	* @param String $callsign The callsign
829
-	* @param String $date date we want flight number info
830
-	* @param String $carrier airline code
831
-	* @return Flight departure and arrival airports and time
832
-	*/
827
+	 * Get flight info from Air Berlin
828
+	 * @param String $callsign The callsign
829
+	 * @param String $date date we want flight number info
830
+	 * @param String $carrier airline code
831
+	 * @return Flight departure and arrival airports and time
832
+	 */
833 833
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
834 834
 		$Common = new Common();
835 835
 		date_default_timezone_set('UTC');
@@ -858,11 +858,11 @@  discard block
 block discarded – undo
858 858
 			$table = $Common->table2array($data);
859 859
 			$flight = $table;
860 860
 			if (isset($flight[5][4])) {
861
-			    $arrivalTime = $flight[5][4];
862
-			    $arrivalAirport = $flight[5][3];
861
+				$arrivalTime = $flight[5][4];
862
+				$arrivalAirport = $flight[5][3];
863 863
 			} else {
864
-			    $arrivalTime = '';
865
-			    $arrivalAirport = '';
864
+				$arrivalTime = '';
865
+				$arrivalAirport = '';
866 866
 			}
867 867
 		} else return array();
868 868
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
Please login to merge, or discard this patch.
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	* @param String $arrival_airport_time arrival airport time
36 36
 	/ @param String $source source of data
37 37
 	*/
38
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
38
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
39 39
 		date_default_timezone_set('UTC');
40
-		$date = date("Y-m-d H:i:s",time());
40
+		$date = date("Y-m-d H:i:s", time());
41 41
 		//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
42 42
 		//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
43 43
 		$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -45,69 +45,69 @@  discard block
 block discarded – undo
45 45
 		 try {
46 46
 			$sth = $this->db->prepare($query);
47 47
 			$sth->execute($query_values);
48
-		} catch(PDOException $e) {
48
+		} catch (PDOException $e) {
49 49
 			return "error : ".$e->getMessage();
50 50
 		}
51 51
 		if ($sth->fetchColumn() > 0) {
52 52
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
53 53
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
54
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
54
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
55 55
 			} elseif ($arrival_airport_time == '') {
56 56
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
57
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
57
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
58 58
 			} elseif ($departure_airport_time == '') {
59 59
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
60
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
60
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
61 61
 			} else {
62 62
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
63 63
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
64
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
64
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
65 65
 			}
66 66
 			try {
67 67
 				$sth = $this->db->prepare($query);
68 68
 				$sth->execute($query_values);
69
-			} catch(PDOException $e) {
69
+			} catch (PDOException $e) {
70 70
 				return "error : ".$e->getMessage();
71 71
 			}
72 72
 			if ($sth->fetchColumn() == 0) {
73 73
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
74 74
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
75 75
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
76
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
76
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
77 77
 				} elseif ($arrival_airport_time == '') {
78 78
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
79
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
79
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
80 80
 				} elseif ($departure_airport_time == '') {
81 81
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
82
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
82
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
83 83
 				} else {
84 84
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
85
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
85
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
86 86
 				}
87 87
 				try {
88 88
 					$sth = $this->db->prepare($query);
89 89
 					$sth->execute($query_values);
90
-				} catch(PDOException $e) {
90
+				} catch (PDOException $e) {
91 91
 					return "error : ".$e->getMessage();
92 92
 				}
93 93
 			} else {
94 94
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
95 95
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
96
-				$query_values = array(':ident' => $ident,':date' => $date);
96
+				$query_values = array(':ident' => $ident, ':date' => $date);
97 97
 				try {
98 98
 					$sth = $this->db->prepare($query);
99 99
 					$sth->execute($query_values);
100
-				} catch(PDOException $e) {
100
+				} catch (PDOException $e) {
101 101
 					return "error : ".$e->getMessage();
102 102
 				}
103 103
 			}
104 104
 		} else {
105 105
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
106
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
106
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
107 107
 			 try {
108 108
 				$sth = $this->db->prepare($query);
109 109
 				$sth->execute($query_values);
110
-			} catch(PDOException $e) {
110
+			} catch (PDOException $e) {
111 111
 				return "error : ".$e->getMessage();
112 112
 			}
113 113
 		}
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 	*/
121 121
 	public function getSchedule($ident) {
122 122
 		$Translation = new Translation($this->db);
123
-		$operator = $Translation->checkTranslation($ident,false);
123
+		$operator = $Translation->checkTranslation($ident, false);
124 124
 		if ($ident != $operator) {
125 125
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
126
-			$query_values = array(':ident' => $ident,'operator' => $operator);
126
+			$query_values = array(':ident' => $ident, 'operator' => $operator);
127 127
 		} else {
128 128
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
129 129
 			$query_values = array(':ident' => $ident);
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		 try {
132 132
 			$sth = $this->db->prepare($query);
133 133
 			$sth->execute($query_values);
134
-		} catch(PDOException $e) {
134
+		} catch (PDOException $e) {
135 135
 			return "error : ".$e->getMessage();
136 136
 		}
137 137
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		 try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute($query_values);
163
-		} catch(PDOException $e) {
163
+		} catch (PDOException $e) {
164 164
 			return "error : ".$e->getMessage();
165 165
 		}
166 166
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
 	* @param String $carrier IATA code
176 176
 	* @return Flight departure and arrival airports and time
177 177
 	*/
178
-	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
178
+	private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
179 179
 		$Common = new Common();
180 180
 		$check_date = new Datetime($date);
181
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
182
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
181
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
182
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
183 183
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
184 184
 		$json = $Common->getData($url);
185 185
 	
186 186
 		$parsed_json = json_decode($json);
187
-		if (property_exists($parsed_json,'errors') === false) {
187
+		if (property_exists($parsed_json, 'errors') === false) {
188 188
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
189 189
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
190 190
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
195 195
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
196 196
 
197
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
197
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
198 198
 			$DepartureAirportIata = $originiata[1];
199
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
199
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
200 200
 			$ArrivalAirportIata = $destinationiata[1];
201 201
 
202 202
 			/*
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
206 206
 			*/
207 207
 		
208
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
208
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
209 209
 		} else return array();
210 210
 	}
211 211
 
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 		$Common = new Common();
221 221
 		date_default_timezone_set($globalTimezone);
222 222
 		$check_date = new Datetime($date);
223
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
224
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
223
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
224
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
225 225
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
226 226
 		$json = $Common->getData($url);
227 227
 		$parsed_json = json_decode($json);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
234 234
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
235 235
 
236
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
236
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
237 237
 		} else return array();
238 238
 	}
239 239
 
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 	*/
245 245
 	private function getRyanair($callsign) {
246 246
 		$Common = new Common();
247
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
248
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
247
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
248
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
249 249
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
250 250
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
251
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
252
-		$json = $Common->getData($url,'post',$post,$headers);
251
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
252
+		$json = $Common->getData($url, 'post', $post, $headers);
253 253
 		$parsed_json = json_decode($json);
254 254
 		if (isset($parsed_json->{'flightInfo'})) {
255 255
 			$flights = $parsed_json->{'flightInfo'};
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
259 259
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
260 260
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
261
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
261
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
262 262
 			} else return array();
263 263
 		} else return array();
264 264
 	}
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	*/
271 271
 	private function getSwiss($callsign) {
272 272
 		$Common = new Common();
273
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
274
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
273
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
274
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
275 275
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
276 276
 		$json = $Common->getData($url);
277 277
 		$parsed_json = json_decode($json);
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
286 286
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
287 287
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
288
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
289
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
288
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
289
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
290 290
 				}
291 291
 			}
292 292
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
293
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
293
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
294 294
 			} else return array();
295 295
 		} else return array();
296 296
 	}
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
 		global $globalBritishAirwaysKey;
306 306
 		$Common = new Common();
307 307
 		$check_date = new Datetime($date);
308
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
309
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
308
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
309
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
310 310
 		if ($globalBritishAirwaysKey == '') return array();
311 311
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
312 312
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
313
-		$json = $Common->getData($url,'get','',$headers);
313
+		$json = $Common->getData($url, 'get', '', $headers);
314 314
 		if ($json == '') return array();
315 315
 		$parsed_json = json_decode($json);
316 316
 		$flights = $parsed_json->{'FlightsResponse'};
317 317
 		if (count($flights) > 0) {
318 318
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
319 319
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
320
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
321
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
322
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
320
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
321
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
322
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
323 323
 		} else return array();
324 324
 	}
325 325
 
@@ -333,27 +333,27 @@  discard block
 block discarded – undo
333 333
 		global $globalLufthansaKey;
334 334
 		$Common = new Common();
335 335
 		$check_date = new Datetime($date);
336
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
337
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
336
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
337
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
338 338
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
339 339
 		$url = "https://api.lufthansa.com/v1/oauth/token";
340
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
341
-		$data = $Common->getData($url,'post',$post);
340
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
341
+		$data = $Common->getData($url, 'post', $post);
342 342
 		$parsed_data = json_decode($data);
343 343
 		if (!isset($parsed_data->{'access_token'})) return array();
344 344
 		$token = $parsed_data->{'access_token'};
345 345
 		
346 346
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
347
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
348
-		$json = $Common->getData($url,'get','',$headers);
347
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
348
+		$json = $Common->getData($url, 'get', '', $headers);
349 349
 		if ($json == '') return array();
350 350
 		$parsed_json = json_decode($json);
351 351
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
352 352
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
353
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
353
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
354 354
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
355
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
356
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
355
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
356
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
357 357
 		} else return array();
358 358
 	}
359 359
 
@@ -367,23 +367,23 @@  discard block
 block discarded – undo
367 367
 		global $globalTransaviaKey;
368 368
 		$Common = new Common();
369 369
 		$check_date = new Datetime($date);
370
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
371
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
370
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
371
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
372 372
 		if ($globalTransaviaKey == '') return array();
373 373
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
374 374
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
375 375
 		$headers = array('apikey: '.$globalTransaviaKey);
376
-		$json = $Common->getData($url,'get','',$headers);
376
+		$json = $Common->getData($url, 'get', '', $headers);
377 377
 		//echo 'result : '.$json;
378 378
 		if ($json == '') return array();
379 379
 		$parsed_json = json_decode($json);
380 380
 		
381 381
 		if (isset($parsed_json->{'data'}[0])) {
382 382
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
383
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
383
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
384 384
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
385
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
386
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
385
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
386
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
387 387
 		} else return array();
388 388
 	}
389 389
 
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
 	*/
395 395
 	public function getTunisair($callsign) {
396 396
 		$Common = new Common();
397
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
398
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
397
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
398
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
399 399
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
400 400
 		$data = $Common->getData($url);
401 401
 		$table = $Common->table2array($data);
402 402
 		foreach ($table as $flight) {
403
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
404
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
403
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
404
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
405 405
 			}
406 406
 		}
407 407
 		return array();
@@ -412,21 +412,21 @@  discard block
 block discarded – undo
412 412
 	* @param String $callsign The callsign
413 413
 	* @return Flight departure and arrival airports and time
414 414
 	*/
415
-	public function getVueling($callsign,$date = 'NOW') {
415
+	public function getVueling($callsign, $date = 'NOW') {
416 416
 		$Common = new Common();
417 417
 		$check_date = new Datetime($date);
418
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
419
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
420
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
418
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
419
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
420
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
421 421
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
422 422
 		$data = $Common->getData($url);
423
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
423
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
424 424
 		if ($data != '') {
425
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
426
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
427
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
428
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
429
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
425
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
426
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
427
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
428
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
429
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
430 430
 			else return array();
431 431
 		}
432 432
 		return array();
@@ -440,27 +440,27 @@  discard block
 block discarded – undo
440 440
 	*/
441 441
 	public function getIberia($callsign, $date = 'NOW') {
442 442
 		$Common = new Common();
443
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
443
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
444 444
 		$check_date = new Datetime($date);
445
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
445
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
446 446
 		$url = "https://www.iberia.com/web/flightDetail.do";
447
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
448
-		$data = $Common->getData($url,'post',$post);
447
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
448
+		$data = $Common->getData($url, 'post', $post);
449 449
 		if ($data != '') {
450 450
 			$table = $Common->table2array($data);
451 451
 			//print_r($table);
452 452
 			if (count($table) > 0) {
453 453
 				$flight = $table;
454
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
455
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
454
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
455
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
456 456
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
457 457
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
458
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
459
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
458
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
459
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
460 460
 				if ($arrivalTime == 'Hora estimada de llegada') {
461
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
462
-				} else $arrivalTime = substr($arrivalTime,0,5);
463
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
461
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
462
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
463
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
464 464
 			}
465 465
 		}
466 466
 		return array();
@@ -473,11 +473,11 @@  discard block
 block discarded – undo
473 473
 	* @return Flight departure and arrival airports and time
474 474
 	*/
475 475
 
476
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
476
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
477 477
 		$Common = new Common();
478
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
478
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
479 479
 		$check_date = new Datetime($date);
480
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
480
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
481 481
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
482 482
 		$data = $Common->getData($url);
483 483
 		if ($data != '') {
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 				$flight = $table;
487 487
 				//print_r($table);
488 488
 				if (isset($flight[25]) && isset($flight[29])) {
489
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
490
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
489
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
490
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
491 491
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
492 492
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
493
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
494
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
495
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
493
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
494
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
495
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
496 496
 				} else return array();
497 497
 			}
498 498
 			
@@ -510,10 +510,10 @@  discard block
 block discarded – undo
510 510
 	*/
511 511
 	private function getAlitalia($callsign, $date = 'NOW') {
512 512
 		$Common = new Common();
513
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
513
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
514 514
 		$check_date = new Datetime($date);
515
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
516
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
515
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
516
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
517 517
 		$data = $Common->getData($url);
518 518
 		if ($data != '') {
519 519
 			$table = $Common->text2array($data);
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 			$ArrivalAirportIata = '';
522 522
 			$departureTime = $table[4];
523 523
 			$arrivalTime = $table[5];
524
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
524
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
525 525
 		}
526 526
 	}
527 527
 
@@ -533,21 +533,21 @@  discard block
 block discarded – undo
533 533
 	*/
534 534
 	private function getBrussels($callsign, $date = 'NOW') {
535 535
 		$Common = new Common();
536
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
536
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
537 537
 		$check_date = new Datetime($date);
538
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
538
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
539 539
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
540
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
540
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
541 541
 		$data = $Common->getData($url);
542 542
 		if ($data != '') {
543 543
 		    //echo $data;
544
-		    $parsed_json = json_decode($data,true);
544
+		    $parsed_json = json_decode($data, true);
545 545
 		    if (isset($parsed_json[0]['FromAirportCode'])) {
546 546
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
547 547
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
548
-			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
549
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
550
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
548
+			$departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate']));
549
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate']));
550
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
551 551
 		    }
552 552
 		}
553 553
 	}
@@ -624,21 +624,21 @@  discard block
 block discarded – undo
624 624
 	*/
625 625
 	private function getFlyTap($callsign) {
626 626
 		$Common = new Common();
627
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
628
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
627
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
628
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
629 629
 		//$check_date = new Datetime($date);
630
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
631
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
632
-		$data = $Common->getData($url,'post',$post);
630
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
631
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
632
+		$data = $Common->getData($url, 'post', $post);
633 633
 		if ($data != '') {
634 634
 			$table = $Common->table2array($data);
635
-			$departureTime = trim(substr($table[15][0],0,5));
636
-			$arrivalTime = trim(substr($table[35][0],0,5));
637
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
638
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
635
+			$departureTime = trim(substr($table[15][0], 0, 5));
636
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
637
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
638
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
639 639
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
640 640
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
641
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
641
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
642 642
 		}
643 643
 		return array();
644 644
 	}
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
 			} 
661 661
 		}
662 662
 		if ($airline_icao == '') return array();
663
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
664
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
663
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
664
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
665 665
 		//$check_date = new Datetime($date);
666
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
666
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
667 667
 		$data = $Common->getData($url);
668 668
 		if ($data != '') {
669 669
 			$table = $Common->table2array($data);
@@ -673,13 +673,13 @@  discard block
 block discarded – undo
673 673
 				$darr = '';
674 674
 				$ahour = '';
675 675
 				$aarr = '';
676
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
676
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
677 677
 				if ($n == 7) {
678 678
 				    $departureTime = $dhour;
679 679
 				    $arrivalTime = $ahour;
680
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
681
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
682
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
680
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
681
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
682
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
683 683
 				}
684 684
 			}
685 685
 		}
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 			$url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign;
712 712
 			$data = $Common->getData($url);
713 713
 			if ($data != '') {
714
-				$result = json_decode($data,true);
714
+				$result = json_decode($data, true);
715 715
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
716 716
 				if (isset($flight['origin'])) {
717 717
 					return array(
@@ -724,18 +724,18 @@  discard block
 block discarded – undo
724 724
 			}
725 725
 		}
726 726
 		
727
-		$url= "http://flightaware.com/live/flight/".$callsign;
727
+		$url = "http://flightaware.com/live/flight/".$callsign;
728 728
 		$data = $Common->getData($url);
729 729
 		if ($data != '') {
730
-			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result);
731
-			$flights = json_decode($result[1],true);
730
+			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result);
731
+			$flights = json_decode($result[1], true);
732 732
 			$flight = reset($flights['flights']);
733 733
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
734 734
 				return array(
735 735
 				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
736
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
736
+				    'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
737 737
 				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
738
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
738
+				    'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
739 739
 				    'Source' => 'website_flightaware');
740 740
 			}
741 741
 		}
@@ -749,20 +749,20 @@  discard block
 block discarded – undo
749 749
 	*/
750 750
 	public function getCostToTravel($callsign) {
751 751
 		$Common = new Common();
752
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
752
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
753 753
 		//$check_date = new Datetime($date);
754 754
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
755 755
 		$data = $Common->getData($url);
756 756
 		if ($data != '') {
757 757
 			$table = $Common->table2array($data);
758 758
 			if (isset($table[11][1])) {
759
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
759
+				if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5);
760 760
 				else $departureTime = '';
761
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
761
+				if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5);
762 762
 				else $arrivalTime = '';
763
-				$DepartureAirportIata = substr($table[13][1],0,3);
764
-				$ArrivalAirportIata = substr($table[15][1],0,3);
765
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
763
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
764
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
765
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
766 766
 			}
767 767
 		}
768 768
 		return array();
@@ -774,14 +774,14 @@  discard block
 block discarded – undo
774 774
 	* @param String $date date we want flight number info
775 775
 	* @return Flight departure and arrival airports and time
776 776
 	*/
777
-	private function getAirCanada($callsign,$date = 'NOW') {
777
+	private function getAirCanada($callsign, $date = 'NOW') {
778 778
 		$Common = new Common();
779 779
 		if (class_exists("DomDocument") === FALSE) return array();
780 780
 		date_default_timezone_set('UTC');
781 781
 		$check_date = new Datetime($date);
782
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
783
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
784
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
782
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
783
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
784
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
785 785
 		$data = $Common->getData($url);
786 786
 		$dom = new DomDocument();
787 787
 		$dom->loadXML($data);
@@ -789,11 +789,11 @@  discard block
 block discarded – undo
789 789
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
790 790
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
791 791
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
792
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
792
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
793 793
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
794 794
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
795
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
796
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
795
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
796
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
797 797
 		} else return array();
798 798
 	}
799 799
 
@@ -805,21 +805,21 @@  discard block
 block discarded – undo
805 805
 	*/
806 806
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
807 807
 		$Common = new Common();
808
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
808
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
809 809
 		$check_date = new Datetime($date);
810
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
811
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
810
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
811
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
812 812
 		$data = $Common->getData($url);
813 813
 		if ($data != '') {
814 814
 			$table = $Common->table2array($data);
815 815
 			$flight = $table;
816
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
817
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
816
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
817
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
818 818
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
819 819
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
820 820
 			$departureTime = $flight[5][1];
821 821
 			$arrivalTime = $flight[23][1];
822
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
822
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
823 823
 		}
824 824
 	}
825 825
 
@@ -830,16 +830,16 @@  discard block
 block discarded – undo
830 830
 	* @param String $carrier airline code
831 831
 	* @return Flight departure and arrival airports and time
832 832
 	*/
833
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
833
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
834 834
 		$Common = new Common();
835 835
 		date_default_timezone_set('UTC');
836 836
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
837
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
837
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
838 838
 		$check_date = new Datetime($date);
839
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
840
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
841
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
842
-		$data = $Common->getData($url,'post',$post);
839
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
840
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
841
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
842
+		$data = $Common->getData($url, 'post', $post);
843 843
 		//echo $data;
844 844
 		$DepartureAirportIata = '';
845 845
 		$ArrivalAirportIata = '';
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
853 853
 			else $departureAirport = '';
854 854
 		} else return array();
855
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
856
-		$data = $Common->getData($url,'post',$post);
855
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
856
+		$data = $Common->getData($url, 'post', $post);
857 857
 		if ($data != '') {
858 858
 			$table = $Common->table2array($data);
859 859
 			$flight = $table;
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 			}
882 882
 		}
883 883
 		if (isset($DepartureAirportIata)) {
884
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
884
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
885 885
 		} else return array();
886 886
 	}
887 887
 
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 	 * @param String $date Date
892 892
 	 * @return Array Schedules info
893 893
 	*/
894
-	public function fetchSchedule($ident,$date = 'NOW') {
894
+	public function fetchSchedule($ident, $date = 'NOW') {
895 895
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline;
896 896
 		//$Common = new Common();
897 897
 		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 				// Brussels Airlines
962 962
 				case "BEL":
963 963
 				case "SN":
964
-					return $this->getBrussels($ident,$date);
964
+					return $this->getBrussels($ident, $date);
965 965
 /*
966 966
 				// Copa Airlines
967 967
 				case "CMP":
@@ -1046,17 +1046,17 @@  discard block
 block discarded – undo
1046 1046
 				// Air France
1047 1047
 				case "AF":
1048 1048
 				case "AFR":
1049
-					return $this->getAirFrance($ident,$date,'AF');
1049
+					return $this->getAirFrance($ident, $date, 'AF');
1050 1050
 				// HOP
1051 1051
 				case "A5":
1052 1052
 				case "HOP":
1053
-					return $this->getAirFrance($ident,$date,'A5');
1053
+					return $this->getAirFrance($ident, $date, 'A5');
1054 1054
 				// EasyJet
1055 1055
 				case "U2":
1056 1056
 				case "DS":
1057 1057
 				case "EZY":
1058 1058
 				case "EZS":
1059
-					return $this->getEasyJet($ident,$date);
1059
+					return $this->getEasyJet($ident, $date);
1060 1060
 				// Ryanair
1061 1061
 				case "FR":
1062 1062
 				case "RYR":
@@ -1106,25 +1106,25 @@  discard block
 block discarded – undo
1106 1106
 					return $this->getIberia($ident);
1107 1107
 				// Vietnam Airlines
1108 1108
 				case "HVN":
1109
-					return $this->getVietnamAirlines($ident,$date);
1109
+					return $this->getVietnamAirlines($ident, $date);
1110 1110
 				// Air Berlin
1111 1111
 				case "AB":
1112 1112
 				case "BER":
1113
-					return $this->getAirBerlin($ident,$date,'AB');
1113
+					return $this->getAirBerlin($ident, $date, 'AB');
1114 1114
 				// NIKI
1115 1115
 				case "HG":
1116 1116
 				case "NLY":
1117
-					return $this->getAirBerlin($ident,$date,'HG');
1117
+					return $this->getAirBerlin($ident, $date, 'HG');
1118 1118
 				// BelAir
1119 1119
 				case "4T":
1120 1120
 				case "BHP":
1121
-					return $this->getAirBerlin($ident,$date,'4T');
1121
+					return $this->getAirBerlin($ident, $date, '4T');
1122 1122
 				default:
1123 1123
 					// Randomly use a generic function to get hours
1124 1124
 					if (strlen($airline_icao) == 2) {
1125
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1125
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1126 1126
 						if (count($globalSchedulesSources) > 0) {
1127
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1127
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1128 1128
 							$source = $globalSchedulesSources[$rand];
1129 1129
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1130 1130
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
Braces   +177 added lines, -61 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 	public function __construct($dbc = null) {
24 24
 		$Connection = new Connection($dbc);
25 25
 		$this->db = $Connection->db();
26
-		if ($this->db === null) die('Error: No DB connection.');
26
+		if ($this->db === null) {
27
+			die('Error: No DB connection.');
28
+		}
27 29
 	}
28 30
 
29 31
 	/**
@@ -138,7 +140,9 @@  discard block
 block discarded – undo
138 140
 		$sth->closeCursor();
139 141
 		if (count($row) > 0) {
140 142
 			return $row;
141
-		} else return array();
143
+		} else {
144
+			return array();
145
+		}
142 146
 	}
143 147
 
144 148
 	/*
@@ -179,7 +183,9 @@  discard block
 block discarded – undo
179 183
 		$Common = new Common();
180 184
 		$check_date = new Datetime($date);
181 185
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
182
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
186
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
187
+			return array();
188
+		}
183 189
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
184 190
 		$json = $Common->getData($url);
185 191
 	
@@ -206,7 +212,9 @@  discard block
 block discarded – undo
206 212
 			*/
207 213
 		
208 214
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
209
-		} else return array();
215
+		} else {
216
+			return array();
217
+		}
210 218
 	}
211 219
 
212 220
 	/**
@@ -221,7 +229,9 @@  discard block
 block discarded – undo
221 229
 		date_default_timezone_set($globalTimezone);
222 230
 		$check_date = new Datetime($date);
223 231
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
224
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
232
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
233
+			return array();
234
+		}
225 235
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
226 236
 		$json = $Common->getData($url);
227 237
 		$parsed_json = json_decode($json);
@@ -234,7 +244,9 @@  discard block
 block discarded – undo
234 244
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
235 245
 
236 246
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
237
-		} else return array();
247
+		} else {
248
+			return array();
249
+		}
238 250
 	}
239 251
 
240 252
 	/**
@@ -245,7 +257,9 @@  discard block
 block discarded – undo
245 257
 	private function getRyanair($callsign) {
246 258
 		$Common = new Common();
247 259
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
248
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
260
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
261
+			return array();
262
+		}
249 263
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
250 264
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
251 265
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -259,8 +273,12 @@  discard block
 block discarded – undo
259 273
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
260 274
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
261 275
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
262
-			} else return array();
263
-		} else return array();
276
+			} else {
277
+				return array();
278
+			}
279
+		} else {
280
+			return array();
281
+		}
264 282
 	}
265 283
 
266 284
 	/**
@@ -271,7 +289,9 @@  discard block
 block discarded – undo
271 289
 	private function getSwiss($callsign) {
272 290
 		$Common = new Common();
273 291
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
274
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
292
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
293
+			return array();
294
+		}
275 295
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
276 296
 		$json = $Common->getData($url);
277 297
 		$parsed_json = json_decode($json);
@@ -291,8 +311,12 @@  discard block
 block discarded – undo
291 311
 			}
292 312
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
293 313
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
294
-			} else return array();
295
-		} else return array();
314
+			} else {
315
+				return array();
316
+			}
317
+		} else {
318
+			return array();
319
+		}
296 320
 	}
297 321
 	
298 322
 	/**
@@ -306,12 +330,18 @@  discard block
 block discarded – undo
306 330
 		$Common = new Common();
307 331
 		$check_date = new Datetime($date);
308 332
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
309
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
310
-		if ($globalBritishAirwaysKey == '') return array();
333
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
334
+			return array();
335
+		}
336
+		if ($globalBritishAirwaysKey == '') {
337
+			return array();
338
+		}
311 339
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
312 340
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
313 341
 		$json = $Common->getData($url,'get','',$headers);
314
-		if ($json == '') return array();
342
+		if ($json == '') {
343
+			return array();
344
+		}
315 345
 		$parsed_json = json_decode($json);
316 346
 		$flights = $parsed_json->{'FlightsResponse'};
317 347
 		if (count($flights) > 0) {
@@ -320,7 +350,9 @@  discard block
 block discarded – undo
320 350
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
321 351
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
322 352
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
323
-		} else return array();
353
+		} else {
354
+			return array();
355
+		}
324 356
 	}
325 357
 
326 358
 	/**
@@ -334,19 +366,27 @@  discard block
 block discarded – undo
334 366
 		$Common = new Common();
335 367
 		$check_date = new Datetime($date);
336 368
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
337
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
338
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
369
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
370
+			return array();
371
+		}
372
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
373
+			return array();
374
+		}
339 375
 		$url = "https://api.lufthansa.com/v1/oauth/token";
340 376
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
341 377
 		$data = $Common->getData($url,'post',$post);
342 378
 		$parsed_data = json_decode($data);
343
-		if (!isset($parsed_data->{'access_token'})) return array();
379
+		if (!isset($parsed_data->{'access_token'})) {
380
+			return array();
381
+		}
344 382
 		$token = $parsed_data->{'access_token'};
345 383
 		
346 384
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
347 385
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
348 386
 		$json = $Common->getData($url,'get','',$headers);
349
-		if ($json == '') return array();
387
+		if ($json == '') {
388
+			return array();
389
+		}
350 390
 		$parsed_json = json_decode($json);
351 391
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
352 392
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -354,7 +394,9 @@  discard block
 block discarded – undo
354 394
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
355 395
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
356 396
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
357
-		} else return array();
397
+		} else {
398
+			return array();
399
+		}
358 400
 	}
359 401
 
360 402
 	/**
@@ -368,14 +410,20 @@  discard block
 block discarded – undo
368 410
 		$Common = new Common();
369 411
 		$check_date = new Datetime($date);
370 412
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
371
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
372
-		if ($globalTransaviaKey == '') return array();
413
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
414
+			return array();
415
+		}
416
+		if ($globalTransaviaKey == '') {
417
+			return array();
418
+		}
373 419
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
374 420
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
375 421
 		$headers = array('apikey: '.$globalTransaviaKey);
376 422
 		$json = $Common->getData($url,'get','',$headers);
377 423
 		//echo 'result : '.$json;
378
-		if ($json == '') return array();
424
+		if ($json == '') {
425
+			return array();
426
+		}
379 427
 		$parsed_json = json_decode($json);
380 428
 		
381 429
 		if (isset($parsed_json->{'data'}[0])) {
@@ -384,7 +432,9 @@  discard block
 block discarded – undo
384 432
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
385 433
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
386 434
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
387
-		} else return array();
435
+		} else {
436
+			return array();
437
+		}
388 438
 	}
389 439
 
390 440
 	/**
@@ -395,7 +445,9 @@  discard block
 block discarded – undo
395 445
 	public function getTunisair($callsign) {
396 446
 		$Common = new Common();
397 447
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
398
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
448
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
449
+			return array();
450
+		}
399 451
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
400 452
 		$data = $Common->getData($url);
401 453
 		$table = $Common->table2array($data);
@@ -416,7 +468,9 @@  discard block
 block discarded – undo
416 468
 		$Common = new Common();
417 469
 		$check_date = new Datetime($date);
418 470
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
419
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
471
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
472
+			return array();
473
+		}
420 474
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
421 475
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
422 476
 		$data = $Common->getData($url);
@@ -426,8 +480,11 @@  discard block
 block discarded – undo
426 480
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
427 481
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
428 482
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
429
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
430
-			else return array();
483
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
484
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
485
+			} else {
486
+				return array();
487
+			}
431 488
 		}
432 489
 		return array();
433 490
 	}
@@ -442,7 +499,9 @@  discard block
 block discarded – undo
442 499
 		$Common = new Common();
443 500
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
444 501
 		$check_date = new Datetime($date);
445
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
502
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
503
+			return array();
504
+		}
446 505
 		$url = "https://www.iberia.com/web/flightDetail.do";
447 506
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
448 507
 		$data = $Common->getData($url,'post',$post);
@@ -459,7 +518,9 @@  discard block
 block discarded – undo
459 518
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
460 519
 				if ($arrivalTime == 'Hora estimada de llegada') {
461 520
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
462
-				} else $arrivalTime = substr($arrivalTime,0,5);
521
+				} else {
522
+					$arrivalTime = substr($arrivalTime,0,5);
523
+				}
463 524
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
464 525
 			}
465 526
 		}
@@ -477,7 +538,9 @@  discard block
 block discarded – undo
477 538
 		$Common = new Common();
478 539
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
479 540
 		$check_date = new Datetime($date);
480
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
541
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
542
+			return array();
543
+		}
481 544
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
482 545
 		$data = $Common->getData($url);
483 546
 		if ($data != '') {
@@ -493,7 +556,9 @@  discard block
 block discarded – undo
493 556
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
494 557
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
495 558
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
496
-				} else return array();
559
+				} else {
560
+					return array();
561
+				}
497 562
 			}
498 563
 			
499 564
 
@@ -513,7 +578,9 @@  discard block
 block discarded – undo
513 578
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
514 579
 		$check_date = new Datetime($date);
515 580
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
516
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
581
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
582
+			return array();
583
+		}
517 584
 		$data = $Common->getData($url);
518 585
 		if ($data != '') {
519 586
 			$table = $Common->text2array($data);
@@ -537,7 +604,9 @@  discard block
 block discarded – undo
537 604
 		$check_date = new Datetime($date);
538 605
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
539 606
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
540
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
607
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
608
+			return array();
609
+		}
541 610
 		$data = $Common->getData($url);
542 611
 		if ($data != '') {
543 612
 		    //echo $data;
@@ -627,7 +696,9 @@  discard block
 block discarded – undo
627 696
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
628 697
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
629 698
 		//$check_date = new Datetime($date);
630
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
699
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
700
+			return array();
701
+		}
631 702
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
632 703
 		$data = $Common->getData($url,'post',$post);
633 704
 		if ($data != '') {
@@ -659,11 +730,15 @@  discard block
 block discarded – undo
659 730
 				$airline_icao = substr($callsign, 0, 3);
660 731
 			} 
661 732
 		}
662
-		if ($airline_icao == '') return array();
733
+		if ($airline_icao == '') {
734
+			return array();
735
+		}
663 736
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
664 737
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
665 738
 		//$check_date = new Datetime($date);
666
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
739
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
740
+			return array();
741
+		}
667 742
 		$data = $Common->getData($url);
668 743
 		if ($data != '') {
669 744
 			$table = $Common->table2array($data);
@@ -756,10 +831,16 @@  discard block
 block discarded – undo
756 831
 		if ($data != '') {
757 832
 			$table = $Common->table2array($data);
758 833
 			if (isset($table[11][1])) {
759
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
760
-				else $departureTime = '';
761
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
762
-				else $arrivalTime = '';
834
+				if (is_numeric(substr($table[11][1],0,1))) {
835
+					$departureTime = substr($table[11][1],0,5);
836
+				} else {
837
+					$departureTime = '';
838
+				}
839
+				if (is_numeric(substr($table[17][1],0,1))) {
840
+					$arrivalTime = substr($table[17][1],0,5);
841
+				} else {
842
+					$arrivalTime = '';
843
+				}
763 844
 				$DepartureAirportIata = substr($table[13][1],0,3);
764 845
 				$ArrivalAirportIata = substr($table[15][1],0,3);
765 846
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
@@ -776,16 +857,22 @@  discard block
 block discarded – undo
776 857
 	*/
777 858
 	private function getAirCanada($callsign,$date = 'NOW') {
778 859
 		$Common = new Common();
779
-		if (class_exists("DomDocument") === FALSE) return array();
860
+		if (class_exists("DomDocument") === FALSE) {
861
+			return array();
862
+		}
780 863
 		date_default_timezone_set('UTC');
781 864
 		$check_date = new Datetime($date);
782 865
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
783 866
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
784
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
867
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
868
+			return array();
869
+		}
785 870
 		$data = $Common->getData($url);
786 871
 		$dom = new DomDocument();
787 872
 		$dom->loadXML($data);
788
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
873
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
874
+			return array();
875
+		}
789 876
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
790 877
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
791 878
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -794,7 +881,9 @@  discard block
 block discarded – undo
794 881
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
795 882
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
796 883
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
797
-		} else return array();
884
+		} else {
885
+			return array();
886
+		}
798 887
 	}
799 888
 
800 889
 	/**
@@ -808,7 +897,9 @@  discard block
 block discarded – undo
808 897
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
809 898
 		$check_date = new Datetime($date);
810 899
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
811
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
900
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
901
+			return array();
902
+		}
812 903
 		$data = $Common->getData($url);
813 904
 		if ($data != '') {
814 905
 			$table = $Common->table2array($data);
@@ -837,7 +928,9 @@  discard block
 block discarded – undo
837 928
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
838 929
 		$check_date = new Datetime($date);
839 930
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
840
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
931
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
932
+			return array();
933
+		}
841 934
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
842 935
 		$data = $Common->getData($url,'post',$post);
843 936
 		//echo $data;
@@ -847,11 +940,19 @@  discard block
 block discarded – undo
847 940
 		if ($data != '') {
848 941
 			$table = $Common->table2array($data);
849 942
 			$flight = $table;
850
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
851
-			else $departureTime = '';
852
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
853
-			else $departureAirport = '';
854
-		} else return array();
943
+			if (isset($flight[5][4])) {
944
+				$departureTime = $flight[5][4];
945
+			} else {
946
+				$departureTime = '';
947
+			}
948
+			if (isset($flight[5][2])) {
949
+				$departureAirport = $flight[5][2];
950
+			} else {
951
+				$departureAirport = '';
952
+			}
953
+		} else {
954
+			return array();
955
+		}
855 956
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
856 957
 		$data = $Common->getData($url,'post',$post);
857 958
 		if ($data != '') {
@@ -864,10 +965,14 @@  discard block
 block discarded – undo
864 965
 			    $arrivalTime = '';
865 966
 			    $arrivalAirport = '';
866 967
 			}
867
-		} else return array();
968
+		} else {
969
+			return array();
970
+		}
868 971
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
869 972
 		$json = $Common->getData($url);
870
-		if ($json == '') return array();
973
+		if ($json == '') {
974
+			return array();
975
+		}
871 976
 		$parsed_json = json_decode($json);
872 977
 		$airports = $parsed_json->{'suggestList'};
873 978
 		if (count($airports) > 0) {
@@ -882,7 +987,9 @@  discard block
 block discarded – undo
882 987
 		}
883 988
 		if (isset($DepartureAirportIata)) {
884 989
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
885
-		} else return array();
990
+		} else {
991
+			return array();
992
+		}
886 993
 	}
887 994
 
888 995
 	/*
@@ -894,7 +1001,9 @@  discard block
 block discarded – undo
894 1001
 	public function fetchSchedule($ident,$date = 'NOW') {
895 1002
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline;
896 1003
 		//$Common = new Common();
897
-		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
1004
+		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) {
1005
+			return array();
1006
+		}
898 1007
 		$airline_icao = '';
899 1008
 		if (!is_numeric(substr($ident, 0, 3)))
900 1009
 		{
@@ -1122,14 +1231,21 @@  discard block
 block discarded – undo
1122 1231
 				default:
1123 1232
 					// Randomly use a generic function to get hours
1124 1233
 					if (strlen($airline_icao) == 2) {
1125
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1234
+						if (!isset($globalSchedulesSources)) {
1235
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1236
+						}
1126 1237
 						if (count($globalSchedulesSources) > 0) {
1127 1238
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1128 1239
 							$source = $globalSchedulesSources[$rand];
1129
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1130
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1240
+							if ($source == 'flightmapper') {
1241
+								return $this->getFlightMapper($ident);
1242
+							} elseif ($source == 'costtotravel') {
1243
+								return $this->getCostToTravel($ident);
1244
+							}
1131 1245
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1132
-							elseif ($source == 'flightaware') return $this->getFlightAware($ident);
1246
+							elseif ($source == 'flightaware') {
1247
+								return $this->getFlightAware($ident);
1248
+							}
1133 1249
 						}
1134 1250
 					}
1135 1251
 			}
Please login to merge, or discard this patch.
header.php 3 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 // When button "Remove all filters" is clicked
39 39
 if (isset($_POST['removefilters'])) {
40 40
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
41
-	    return strpos($key,'filter_') === 0;
41
+		return strpos($key,'filter_') === 0;
42 42
 	});
43 43
 	foreach ($allfilters as $filt) {
44 44
 		unset($_COOKIE[$filt]);
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 	}
189 189
 ?>
190 190
 <?php 
191
-    if (isset($_POST['archive'])) {
191
+	if (isset($_POST['archive'])) {
192 192
 ?>
193 193
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
194 194
 <?php 
195
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
195
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
196 196
 ?>
197 197
 
198 198
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
199 199
 <?php    
200
-	    }
201
-    } else {
200
+		}
201
+	} else {
202 202
 ?>
203 203
 <?php
204 204
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 */
211 211
 ?>
212 212
 <?php 
213
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
213
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
214 214
 ?>
215 215
 <?php
216 216
 //		if (isset($globalBeta) && $globalBeta) {
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
 <script src="<?php print $globalURL; ?>/js/map-satellite.2d.js.php?<?php print time(); ?>"></script>
242 242
 <?php
243 243
 		}
244
-	    }
244
+		}
245 245
 ?>
246 246
 <?php
247 247
 //	}
248 248
 ?>
249 249
 <?php
250
-    }
250
+	}
251 251
 }
252 252
 ?>
253 253
 <?php
@@ -424,34 +424,34 @@  discard block
 block discarded – undo
424 424
 
425 425
       <ul class="nav navbar-nav">
426 426
 <?php
427
-    if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) {
427
+	if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) {
428 428
 ?>
429 429
     <li><a href="<?php print $globalURL; ?>/news"><?php echo _("News"); ?></a></li>
430 430
 <?php
431
-    }
431
+	}
432 432
 ?>
433 433
 
434 434
 <?php 
435
-    $sub = false;
436
-    if (
435
+	$sub = false;
436
+	if (
437 437
 	(
438
-	    (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
438
+		(!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
439 439
 	) || 
440 440
 	(
441
-	    isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
441
+		isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
442 442
 	) || 
443 443
 	(
444
-	    isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
444
+		isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
445 445
 	) || 
446 446
 	(
447
-	    isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
447
+		isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
448 448
 	)
449
-    ) {
449
+	) {
450 450
 	$sub = true;
451
-    }
451
+	}
452 452
 ?>
453 453
 <?php
454
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
454
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
455 455
 ?>
456 456
     <li class="dropdown">
457 457
 <?php
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 	<ul class="dropdown-menu multi-level">
463 463
       	<li class="dropdown-submenu">
464 464
 <?php
465
-        }
465
+		}
466 466
 ?>
467 467
 <?php
468 468
 	if (isset($globalNewsFeeds['aircraft']) && !empty($globalNewsFeeds['aircraft'])) {
@@ -477,25 +477,25 @@  discard block
 block discarded – undo
477 477
           <ul class="dropdown-menu">
478 478
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
479 479
 <?php
480
-    if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
480
+	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
481 481
 ?>
482 482
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
483 483
 <?php
484
-    }
484
+	}
485 485
 ?>
486 486
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
487 487
 <?php
488
-    if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
488
+	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
489 489
 ?>
490 490
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
491 491
 <?php
492
-    } 
493
-    if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
492
+	} 
493
+	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
494 494
 
495 495
 ?>
496 496
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
497 497
 <?php
498
-    }
498
+	}
499 499
 ?>
500 500
 			<li><hr /></li>
501 501
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -503,43 +503,43 @@  discard block
 block discarded – undo
503 503
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
504 504
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
505 505
             <?php
506
-        	if ($globalACARS) {
507
-        	    if (isset($globalDemo) && $globalDemo) {
508
-    	    ?>
506
+			if ($globalACARS) {
507
+				if (isset($globalDemo) && $globalDemo) {
508
+			?>
509 509
             <li><hr /></li>
510 510
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
511 511
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
512 512
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
513 513
             <?php
514
-        	    } else {
515
-    	    ?>
514
+				} else {
515
+			?>
516 516
             <li><hr /></li>
517 517
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
518 518
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
519 519
             <?php
520
-        	    }
521
-        	}
522
-    	    ?>
520
+				}
521
+			}
522
+			?>
523 523
     	    <?php
524
-    	        if (isset($globalAccidents) && $globalAccidents) {
525
-    	    ?>
524
+				if (isset($globalAccidents) && $globalAccidents) {
525
+			?>
526 526
             <li><hr /></li>
527 527
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
528 528
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
529 529
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
530 530
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
531 531
             <?php
532
-        	}
533
-    	    ?>
532
+			}
533
+			?>
534 534
             <li><hr /></li>
535 535
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
536 536
             <?php
537 537
 		if (!isset($globalNoUpcoming) || $globalNoUpcoming === FALSE) {
538
-	    ?>
538
+		?>
539 539
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
540 540
 	    <?php
541 541
 		}
542
-	    ?>
542
+		?>
543 543
           </ul>
544 544
         </li>
545 545
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
@@ -566,14 +566,14 @@  discard block
 block discarded – undo
566 566
     </ul>
567 567
 <?php
568 568
 	}
569
-    }
569
+	}
570 570
 ?>
571 571
 <?php
572
-    if (isset($globalMarine) && $globalMarine) {
572
+	if (isset($globalMarine) && $globalMarine) {
573 573
 ?>
574 574
     <li class="dropdown">
575 575
 <?php
576
-        if ($sub) {
576
+		if ($sub) {
577 577
 ?>
578 578
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Marines"); ?> <b class="caret"></b></a>
579 579
 	<ul class="dropdown-menu multi-level">
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
 	}
608 608
 ?>
609 609
 <?php
610
-    }
610
+	}
611 611
 ?>
612 612
 <?php
613
-    if (isset($globalTracker) && $globalTracker) {
613
+	if (isset($globalTracker) && $globalTracker) {
614 614
 ?>
615 615
     <li class="dropdown">
616 616
 <?php
617
-        if ($sub) {
617
+		if ($sub) {
618 618
 ?>
619 619
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a>
620 620
 	<ul class="dropdown-menu multi-level">
@@ -648,14 +648,14 @@  discard block
 block discarded – undo
648 648
 	}
649 649
 ?>
650 650
 <?php
651
-    }
651
+	}
652 652
 ?>
653 653
 <?php
654
-    if (isset($globalSatellite) && $globalSatellite) {
654
+	if (isset($globalSatellite) && $globalSatellite) {
655 655
 ?>
656 656
     <li class="dropdown">
657 657
 <?php
658
-        if ($sub) {
658
+		if ($sub) {
659 659
 ?>
660 660
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Satellites"); ?> <b class="caret"></b></a>
661 661
 	<ul class="dropdown-menu multi-level">
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 	}
692 692
 ?>
693 693
 <?php
694
-    }
694
+	}
695 695
 ?>
696 696
 
697 697
         <li class="dropdown">
@@ -700,12 +700,12 @@  discard block
 block discarded – undo
700 700
           	<li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li>
701 701
           	<li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li>
702 702
 <?php
703
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
703
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
704 704
 ?>
705 705
 		<li><hr /></li>
706 706
 		<li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li>
707 707
 <?php
708
-    }
708
+	}
709 709
 ?>
710 710
 	    <?php if (isset($globalContribute) && $globalContribute) { ?>
711 711
                 <li><hr /></li>
@@ -726,14 +726,14 @@  discard block
 block discarded – undo
726 726
   	    <form>
727 727
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
728 728
   		    <?php
729
-  		        $Language = new Language();
730
-  		        $alllang = $Language->getLanguages();
731
-  		        foreach ($alllang as $key => $lang) {
732
-  		            print '<option value="'.$key.'"';
733
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
734
-  		            print '>'.$lang[0].'</option>';
735
-  		        }
736
-  		    ?>
729
+  				$Language = new Language();
730
+  				$alllang = $Language->getLanguages();
731
+  				foreach ($alllang as $key => $lang) {
732
+  					print '<option value="'.$key.'"';
733
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
734
+  					print '>'.$lang[0].'</option>';
735
+  				}
736
+  			?>
737 737
   		</select>
738 738
   	    </form>
739 739
   	</div>
@@ -765,18 +765,18 @@  discard block
 block discarded – undo
765 765
 ?>
766 766
     <div class="top-header clear" role="main">
767 767
 <?php
768
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
768
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
769 769
 ?>
770 770
     <div id="archive-map"></div>
771 771
 <?php
772
-    }
772
+	}
773 773
 ?>
774 774
     </div>
775 775
 <?php
776 776
 }
777 777
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
778 778
 {
779
-    ?>
779
+	?>
780 780
     <div class="top-header clear" role="main">
781 781
         <div id="map"></div>
782 782
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -787,15 +787,15 @@  discard block
 block discarded – undo
787 787
         var zoom = 13;
788 788
 //create the map
789 789
 <?php
790
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
790
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
791 791
 ?>
792 792
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
793 793
 <?php
794
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
794
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
795 795
 ?>
796 796
   map = L.map('map', { zoomControl:true });
797 797
 <?php
798
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
798
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
799 799
 ?>
800 800
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
801 801
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -803,22 +803,22 @@  discard block
 block discarded – undo
803 803
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
804 804
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
805 805
 <?php
806
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
806
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
807 807
 ?>
808 808
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
809 809
 <?php
810
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
810
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
811 811
 ?>
812 812
   map = L.map('map', { zoomControl:true });
813 813
 <?php
814
-    }
814
+	}
815 815
 ?>
816 816
   //initialize the layer group for the aircrft markers
817 817
   var layer_data = L.layerGroup();
818 818
 
819 819
   //a few title layers
820 820
 <?php
821
-    if ($globalMapProvider == 'Mapbox') {
821
+	if ($globalMapProvider == 'Mapbox') {
822 822
 ?>
823 823
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
824 824
     maxZoom: 18,
@@ -829,14 +829,14 @@  discard block
 block discarded – undo
829 829
     token : '<?php print $globalMapboxToken; ?>'
830 830
   }).addTo(map);
831 831
 <?php
832
-    } elseif ($globalMapProvider == 'Mapbox-GL') {
832
+	} elseif ($globalMapProvider == 'Mapbox-GL') {
833 833
 ?>
834 834
     L.mapboxGL({
835 835
 	accessToken: '<?php print $globalMapboxToken; ?>',
836 836
 	style: 'mapbox://styles/mapbox/bright-v8'
837 837
   }).addTo(map);
838 838
 <?php
839
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
839
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
840 840
 ?>
841 841
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
842 842
     maxZoom: 18,
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
846 846
   }).addTo(map);
847 847
 <?php
848
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
848
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
849 849
 ?>
850 850
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
851 851
     maxZoom: 18,
@@ -854,27 +854,27 @@  discard block
 block discarded – undo
854 854
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
855 855
   }).addTo(map);
856 856
 <?php
857
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
857
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
858 858
 ?>
859 859
     var googleLayer = new L.Google('ROADMAP');
860 860
     map.addLayer(googleLayer);
861 861
 <?php
862
-    } elseif ($globalMapProvider == 'Google-Satellite') {
862
+	} elseif ($globalMapProvider == 'Google-Satellite') {
863 863
 ?>
864 864
     var googleLayer = new L.Google('SATELLITE');
865 865
     map.addLayer(googleLayer);
866 866
 <?php
867
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
867
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
868 868
 ?>
869 869
     var googleLayer = new L.Google('HYBRID');
870 870
     map.addLayer(googleLayer);
871 871
 <?php
872
-    } elseif ($globalMapProvider == 'Google-Terrain') {
872
+	} elseif ($globalMapProvider == 'Google-Terrain') {
873 873
 ?>
874 874
     var googleLayer = new L.Google('Terrain');
875 875
     map.addLayer(googleLayer);
876 876
 <?php
877
-    } elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
877
+	} elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
878 878
 	$customid = $globalMapProvider;
879 879
 ?>
880 880
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
885 885
     }).addTo(map);
886 886
 <?php
887
-    } elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) {
887
+	} elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) {
888 888
 ?>
889 889
     var center = map.getCenter();
890 890
     map.options.crs = L.CRS.EPSG4326;
@@ -899,8 +899,8 @@  discard block
 block discarded – undo
899 899
         attribution: 'Natural Earth'
900 900
     }).addTo(map);
901 901
 <?php
902
-    //} elseif ($globalMapProvider == 'OpenStreetMap') {
903
-    } else {
902
+	//} elseif ($globalMapProvider == 'OpenStreetMap') {
903
+	} else {
904 904
 ?>
905 905
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
906 906
     maxZoom: 18,
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
   }).addTo(map);
910 910
 
911 911
 <?php
912
-    }
912
+	}
913 913
 ?>
914 914
         </script>
915 915
     </div>
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -14,35 +14,35 @@  discard block
 block discarded – undo
14 14
 if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
15 15
 
16 16
 if (isset($_GET['3d'])) {
17
-	setcookie('MapFormat','3d');
17
+	setcookie('MapFormat', '3d');
18 18
 } else if (isset($_GET['2d'])) {
19
-	setcookie('MapFormat','2d');
19
+	setcookie('MapFormat', '2d');
20 20
 }
21 21
 
22 22
 if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) {
23
-	$tsk = filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL);
23
+	$tsk = filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL);
24 24
 }
25 25
 
26 26
 if (isset($_POST['archive'])) {
27
-	setcookie('archive','true');
28
-	setcookie('archive_begin',strtotime($_POST['start_date']));
29
-	setcookie('archive_end',strtotime($_POST['end_date']));
30
-	setcookie('archive_speed',$_POST['archivespeed']);
27
+	setcookie('archive', 'true');
28
+	setcookie('archive_begin', strtotime($_POST['start_date']));
29
+	setcookie('archive_end', strtotime($_POST['end_date']));
30
+	setcookie('archive_speed', $_POST['archivespeed']);
31 31
 }
32 32
 if (isset($_POST['noarchive'])) {
33
-	setcookie('archive','false',-1);
34
-	setcookie('archive_begin','',-1);
35
-	setcookie('archive_end','',-1);
36
-	setcookie('archive_speed','',-1);
33
+	setcookie('archive', 'false', -1);
34
+	setcookie('archive_begin', '', -1);
35
+	setcookie('archive_end', '', -1);
36
+	setcookie('archive_speed', '', -1);
37 37
 }
38 38
 // When button "Remove all filters" is clicked
39 39
 if (isset($_POST['removefilters'])) {
40
-	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
41
-	    return strpos($key,'filter_') === 0;
40
+	$allfilters = array_filter(array_keys($_COOKIE), function($key) {
41
+	    return strpos($key, 'filter_') === 0;
42 42
 	});
43 43
 	foreach ($allfilters as $filt) {
44 44
 		unset($_COOKIE[$filt]);
45
-		setcookie($filt,null,-1);
45
+		setcookie($filt, null, -1);
46 46
 	}
47 47
 }
48 48
 ?>
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
265 265
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
266 266
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
267
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
267
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
268 268
 <?php
269 269
 		if (!isset($type) || $type == 'aircraft') {
270 270
 ?>
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
338 338
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
339 339
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
340
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
340
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
341 341
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
342 342
 <?php
343 343
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 ?>
743 743
       <div class="search">
744 744
 	<form action="<?php print $globalURL; ?>/search" method="get">
745
-		<!--<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>-->
746
-		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != ""){ print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
745
+		<!--<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>-->
746
+		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != "") { print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
747 747
 	</form>
748 748
 	</div>
749 749
   	<div class="social">
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	print '</div>';
762 762
 }
763 763
 
764
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
764
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
765 765
 ?>
766 766
     <div class="top-header clear" role="main">
767 767
 <?php
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
     </div>
775 775
 <?php
776 776
 }
777
-if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
777
+if ((strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) || (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false))
778 778
 {
779 779
     ?>
780 780
     <div class="top-header clear" role="main">
@@ -787,15 +787,15 @@  discard block
 block discarded – undo
787 787
         var zoom = 13;
788 788
 //create the map
789 789
 <?php
790
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
790
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
791 791
 ?>
792 792
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
793 793
 <?php
794
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
794
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
795 795
 ?>
796 796
   map = L.map('map', { zoomControl:true });
797 797
 <?php
798
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
798
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
799 799
 ?>
800 800
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
801 801
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
804 804
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
805 805
 <?php
806
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
806
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
807 807
 ?>
808 808
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
809 809
 <?php
Please login to merge, or discard this patch.
Braces   +90 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,12 +6,19 @@  discard block
 block discarded – undo
6 6
 //gets the page file and stores it in a variable
7 7
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
8 8
 $current_page = $file_path['filename'];
9
-if ($globalTimezone == '') $globalTimezone = 'UTC';
9
+if ($globalTimezone == '') {
10
+	$globalTimezone = 'UTC';
11
+}
10 12
 date_default_timezone_set($globalTimezone);
11
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
12
-else $MapType = $globalMapProvider;
13
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
14
+	$MapType = $_COOKIE['MapType'];
15
+} else {
16
+	$MapType = $globalMapProvider;
17
+}
13 18
 
14
-if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
19
+if (isset($globalMapOffline) && $globalMapOffline) {
20
+	$MapType = 'offline';
21
+}
15 22
 
16 23
 if (isset($_GET['3d'])) {
17 24
 	setcookie('MapFormat','3d');
@@ -219,7 +226,10 @@  discard block
 block discarded – undo
219 226
 <?php
220 227
 //		}
221 228
 ?>
222
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) print '&tsk='.$tsk; ?>"></script>
229
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) {
230
+	print '&tsk='.$tsk;
231
+}
232
+?>"></script>
223 233
 <?php
224 234
 		if (!isset($globalAircraft) || $globalAircraft) {
225 235
 ?>
@@ -264,7 +274,13 @@  discard block
 block discarded – undo
264 274
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
265 275
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
266 276
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
267
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
277
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
278
+	print '&latitude='.$latitude;
279
+}
280
+?><?php if(isset($longitude)) {
281
+	print '&longitude='.$longitude;
282
+}
283
+?>&<?php print time(); ?>"></script>
268 284
 <?php
269 285
 		if (!isset($type) || $type == 'aircraft') {
270 286
 ?>
@@ -337,7 +353,13 @@  discard block
 block discarded – undo
337 353
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
338 354
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
339 355
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
340
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
356
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
357
+	print '&latitude='.$latitude;
358
+}
359
+?><?php if(isset($longitude)) {
360
+	print '&longitude='.$longitude;
361
+}
362
+?>&<?php print time(); ?>"></script>
341 363
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
342 364
 <?php
343 365
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -418,7 +440,12 @@  discard block
 block discarded – undo
418 440
         <span class="icon-bar"></span>
419 441
       </button>
420 442
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle search"><i class="fa fa-search"></i></a>
421
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
443
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
444
+	print '/';
445
+} else {
446
+	print $globalURL;
447
+}
448
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
422 449
     </div>
423 450
     <div class="collapse navbar-collapse">
424 451
 
@@ -473,7 +500,10 @@  discard block
 block discarded – undo
473 500
 	}
474 501
 ?>
475 502
 
476
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
503
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
504
+	echo 'right-';
505
+}
506
+?>caret"></b></a>
477 507
           <ul class="dropdown-menu">
478 508
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
479 509
 <?php
@@ -544,8 +574,14 @@  discard block
 block discarded – undo
544 574
         </li>
545 575
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
546 576
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
547
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
548
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
577
+        <li class="dropdown<?php if ($sub) {
578
+	echo '-submenu';
579
+}
580
+?>">
581
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
582
+	echo 'right-';
583
+}
584
+?>caret"></b></a>
549 585
           <ul class="dropdown-menu">
550 586
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
551 587
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -589,7 +625,10 @@  discard block
 block discarded – undo
589 625
 <?php
590 626
 	}
591 627
 ?>
592
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
628
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
629
+	echo 'right-';
630
+}
631
+?>caret"></b></a>
593 632
 		<ul class="dropdown-menu">
594 633
 		    <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li>
595 634
 		    <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -630,7 +669,10 @@  discard block
 block discarded – undo
630 669
 <?php
631 670
 	}
632 671
 ?>
633
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
672
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
673
+	echo 'right-';
674
+}
675
+?>caret"></b></a>
634 676
 		<ul class="dropdown-menu">
635 677
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
636 678
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -673,7 +715,10 @@  discard block
 block discarded – undo
673 715
 ?>
674 716
 
675 717
 <!--
676
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
718
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
719
+	echo 'right-';
720
+}
721
+?>caret"></b></a>
677 722
 		<ul class="dropdown-menu">
678 723
 		    <li><a href="<?php print $globalURL; ?>/satellite/currently"><?php echo _("Current Activity"); ?></a></li>
679 724
 		    <li><a href="<?php print $globalURL; ?>/satellite/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -730,7 +775,9 @@  discard block
 block discarded – undo
730 775
   		        $alllang = $Language->getLanguages();
731 776
   		        foreach ($alllang as $key => $lang) {
732 777
   		            print '<option value="'.$key.'"';
733
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
778
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
779
+  		            	print ' selected ';
780
+  		            }
734 781
   		            print '>'.$lang[0].'</option>';
735 782
   		        }
736 783
   		    ?>
@@ -878,9 +925,24 @@  discard block
 block discarded – undo
878 925
 	$customid = $globalMapProvider;
879 926
 ?>
880 927
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
881
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
882
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
883
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
928
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
929
+	print $globalMapCustomLayer[$customid]['maxZoom'];
930
+} else {
931
+	print '18';
932
+}
933
+?>,
934
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
935
+	print $globalMapCustomLayer[$customid]['minZoom'];
936
+} else {
937
+	print '0';
938
+}
939
+?>,
940
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
941
+	print 'false';
942
+} else {
943
+	print 'true';
944
+}
945
+?>,
884 946
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
885 947
     }).addTo(map);
886 948
 <?php
@@ -895,7 +957,12 @@  discard block
 block discarded – undo
895 957
         maxZoom: 5,
896 958
         tms : true,
897 959
         zindex : 3,
898
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
960
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
961
+	print 'false';
962
+} else {
963
+	print 'true';
964
+}
965
+?>,
899 966
         attribution: 'Natural Earth'
900 967
     }).addTo(map);
901 968
 <?php
@@ -918,4 +985,7 @@  discard block
 block discarded – undo
918 985
 
919 986
 ?>
920 987
 
921
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
988
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
989
+	print 'index ';
990
+}
991
+?>clear">
Please login to merge, or discard this patch.
install/install-action.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 	if ($check_version == '0') {
87 87
 		
88 88
 		if ($globalDBdriver == 'mysql') {
89
-		    $error .= create_db::import_all_db('../db/');
89
+			$error .= create_db::import_all_db('../db/');
90 90
 		} elseif ($globalDBdriver == 'pgsql') {
91
-		    $error .= create_db::import_all_db('../db/pgsql/');
91
+			$error .= create_db::import_all_db('../db/pgsql/');
92 92
 		}
93 93
 		if ($error != '') {
94 94
 			$_SESSION['error'] = $error;
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 			$_SESSION['install'] = 'populate';
99 99
 			$_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B';
100 100
 		} else {
101
-		    $_SESSION['install'] = 'sources';
102
-		    $_SESSION['next'] = 'Insert data in source table';
101
+			$_SESSION['install'] = 'sources';
102
+			$_SESSION['next'] = 'Insert data in source table';
103 103
 		}
104 104
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
105 105
 		print json_encode($result);
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database'));
157 157
 	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database'));
158 158
 	if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') {
159
-	    $_SESSION['install'] = 'notam';
160
-	    $_SESSION['next'] = 'Populate NOTAM table with externals data';
161
-	    $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
162
-	    print json_encode($result);
159
+		$_SESSION['install'] = 'notam';
160
+		$_SESSION['next'] = 'Populate NOTAM table with externals data';
161
+		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
162
+		print json_encode($result);
163 163
 	/*
164 164
 	} elseif (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) {
165 165
 	    $_SESSION['install'] = 'owner';
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	    print json_encode($result);
170 170
 	*/
171 171
 	} else {
172
-	    $_SESSION['install'] = 'sources';
173
-	    $_SESSION['next'] = 'Insert data in source table';
174
-	    $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
175
-	    print json_encode($result);
172
+		$_SESSION['install'] = 'sources';
173
+		$_SESSION['next'] = 'Insert data in source table';
174
+		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
175
+		print json_encode($result);
176 176
 	}
177 177
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate') {
178 178
 	if (!is_writable('tmp')) {
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
 	$globalDebug = FALSE;
71 71
 	$dbroot = $_SESSION['database_root'];
72 72
 	$dbrootpass = $_SESSION['database_rootpass'];
73
-	$error .= create_db::create_database($dbroot,$dbrootpass,$globalDBuser,$globalDBpass,$globalDBname,$globalDBdriver,$globalDBhost);
73
+	$error .= create_db::create_database($dbroot, $dbrootpass, $globalDBuser, $globalDBpass, $globalDBname, $globalDBdriver, $globalDBhost);
74 74
 	sleep(5);
75 75
 	if ($error != '') {
76 76
 		$_SESSION['error'] = $error;
77
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database'));
78
-	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database'));
77
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create database'));
78
+	} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Create database'));
79 79
 	$_SESSION['install'] = 'database_import';
80 80
 	$_SESSION['next'] = 'Create and import tables';
81
-	$result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
81
+	$result = array('error' => $error, 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
82 82
 	print json_encode($result);
83 83
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'database_import') {
84 84
 	$globalDebug = FALSE;
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 		}
93 93
 		if ($error != '') {
94 94
 			$_SESSION['error'] = $error;
95
-			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables'));
96
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables'));
95
+			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create and import tables'));
96
+		} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Create and import tables'));
97 97
 		if ($globalSBS1 && !$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
98 98
 			$_SESSION['install'] = 'populate';
99 99
 			$_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B';
@@ -101,24 +101,24 @@  discard block
 block discarded – undo
101 101
 		    $_SESSION['install'] = 'sources';
102 102
 		    $_SESSION['next'] = 'Insert data in source table';
103 103
 		}
104
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
104
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
105 105
 		print json_encode($result);
106 106
 	} elseif (!is_numeric($check_version)) {
107 107
 		$error .= $check_version;
108 108
 		$_SESSION['error'] = $error;
109
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables'));
109
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create and import tables'));
110 110
 		if (!isset($_SESSION['next'])) $_SESSION['next'] = '';
111
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
111
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
112 112
 		print json_encode($result);
113 113
 	} else {
114 114
 		$error .= update_schema::check_version(true);
115 115
 		if ($error != '') {
116 116
 			$_SESSION['error'] = $error;
117
-			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed'));
118
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed'));
117
+			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Update schema if needed'));
118
+		} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Update schema if needed'));
119 119
 		$_SESSION['install'] = 'sources';
120 120
 		$_SESSION['next'] = 'Insert data in source table';
121
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
121
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
122 122
 		print json_encode($result);
123 123
 	}
124 124
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'waypoints') {
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 	$error .= update_db::update_waypoints();
128 128
 	if ($error != '') {
129 129
 		$_SESSION['error'] = $error;
130
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database'));
131
-	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database'));
130
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate waypoints database'));
131
+	} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate waypoints database'));
132 132
 /*
133 133
 	$_SESSION['install'] = 'airspace';
134 134
 	$_SESSION['next'] = 'Populate airspace table';
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 */
146 146
 	$_SESSION['install'] = 'countries';
147 147
 	$_SESSION['next'] = 'Populate countries table';
148
-	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
148
+	$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
149 149
 	print json_encode($result);
150 150
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'countries') {
151 151
 	include_once('class.update_db.php');
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 	$error .= update_db::update_countries();
154 154
 	if ($error != '') {
155 155
 		$_SESSION['error'] = $error;
156
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database'));
157
-	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database'));
156
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate countries database'));
157
+	} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate countries database'));
158 158
 	if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') {
159 159
 	    $_SESSION['install'] = 'notam';
160 160
 	    $_SESSION['next'] = 'Populate NOTAM table with externals data';
161
-	    $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
161
+	    $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
162 162
 	    print json_encode($result);
163 163
 	/*
164 164
 	} elseif (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) {
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
 	} else {
172 172
 	    $_SESSION['install'] = 'sources';
173 173
 	    $_SESSION['next'] = 'Insert data in source table';
174
-	    $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
174
+	    $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
175 175
 	    print json_encode($result);
176 176
 	}
177 177
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate') {
178 178
 	if (!is_writable('tmp')) {
179 179
 		$error = 'The directory <i>install/tmp</i> must be writable.';
180 180
 		$_SESSION['error'] = $error;
181
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B'));
182
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
181
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B'));
182
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
183 183
 		print json_encode($result);
184 184
 	} else {
185 185
 		include_once('class.update_db.php');
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
 		$error .= update_db::update_ModeS_fam();
188 188
 		if ($error != '') {
189 189
 			$_SESSION['error'] = $error;
190
-			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B'));
191
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B'));
190
+			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B'));
191
+		} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate aircraft_modes table with externals data for ADS-B'));
192 192
 		$_SESSION['install'] = 'populate_flarm';
193 193
 		$_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM';
194
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
194
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
195 195
 		print json_encode($result);
196 196
 	}
197 197
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate_flarm') {
198 198
 	if (!is_writable('tmp')) {
199 199
 		$error = 'The directory <i>install/tmp</i> must be writable.';
200 200
 		$_SESSION['error'] = $error;
201
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM'));
202
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
201
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for FLARM'));
202
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
203 203
 		print json_encode($result);
204 204
 	} else {
205 205
 		include_once('class.update_db.php');
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 		$error .= update_db::update_ModeS_ogn();
209 209
 		if ($error != '') {
210 210
 			$_SESSION['error'] = $error;
211
-			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM'));
212
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM'));
211
+			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for FLARM'));
212
+		} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate aircraft_modes table with externals data for FLARM'));
213 213
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
214 214
 			$_SESSION['install'] = 'vatsim';
215 215
 			if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
@@ -228,15 +228,15 @@  discard block
 block discarded – undo
228 228
 			$_SESSION['install'] = 'routes';
229 229
 			$_SESSION['next'] = 'Populate routes table with externals data';
230 230
 		}
231
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
231
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
232 232
 		print json_encode($result);
233 233
 	}
234 234
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'routes') {
235 235
 	if (!is_writable('tmp')) {
236 236
 		$error = 'The directory <i>install/tmp</i> must be writable.';
237 237
 		$_SESSION['error'] = $error;
238
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B'));
239
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
238
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B'));
239
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
240 240
 		print json_encode($result);
241 241
 	} else {
242 242
 		include_once('class.update_db.php');
@@ -244,19 +244,19 @@  discard block
 block discarded – undo
244 244
 		$error .= update_db::update_routes_fam();
245 245
 		if ($error != '') {
246 246
 			$_SESSION['error'] = $error;
247
-			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data'));
248
-		} else 	$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data'));
247
+			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate routes table with externals data'));
248
+		} else 	$_SESSION['done'] = array_merge($_SESSION['done'], array('Populate routes table with externals data'));
249 249
 		$_SESSION['install'] = 'translation';
250 250
 		$_SESSION['next'] = 'Populate translation table with externals data';
251
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
251
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
252 252
 		print json_encode($result);
253 253
 	}
254 254
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'translation') {
255 255
 	if (!is_writable('tmp')) {
256 256
 		$error = 'The directory <i>install/tmp</i> must be writable.';
257 257
 		$_SESSION['error'] = $error;
258
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data'));
259
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
258
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate translation table with externals data'));
259
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
260 260
 		print json_encode($result);
261 261
 	} else {
262 262
 		include_once('class.update_db.php');
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 		$error .= update_db::update_translation_fam();
265 265
 		if ($error != '') {
266 266
 			$_SESSION['error'] = $error;
267
-			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data'));
268
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data'));
267
+			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate translation table with externals data'));
268
+		} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate translation table with externals data'));
269 269
 		if ($_SESSION['waypoints'] == 1) {
270 270
 			$_SESSION['install'] = 'waypoints';
271 271
 			$_SESSION['next'] = 'Populate waypoints table';
@@ -283,15 +283,15 @@  discard block
 block discarded – undo
283 283
 			$_SESSION['install'] = 'sources';
284 284
 			$_SESSION['next'] = 'Insert data in source table';
285 285
 		}
286
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
286
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
287 287
 		print json_encode($result);
288 288
 	}
289 289
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'owner') {
290 290
 	if (!is_writable('tmp')) {
291 291
 		$error = 'The directory <i>install/tmp</i> must be writable.';
292 292
 		$_SESSION['error'] = $error;
293
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data'));
294
-		$result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
293
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate owner table with externals data'));
294
+		$result = array('error' => $error, 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
295 295
 		print json_encode($result);
296 296
 	} else {
297 297
 		include_once('class.update_db.php');
@@ -299,19 +299,19 @@  discard block
 block discarded – undo
299 299
 		$error = update_db::update_owner_fam();
300 300
 		if ($error != '') {
301 301
 			$_SESSION['error'] = $error;
302
-			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data'));
303
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data'));
302
+			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate owner table with externals data'));
303
+		} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate owner table with externals data'));
304 304
 		$_SESSION['install'] = 'sources';
305 305
 		$_SESSION['next'] = 'Insert data in source table';
306
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
306
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
307 307
 		print json_encode($result);
308 308
 	}
309 309
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'notam') {
310 310
 	if (!is_writable('tmp')) {
311 311
 		$error = 'The directory <i>install/tmp</i> must be writable.';
312 312
 		$_SESSION['error'] = $error;
313
-		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data'));
314
-		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
313
+		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data'));
314
+		$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
315 315
 		print json_encode($result);
316 316
 	} else {
317 317
 		include_once('class.update_db.php');
@@ -320,13 +320,13 @@  discard block
 block discarded – undo
320 320
 			$error .= update_db::update_notam();
321 321
 			if ($error != '') {
322 322
 				$_SESSION['error'] = $error;
323
-				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data'));
324
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data'));
323
+				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data'));
324
+			} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate notam table with externals data'));
325 325
 		} else {
326 326
 			if ($error != '') {
327 327
 				$_SESSION['error'] = $error;
328
-				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)'));
329
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)'));
328
+				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data (no source defined)'));
329
+			} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate notam table with externals data (no source defined)'));
330 330
 		}
331 331
 		/*
332 332
 		if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) {
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		*/
340 340
 			$_SESSION['install'] = 'sources';
341 341
 			$_SESSION['next'] = 'Insert data in source table';
342
-			$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
342
+			$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
343 343
 			print json_encode($result);
344 344
 		//}
345 345
 	}
@@ -376,9 +376,9 @@  discard block
 block discarded – undo
376 376
 		$Source = new Source();
377 377
 		$Source->deleteAllLocation();
378 378
 		foreach ($sources as $src) {
379
-			if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png');
379
+			if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'], $src['latitude'], $src['longitude'], $src['altitude'], $src['city'], $src['country'], $src['source'], 'antenna.png');
380 380
 		}
381
-		$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table'));
381
+		$_SESSION['done'] = array_merge($_SESSION['done'], array('Insert data in source table'));
382 382
 		unset($_SESSION['sources']);
383 383
 	}
384 384
 	/*
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 		$_SESSION['install'] = 'finish';
404 404
 		$_SESSION['next'] = 'finish';
405 405
 	}
406
-	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
406
+	$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
407 407
 	print json_encode($result);
408 408
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'vatsim') {
409 409
 	include_once('../install/class.create_db.php');
@@ -415,48 +415,48 @@  discard block
 block discarded – undo
415 415
 			$error .= update_db::update_IVAO();
416 416
 			if ($error != '') {
417 417
 				$_SESSION['error'] = $error;
418
-				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data'));
419
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
418
+				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert IVAO data'));
419
+			} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert IVAO data'));
420 420
 		} else {
421 421
 			$error .= update_db::update_vatsim();
422 422
 			if ($error != '') {
423 423
 				$_SESSION['error'] = $error;
424
-				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data'));
425
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
424
+				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data'));
425
+			} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data'));
426 426
 		}
427 427
 	} elseif (isset($globalVATSIM) && $globalVATSIM) {
428 428
 		$error .= update_db::update_vatsim();
429 429
 		if ($error != '') {
430 430
 			$_SESSION['error'] = $error;
431
-			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data'));
432
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
431
+			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data'));
432
+		} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data'));
433 433
 	} elseif (isset($globalIVAO) && $globalIVAO) {
434 434
 		if (file_exists('tmp/ivae_feb2013.zip')) {
435 435
 			$error .= update_db::update_IVAO();
436 436
 			if ($error != '') {
437 437
 				$_SESSION['error'] = $error;
438
-				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data'));
439
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
438
+				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert IVAO data'));
439
+			} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert IVAO data'));
440 440
 		} else {
441 441
 			$error .= update_db::update_vatsim();
442 442
 			if ($error != '') {
443 443
 				$_SESSION['error'] = $error;
444
-				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)'));
445
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)'));
444
+				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data (IVAO not found)'));
445
+			} else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data (IVAO not found)'));
446 446
 		}
447 447
 	} elseif (isset($globalphpVMS) && $globalphpVMS) {
448
-		$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data'));
448
+		$_SESSION['done'] = array_merge($_SESSION['done'], array('Insert phpVMS data'));
449 449
 	}
450 450
 	//$_SESSION['install'] = 'routes';
451 451
 	//$_SESSION['next'] = 'Populate routes table with externals data';
452 452
 	$_SESSION['install'] = 'finish';
453 453
 	$_SESSION['next'] = 'finish';
454
-	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
454
+	$result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']);
455 455
 	print json_encode($result);
456 456
 } else {
457 457
 	//unset($_SESSION['install']);
458 458
 	$_SESSION['error'] = 'Unknwon task : '.$_SESSION['install'];
459
-	$result = array('error' => 'Unknwon task : '.$_SESSION['install'],'done' => $_SESSION['done'],'next' => 'finish','install' => 'finish');
459
+	$result = array('error' => 'Unknwon task : '.$_SESSION['install'], 'done' => $_SESSION['done'], 'next' => 'finish', 'install' => 'finish');
460 460
 	print json_encode($result);
461 461
 }
462 462
 ?>
463 463
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +78 added lines, -28 removed lines patch added patch discarded remove patch
@@ -75,7 +75,9 @@  discard block
 block discarded – undo
75 75
 	if ($error != '') {
76 76
 		$_SESSION['error'] = $error;
77 77
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database'));
78
-	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database'));
78
+	} else {
79
+		$_SESSION['done'] = array_merge($_SESSION['done'],array('Create database'));
80
+	}
79 81
 	$_SESSION['install'] = 'database_import';
80 82
 	$_SESSION['next'] = 'Create and import tables';
81 83
 	$result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -93,7 +95,9 @@  discard block
 block discarded – undo
93 95
 		if ($error != '') {
94 96
 			$_SESSION['error'] = $error;
95 97
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables'));
96
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables'));
98
+		} else {
99
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables'));
100
+		}
97 101
 		if ($globalSBS1 && !$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
98 102
 			$_SESSION['install'] = 'populate';
99 103
 			$_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B';
@@ -107,7 +111,9 @@  discard block
 block discarded – undo
107 111
 		$error .= $check_version;
108 112
 		$_SESSION['error'] = $error;
109 113
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables'));
110
-		if (!isset($_SESSION['next'])) $_SESSION['next'] = '';
114
+		if (!isset($_SESSION['next'])) {
115
+			$_SESSION['next'] = '';
116
+		}
111 117
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
112 118
 		print json_encode($result);
113 119
 	} else {
@@ -115,7 +121,9 @@  discard block
 block discarded – undo
115 121
 		if ($error != '') {
116 122
 			$_SESSION['error'] = $error;
117 123
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed'));
118
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed'));
124
+		} else {
125
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed'));
126
+		}
119 127
 		$_SESSION['install'] = 'sources';
120 128
 		$_SESSION['next'] = 'Insert data in source table';
121 129
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -128,8 +136,10 @@  discard block
 block discarded – undo
128 136
 	if ($error != '') {
129 137
 		$_SESSION['error'] = $error;
130 138
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database'));
131
-	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database'));
132
-/*
139
+	} else {
140
+		$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database'));
141
+	}
142
+	/*
133 143
 	$_SESSION['install'] = 'airspace';
134 144
 	$_SESSION['next'] = 'Populate airspace table';
135 145
 	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -154,7 +164,9 @@  discard block
 block discarded – undo
154 164
 	if ($error != '') {
155 165
 		$_SESSION['error'] = $error;
156 166
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database'));
157
-	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database'));
167
+	} else {
168
+		$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database'));
169
+	}
158 170
 	if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') {
159 171
 	    $_SESSION['install'] = 'notam';
160 172
 	    $_SESSION['next'] = 'Populate NOTAM table with externals data';
@@ -188,7 +200,9 @@  discard block
 block discarded – undo
188 200
 		if ($error != '') {
189 201
 			$_SESSION['error'] = $error;
190 202
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B'));
191
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B'));
203
+		} else {
204
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B'));
205
+		}
192 206
 		$_SESSION['install'] = 'populate_flarm';
193 207
 		$_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM';
194 208
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -209,18 +223,26 @@  discard block
 block discarded – undo
209 223
 		if ($error != '') {
210 224
 			$_SESSION['error'] = $error;
211 225
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM'));
212
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM'));
226
+		} else {
227
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM'));
228
+		}
213 229
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
214 230
 			$_SESSION['install'] = 'vatsim';
215
-			if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
216
-			else $_SESSION['next'] = 'Insert VATSIM data';
231
+			if (file_exists('tmp/ivae_feb2013.zip')) {
232
+				$_SESSION['next'] = 'Insert IVAO data';
233
+			} else {
234
+				$_SESSION['next'] = 'Insert VATSIM data';
235
+			}
217 236
 		} elseif (isset($globalVATSIM) && $globalVATSIM) {
218 237
 			$_SESSION['install'] = 'vatsim';
219 238
 			$_SESSION['next'] = 'Insert VATSIM data';
220 239
 		} elseif (isset($globalIVAO) && $globalIVAO) {
221 240
 			$_SESSION['install'] = 'vatsim';
222
-			if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
223
-			else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
241
+			if (file_exists('tmp/ivae_feb2013.zip')) {
242
+				$_SESSION['next'] = 'Insert IVAO data';
243
+			} else {
244
+				$_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
245
+			}
224 246
 		} elseif (isset($globalphpVMS) && $globalphpVMS) {
225 247
 			$_SESSION['install'] = 'vatsim';
226 248
 			$_SESSION['next'] = 'Insert phpVMS data';
@@ -245,7 +267,9 @@  discard block
 block discarded – undo
245 267
 		if ($error != '') {
246 268
 			$_SESSION['error'] = $error;
247 269
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data'));
248
-		} else 	$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data'));
270
+		} else {
271
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data'));
272
+		}
249 273
 		$_SESSION['install'] = 'translation';
250 274
 		$_SESSION['next'] = 'Populate translation table with externals data';
251 275
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -265,7 +289,9 @@  discard block
 block discarded – undo
265 289
 		if ($error != '') {
266 290
 			$_SESSION['error'] = $error;
267 291
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data'));
268
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data'));
292
+		} else {
293
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data'));
294
+		}
269 295
 		if ($_SESSION['waypoints'] == 1) {
270 296
 			$_SESSION['install'] = 'waypoints';
271 297
 			$_SESSION['next'] = 'Populate waypoints table';
@@ -300,7 +326,9 @@  discard block
 block discarded – undo
300 326
 		if ($error != '') {
301 327
 			$_SESSION['error'] = $error;
302 328
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data'));
303
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data'));
329
+		} else {
330
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data'));
331
+		}
304 332
 		$_SESSION['install'] = 'sources';
305 333
 		$_SESSION['next'] = 'Insert data in source table';
306 334
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -321,12 +349,16 @@  discard block
 block discarded – undo
321 349
 			if ($error != '') {
322 350
 				$_SESSION['error'] = $error;
323 351
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data'));
324
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data'));
352
+			} else {
353
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data'));
354
+			}
325 355
 		} else {
326 356
 			if ($error != '') {
327 357
 				$_SESSION['error'] = $error;
328 358
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)'));
329
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)'));
359
+			} else {
360
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)'));
361
+			}
330 362
 		}
331 363
 		/*
332 364
 		if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) {
@@ -376,7 +408,9 @@  discard block
 block discarded – undo
376 408
 		$Source = new Source();
377 409
 		$Source->deleteAllLocation();
378 410
 		foreach ($sources as $src) {
379
-			if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png');
411
+			if (isset($src['latitude']) && $src['latitude'] != '') {
412
+				$Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png');
413
+			}
380 414
 		}
381 415
 		$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table'));
382 416
 		unset($_SESSION['sources']);
@@ -387,15 +421,21 @@  discard block
 block discarded – undo
387 421
 	*/
388 422
 	if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
389 423
 		$_SESSION['install'] = 'vatsim';
390
-		if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
391
-		else $_SESSION['next'] = 'Insert VATSIM data';
424
+		if (file_exists('tmp/ivae_feb2013.zip')) {
425
+			$_SESSION['next'] = 'Insert IVAO data';
426
+		} else {
427
+			$_SESSION['next'] = 'Insert VATSIM data';
428
+		}
392 429
 	} elseif (isset($globalVATSIM) && $globalVATSIM) {
393 430
 		$_SESSION['install'] = 'vatsim';
394 431
 		$_SESSION['next'] = 'Insert VATSIM data';
395 432
 	} elseif (isset($globalIVAO) && $globalIVAO) {
396 433
 		$_SESSION['install'] = 'vatsim';
397
-		if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
398
-		else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
434
+		if (file_exists('tmp/ivae_feb2013.zip')) {
435
+			$_SESSION['next'] = 'Insert IVAO data';
436
+		} else {
437
+			$_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
438
+		}
399 439
 	} elseif (isset($globalphpVMS) && $globalphpVMS) {
400 440
 		$_SESSION['install'] = 'vatsim';
401 441
 		$_SESSION['next'] = 'Insert phpVMS data';
@@ -416,33 +456,43 @@  discard block
 block discarded – undo
416 456
 			if ($error != '') {
417 457
 				$_SESSION['error'] = $error;
418 458
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data'));
419
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
459
+			} else {
460
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
461
+			}
420 462
 		} else {
421 463
 			$error .= update_db::update_vatsim();
422 464
 			if ($error != '') {
423 465
 				$_SESSION['error'] = $error;
424 466
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data'));
425
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
467
+			} else {
468
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
469
+			}
426 470
 		}
427 471
 	} elseif (isset($globalVATSIM) && $globalVATSIM) {
428 472
 		$error .= update_db::update_vatsim();
429 473
 		if ($error != '') {
430 474
 			$_SESSION['error'] = $error;
431 475
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data'));
432
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
476
+		} else {
477
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
478
+		}
433 479
 	} elseif (isset($globalIVAO) && $globalIVAO) {
434 480
 		if (file_exists('tmp/ivae_feb2013.zip')) {
435 481
 			$error .= update_db::update_IVAO();
436 482
 			if ($error != '') {
437 483
 				$_SESSION['error'] = $error;
438 484
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data'));
439
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
485
+			} else {
486
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
487
+			}
440 488
 		} else {
441 489
 			$error .= update_db::update_vatsim();
442 490
 			if ($error != '') {
443 491
 				$_SESSION['error'] = $error;
444 492
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)'));
445
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)'));
493
+			} else {
494
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)'));
495
+			}
446 496
 		}
447 497
 	} elseif (isset($globalphpVMS) && $globalphpVMS) {
448 498
 		$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data'));
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Spacing   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,35 +150,35 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
176
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftjson';
178 178
         	$globalSources[$id]['format'] = 'aircraftjson';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/opensky/i',$host)) {
181
+    	    } else if (preg_match('/opensky/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'opensky';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         	    exit(0);
196 196
         	}
197 197
     	    */
198
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
198
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
199 199
         	//$formats[$id] = 'planeupdatefaa';
200 200
         	$globalSources[$id]['format'] = 'planeupdatefaa';
201 201
         	//$last_exec['planeupdatefaa'] = 0;
@@ -204,37 +204,37 @@  discard block
 block discarded – undo
204 204
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
205 205
         	    exit(0);
206 206
         	}
207
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
207
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
208 208
         	//$formats[$id] = 'phpvmacars';
209 209
         	$globalSources[$id]['format'] = 'phpvmacars';
210 210
         	//$last_exec['phpvmacars'] = 0;
211 211
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
212
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
212
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
213 213
         	//$formats[$id] = 'phpvmacars';
214 214
         	$globalSources[$id]['format'] = 'vaos';
215 215
         	//$last_exec['phpvmacars'] = 0;
216 216
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
217
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
217
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
218 218
         	//$formats[$id] = 'phpvmacars';
219 219
         	$globalSources[$id]['format'] = 'vam';
220 220
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
221
-            } else if (preg_match('/whazzup/i',$host)) {
221
+            } else if (preg_match('/whazzup/i', $host)) {
222 222
         	//$formats[$id] = 'whazzup';
223 223
         	$globalSources[$id]['format'] = 'whazzup';
224 224
         	//$last_exec['whazzup'] = 0;
225 225
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
226
-            } else if (preg_match('/blitzortung/i',$host)) {
226
+            } else if (preg_match('/blitzortung/i', $host)) {
227 227
         	$globalSources[$id]['format'] = 'blitzortung';
228 228
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
229
-            } else if (preg_match('/airwhere/i',$host)) {
229
+            } else if (preg_match('/airwhere/i', $host)) {
230 230
         	$globalSources[$id]['format'] = 'airwhere';
231 231
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
-            } else if (preg_match('/recentpireps/i',$host)) {
232
+            } else if (preg_match('/recentpireps/i', $host)) {
233 233
         	//$formats[$id] = 'pirepsjson';
234 234
         	$globalSources[$id]['format'] = 'pirepsjson';
235 235
         	//$last_exec['pirepsjson'] = 0;
236 236
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
237
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
237
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
238 238
         	//$formats[$id] = 'fr24json';
239 239
         	$globalSources[$id]['format'] = 'fr24json';
240 240
         	//$last_exec['fr24json'] = 0;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
244 244
         	    exit(0);
245 245
         	}
246
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
246
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
247 247
         	//$formats[$id] = 'fr24json';
248 248
         	$globalSources[$id]['format'] = 'myshiptracking';
249 249
         	//$last_exec['fr24json'] = 0;
@@ -253,21 +253,21 @@  discard block
 block discarded – undo
253 253
         	    exit(0);
254 254
         	}
255 255
             //} else if (preg_match('/10001/',$host)) {
256
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
256
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
257 257
         	//$formats[$id] = 'tsv';
258 258
         	$globalSources[$id]['format'] = 'tsv';
259 259
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260 260
             }
261
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
261
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
262 262
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
263
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
263
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
264 264
     		    if ($idf !== false) {
265 265
     			$httpfeeds[$id] = $idf;
266 266
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
267 267
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
268 268
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
270
-	    $hostport = explode(':',$host);
269
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
270
+	    $hostport = explode(':', $host);
271 271
 	    if (isset($hostport[1])) {
272 272
 		$port = $hostport[1];
273 273
 		$hostn = $hostport[0];
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
 	    }
278 278
 	    $Common = new Common();
279 279
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
280
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
280
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
281 281
     	    } else {
282
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
282
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
283 283
 	    }
284 284
 	    if ($s) {
285 285
     	        $sockets[$id] = $s;
286 286
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
287
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
287
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
288 288
 			//$formats[$id] = 'aprs';
289 289
 			$globalSources[$id]['format'] = 'aprs';
290 290
 			//$aprs_connect = 0;
291 291
 			//$use_aprs = true;
292
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
292
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
293 293
 			$globalSources[$id]['format'] = 'vrstcp';
294 294
     		    } elseif ($port == '10001') {
295 295
         		//$formats[$id] = 'tsv';
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
329 329
 else $timeout = 20;
330 330
 $errno = '';
331
-$errstr='';
331
+$errstr = '';
332 332
 
333 333
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
334 334
 /* Initiate connections to all the hosts simultaneously */
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 //connect_all($globalSources);
337 337
 
338 338
 if (isset($globalProxy) && $globalProxy) {
339
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
339
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
340 340
 } else {
341 341
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
342 342
 }
@@ -366,16 +366,16 @@  discard block
 block discarded – undo
366 366
 
367 367
 if ($use_aprs) {
368 368
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
369
-	$APRS=new APRS();
369
+	$APRS = new APRS();
370 370
 	$aprs_connect = 0;
371 371
 	$aprs_keep = 120;
372 372
 	$aprs_last_tx = time();
373 373
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
374
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
374
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
375 375
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
376
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
376
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
377 377
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
378
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
378
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
379 379
 	if ($aprs_full) $aprs_filter = '';
380 380
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
381 381
 	else $aprs_pass = '-1';
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 sleep(1);
390 390
 if ($globalDebug) echo "SCAN MODE \n\n";
391 391
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
392
-$endtime = time()+$globalCronEnd;
392
+$endtime = time() + $globalCronEnd;
393 393
 $i = 1;
394 394
 $tt = array();
395 395
 // Delete all ATC
396 396
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
397
-	$ATC=new ATC($Connection->db);
397
+	$ATC = new ATC($Connection->db);
398 398
 }
399 399
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
400 400
 	$ATC->deleteAll();
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 while ($i > 0) {
405 405
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
406 406
 
407
-    if (!$globalDaemon) $i = $endtime-time();
407
+    if (!$globalDaemon) $i = $endtime - time();
408 408
     // Delete old ATC
409 409
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
410 410
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	}
419 419
 	if ($max < $globalMinFetch) {
420 420
 	    if ($globalDebug) echo 'Sleeping...'."\n";
421
-	    sleep($globalMinFetch-$max+2);
421
+	    sleep($globalMinFetch - $max + 2);
422 422
 	}
423 423
     }
424 424
 
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	    //$buffer = $Common->getData($hosts[$id]);
438 438
 	    $buffer = $Common->getData($value['host']);
439 439
 	    if ($buffer != '') $reset = 0;
440
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
441
-	    $buffer = explode('\n',$buffer);
440
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
441
+	    $buffer = explode('\n', $buffer);
442 442
 	    foreach ($buffer as $line) {
443 443
     		if ($line != '' && count($line) > 7) {
444 444
     		    $line = explode(',', $line);
@@ -471,11 +471,11 @@  discard block
 block discarded – undo
471 471
 	    )
472 472
 	) {
473 473
 	    date_default_timezone_set('CET');
474
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
474
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
475 475
 	    date_default_timezone_set('UTC');
476 476
 	    if ($buffer != '') $reset = 0;
477
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
478
-	    $buffer = explode('\n',$buffer);
477
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
478
+	    $buffer = explode('\n', $buffer);
479 479
 	    foreach ($buffer as $line) {
480 480
 		if ($line != '') {
481 481
 		    //echo "'".$line."'\n";
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 		    $ais_data = $AIS->parse_line(trim($line));
484 484
 		    $data = array();
485 485
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
486
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
486
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
487 487
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
488 488
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
489 489
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
496 496
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
497 497
 		    if (isset($ais_data['timestamp'])) {
498
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
498
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
499 499
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
500 500
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
501 501
 			    $add = true;
@@ -518,21 +518,21 @@  discard block
 block discarded – undo
518 518
 	    $w = $e = null;
519 519
 	    
520 520
 	    if (isset($arr[$id])) {
521
-		$nn = stream_select($arr,$w,$e,$timeout);
521
+		$nn = stream_select($arr, $w, $e, $timeout);
522 522
 		if ($nn > 0) {
523 523
 		    foreach ($httpfeeds as $feed) {
524
-			$buffer = stream_get_line($feed,2000,"\n");
524
+			$buffer = stream_get_line($feed, 2000, "\n");
525 525
 			if ($buffer === FALSE) {
526 526
 			    connect_all($globalSources);
527 527
 			}
528
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
529
-			$buffer = explode('\n',$buffer);
528
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
529
+			$buffer = explode('\n', $buffer);
530 530
 			foreach ($buffer as $line) {
531 531
 			    if ($line != '') {
532 532
 				$ais_data = $AIS->parse_line(trim($line));
533 533
 				$data = array();
534 534
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
535
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
535
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
536 536
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
537 537
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
538 538
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -544,9 +544,9 @@  discard block
 block discarded – undo
544 544
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
545 545
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
546 546
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
547
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
547
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
548 548
 				if (isset($ais_data['timestamp'])) {
549
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
549
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
550 550
 				} else {
551 551
 				    $data['datetime'] = date('Y-m-d H:i:s');
552 552
 				}
@@ -578,10 +578,10 @@  discard block
 block discarded – undo
578 578
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
579 579
 	    )
580 580
 	) {
581
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
581
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
582 582
 	    if ($buffer != '') {
583 583
 		//echo $buffer;
584
-		$all_data = json_decode($buffer,true);
584
+		$all_data = json_decode($buffer, true);
585 585
 		//print_r($all_data);
586 586
 		if (isset($all_data[0]['DATA'])) {
587 587
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			    $data['ident'] = $line['NAME'];
591 591
 			    $data['mmsi'] = $line['MMSI'];
592 592
 			    if (strlen($data['mmsi']) > 9) {
593
-				$data['mmsi'] = substr($data['mmsi'],-9);
593
+				$data['mmsi'] = substr($data['mmsi'], -9);
594 594
 			    }
595 595
 			    $data['speed'] = $line['SOG'];
596 596
 			    $data['heading'] = $line['COG'];
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 			    //$data['type_id'] = $line['TYPE'];
601 601
 			    $data['imo'] = $line['IMO'];
602 602
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
603
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
604
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
603
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
604
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
605 605
 			    $data['format_source'] = 'myshiptracking';
606 606
 			    $data['id_source'] = $id_source;
607 607
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -618,16 +618,16 @@  discard block
 block discarded – undo
618 618
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
619 619
 	    )
620 620
 	) {
621
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
621
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
622 622
 	    if ($buffer != '') {
623
-		$all_data = json_decode($buffer,true);
623
+		$all_data = json_decode($buffer, true);
624 624
 		if (isset($all_data[0]['mmsi'])) {
625 625
 		    foreach ($all_data as $line) {
626 626
 			if ($line != '') {
627 627
 			    $data = array();
628 628
 			    $data['ident'] = $line['shipname'];
629 629
 			    $data['callsign'] = $line['callsign'];
630
-			    $data['mmsi'] = substr($line['mmsi'],-9);
630
+			    $data['mmsi'] = substr($line['mmsi'], -9);
631 631
 			    $data['speed'] = $line['sog'];
632 632
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
633 633
 			    $data['latitude'] = $line['latitude'];
@@ -654,14 +654,14 @@  discard block
 block discarded – undo
654 654
 	) {
655 655
 	    $buffer = $Common->getData($value['host']);
656 656
 	    if ($buffer != '') {
657
-		$all_data = json_decode($buffer,true);
657
+		$all_data = json_decode($buffer, true);
658 658
 		if (isset($all_data['features'][0]['id'])) {
659 659
 		    foreach ($all_data['features'] as $line) {
660 660
 			print_r($line);
661 661
 			$data = array();
662 662
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
663 663
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
664
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
664
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
665 665
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
666 666
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
667 667
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -688,31 +688,31 @@  discard block
 block discarded – undo
688 688
 	    )
689 689
 	) {
690 690
 	    echo 'download...';
691
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
691
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
692 692
 	    echo 'done !'."\n";
693 693
 	    // FIXME: Need more work
694 694
 	    if ($buffer != '') $reset = 0;
695
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
696
-	    $buffer = explode('\n',$buffer);
695
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
696
+	    $buffer = explode('\n', $buffer);
697 697
 	    foreach ($buffer as $line) {
698 698
 		if ($line != '') {
699 699
 		    $data = array();
700 700
 		    echo $line."\n";
701
-		    $data['mmsi'] = (int)substr($line,0,9);
702
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
703
-		    $data['status_id'] = substr($line,21,2);
704
-		    $data['type_id'] = substr($line,24,3);
705
-		    $data['latitude'] = substr($line,29,9);
706
-		    $data['longitude'] = substr($line,41,9);
707
-		    $data['speed'] = round(substr($line,51,5));
701
+		    $data['mmsi'] = (int) substr($line, 0, 9);
702
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
703
+		    $data['status_id'] = substr($line, 21, 2);
704
+		    $data['type_id'] = substr($line, 24, 3);
705
+		    $data['latitude'] = substr($line, 29, 9);
706
+		    $data['longitude'] = substr($line, 41, 9);
707
+		    $data['speed'] = round(substr($line, 51, 5));
708 708
 		    //$data['course'] = substr($line,57,5);
709
-		    $data['heading'] = round(substr($line,63,3));
709
+		    $data['heading'] = round(substr($line, 63, 3));
710 710
 		    //$data['draft'] = substr($line,67,4);
711 711
 		    //$data['length'] = substr($line,72,3);
712 712
 		    //$data['beam'] = substr($line,76,2);
713
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
713
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
714 714
 		    //$data['callsign'] = trim(substr($line,100,7);
715
-		    $data['arrival_code'] = substr($line,108,20);
715
+		    $data['arrival_code'] = substr($line, 108, 20);
716 716
 		    //$data['etaDate'] = substr($line,129,5);
717 717
 		    //$data['etaTime'] = substr($line,135,5);
718 718
 		    $data['format_source'] = 'shipplotter';
@@ -743,8 +743,8 @@  discard block
 block discarded – undo
743 743
 	) {
744 744
 	    //$buffer = $Common->getData($hosts[$id]);
745 745
 	    $buffer = $Common->getData($value['host']);
746
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
747
-	    $buffer = explode('\n',$buffer);
746
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
747
+	    $buffer = explode('\n', $buffer);
748 748
 	    $reset = 0;
749 749
 	    foreach ($buffer as $line) {
750 750
     		if ($line != '') {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
756 756
 			$data['pilot_id'] = $line[1];
757 757
 			$data['pilot_name'] = $line[2];
758
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
758
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
759 759
 			$data['ident'] = $line[0]; // ident
760 760
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
761 761
 			$data['speed'] = $line[8]; // speed
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
772 772
 			//if (isset($line[37])) $data['last_update'] = $line[37];
773 773
 		        $data['departure_airport_icao'] = $line[11];
774
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
774
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
775 775
 		        $data['arrival_airport_icao'] = $line[13];
776 776
 			$data['frequency'] = $line[4];
777 777
 			$data['type'] = $line[18];
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
     			$data['id_source'] = $id_source;
781 781
 	    		//$data['arrival_airport_time'] = ;
782 782
 	    		if ($line[9] != '') {
783
-	    		    $aircraft_data = explode('/',$line[9]);
783
+	    		    $aircraft_data = explode('/', $line[9]);
784 784
 	    		    if (isset($aircraft_data[1])) {
785 785
 	    			$data['aircraft_icao'] = $aircraft_data[1];
786 786
 	    		    }
@@ -795,9 +795,9 @@  discard block
 block discarded – undo
795 795
     			if ($line[3] === 'PILOT') $SI->add($data);
796 796
 			elseif ($line[3] === 'ATC') {
797 797
 				//print_r($data);
798
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
799
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
800
-				$typec = substr($data['ident'],-3);
798
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
799
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
800
+				$typec = substr($data['ident'], -3);
801 801
 				if ($typec === 'APP') $data['type'] = 'Approach';
802 802
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
803 803
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
810 810
 				if (!isset($data['source_name'])) $data['source_name'] = '';
811 811
 				if (isset($ATC)) {
812
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
813
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
812
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
813
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
814 814
 				}
815 815
 			}
816 816
     			unset($data);
@@ -826,24 +826,24 @@  discard block
 block discarded – undo
826 826
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
827 827
     	    )
828 828
     	) {
829
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
829
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
830 830
 	    if ($buffer != '') {
831 831
 		$all_data = simplexml_load_string($buffer);
832
-		foreach($all_data->children() as $childdata) {
832
+		foreach ($all_data->children() as $childdata) {
833 833
 			$data = array();
834 834
 			$line = $childdata;
835 835
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
836
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
837
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
838
-			$data['latitude'] = (float)$line['pktLatitude'];
839
-			$data['longitude'] = (float)$line['pktLongitude'];
840
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
841
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
842
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
836
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
837
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
838
+			$data['latitude'] = (float) $line['pktLatitude'];
839
+			$data['longitude'] = (float) $line['pktLongitude'];
840
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
841
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
842
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
843 843
 			$data['altitude_relative'] = 'AMSL';
844
-			$data['pilot_id'] = (int)$line['pktPilotID'];
844
+			$data['pilot_id'] = (int) $line['pktPilotID'];
845 845
 			$data['aircraft_icao'] = 'PARAGLIDER';
846
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
846
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
847 847
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
848 848
 			$data['format_source'] = $value['format'];
849 849
 			$SI->add($data);
@@ -851,22 +851,22 @@  discard block
 block discarded – undo
851 851
 		}
852 852
 	    }
853 853
 	    $Source->deleteOldLocationByType('gs');
854
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
854
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
855 855
 	    if ($buffer != '') {
856 856
 		$all_data = simplexml_load_string($buffer);
857
-		foreach($all_data->children() as $childdata) {
857
+		foreach ($all_data->children() as $childdata) {
858 858
 			$data = array();
859 859
 			$line = $childdata;
860
-			$data['id'] = (int)$line['gsID'];
861
-			$data['latitude'] = (float)$line['gsLatitude'];
862
-			$data['longitude'] = (float)$line['gsLongitude'];
863
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
860
+			$data['id'] = (int) $line['gsID'];
861
+			$data['latitude'] = (float) $line['gsLatitude'];
862
+			$data['longitude'] = (float) $line['gsLongitude'];
863
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
864 864
 			$data['altitude_relative'] = 'AMSL';
865
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
865
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
866 866
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
867
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
867
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
868 868
 			} else {
869
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
869
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
870 870
 			}
871 871
 			unset($data);
872 872
 		}
@@ -884,9 +884,9 @@  discard block
 block discarded – undo
884 884
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
885 885
 	    )
886 886
 	) {
887
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
887
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
888 888
 	    if ($buffer != '') {
889
-	        $all_data = json_decode($buffer,true);
889
+	        $all_data = json_decode($buffer, true);
890 890
 		if (isset($all_data['acList'])) {
891 891
 		    $reset = 0;
892 892
 		    foreach ($all_data['acList'] as $line) {
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
903 903
 			$data['emergency'] = ''; // emergency
904 904
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
905
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
905
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
906 906
 			else $data['datetime'] = date('Y-m-d H:i:s');
907 907
 			//$data['datetime'] = date('Y-m-d H:i:s');
908 908
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 			$data['verticalrate'] = $line['vrt']; // verticale rate
928 928
 			$data['squawk'] = $line['squawk']; // squawk
929 929
 			$data['emergency'] = ''; // emergency
930
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
930
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
931 931
 			else $data['datetime'] = date('Y-m-d H:i:s');
932 932
 			$data['format_source'] = 'aircraftlistjson';
933 933
 			$data['id_source'] = $id_source;
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
     	    )
949 949
     	) {
950 950
 	    $buffer = $Common->getData($value['host']);
951
-	    $all_data = json_decode($buffer,true);
951
+	    $all_data = json_decode($buffer, true);
952 952
 	    if (isset($all_data['planes'])) {
953 953
 		$reset = 0;
954 954
 		foreach ($all_data['planes'] as $key => $line) {
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
 		    $data['emergency'] = ''; // emergency
966 966
 		    $data['registration'] = $line[2];
967 967
 		    $data['aircraft_icao'] = $line[0];
968
-		    $deparr = explode('-',$line[1]);
968
+		    $deparr = explode('-', $line[1]);
969 969
 		    if (count($deparr) === 2) {
970 970
 			$data['departure_airport_icao'] = $deparr[0];
971 971
 			$data['arrival_airport_icao'] = $deparr[1];
972 972
 		    }
973
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
973
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
974 974
 	    	    $data['format_source'] = 'planeupdatefaa';
975 975
     		    $data['id_source'] = $id_source;
976 976
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 	    )
989 989
 	) {
990 990
 	    $buffer = $Common->getData($value['host']);
991
-	    $all_data = json_decode($buffer,true);
991
+	    $all_data = json_decode($buffer, true);
992 992
 	    if (isset($all_data['states'])) {
993 993
 		$reset = 0;
994 994
 		foreach ($all_data['states'] as $key => $line) {
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 		    //$data['emergency'] = ''; // emergency
1006 1006
 		    //$data['registration'] = $line[2];
1007 1007
 		    //$data['aircraft_icao'] = $line[0];
1008
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1008
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1009 1009
 		    $data['format_source'] = 'opensky';
1010 1010
 		    $data['id_source'] = $id_source;
1011 1011
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 	    )
1023 1023
 	) {
1024 1024
 	    $buffer = $Common->getData($value['host']);
1025
-	    $all_data = json_decode($buffer,true);
1025
+	    $all_data = json_decode($buffer, true);
1026 1026
 	    if (isset($all_data['aircraft'])) {
1027 1027
 		$reset = 0;
1028 1028
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 	) {
1059 1059
 	    //$buffer = $Common->getData($hosts[$id]);
1060 1060
 	    $buffer = $Common->getData($value['host']);
1061
-	    $all_data = json_decode($buffer,true);
1061
+	    $all_data = json_decode($buffer, true);
1062 1062
 	    if (!empty($all_data)) $reset = 0;
1063 1063
 	    foreach ($all_data as $key => $line) {
1064 1064
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1096,11 +1096,11 @@  discard block
 block discarded – undo
1096 1096
 	    )
1097 1097
 	) {
1098 1098
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1099
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1099
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1100 1100
 	    //echo $buffer;
1101
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1102
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1103
-	    $all_data = json_decode($buffer,true);
1101
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1102
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1103
+	    $all_data = json_decode($buffer, true);
1104 1104
 	    if (json_last_error() != JSON_ERROR_NONE) {
1105 1105
 		die(json_last_error_msg());
1106 1106
 	    }
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 			//$data['departure_airport_iata'] = $line[11];
1124 1124
 			//$data['arrival_airport_iata'] = $line[12];
1125 1125
 	    		//$data['emergency'] = ''; // emergency
1126
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1126
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1127 1127
 	    		$data['format_source'] = 'radarvirtueljson';
1128 1128
     			$data['id_source'] = $id_source;
1129 1129
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1144,14 +1144,14 @@  discard block
 block discarded – undo
1144 1144
 	) {
1145 1145
 	    //$buffer = $Common->getData($hosts[$id]);
1146 1146
 	    $buffer = $Common->getData($value['host'].'?'.time());
1147
-	    $all_data = json_decode(utf8_encode($buffer),true);
1147
+	    $all_data = json_decode(utf8_encode($buffer), true);
1148 1148
 	    
1149 1149
 	    if (isset($all_data['pireps'])) {
1150 1150
 		$reset = 0;
1151 1151
 	        foreach ($all_data['pireps'] as $line) {
1152 1152
 		    $data = array();
1153 1153
 		    $data['id'] = $line['id'];
1154
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1154
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1155 1155
 		    $data['ident'] = $line['callsign']; // ident
1156 1156
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1157 1157
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1181,9 +1181,9 @@  discard block
 block discarded – undo
1181 1181
 			$SI->add($data);
1182 1182
 		    //    print_r($data);
1183 1183
     		    } elseif ($line['icon'] === 'ct') {
1184
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1185
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1186
-			$typec = substr($data['ident'],-3);
1184
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1185
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1186
+			$typec = substr($data['ident'], -3);
1187 1187
 			$data['type'] = '';
1188 1188
 			if ($typec === 'APP') $data['type'] = 'Approach';
1189 1189
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1195 1195
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1196 1196
 			else $data['type'] = 'Observer';
1197
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1197
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
1198 1198
 		    }
1199 1199
 		    unset($data);
1200 1200
 		}
@@ -1211,14 +1211,14 @@  discard block
 block discarded – undo
1211 1211
 	    //$buffer = $Common->getData($hosts[$id]);
1212 1212
 	    if ($globalDebug) echo 'Get Data...'."\n";
1213 1213
 	    $buffer = $Common->getData($value['host']);
1214
-	    $all_data = json_decode($buffer,true);
1214
+	    $all_data = json_decode($buffer, true);
1215 1215
 	    if ($buffer != '' && is_array($all_data)) {
1216 1216
 		$reset = 0;
1217 1217
 		foreach ($all_data as $line) {
1218 1218
 	    	    $data = array();
1219 1219
 	    	    //$data['id'] = $line['id']; // id not usable
1220 1220
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1221
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1221
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1222 1222
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1223 1223
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1224 1224
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 	    	    //$data['datetime'] = $line['lastupdate'];
1234 1234
 	    	    //$data['last_update'] = $line['lastupdate'];
1235 1235
 	    	    if (isset($value['timezone'])) {
1236
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1236
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1237 1237
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1238 1238
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1239 1239
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1249,14 +1249,14 @@  discard block
 block discarded – undo
1249 1249
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1250 1250
 		    if (isset($line['aircraftname'])) {
1251 1251
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1252
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1253
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1252
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1253
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1254 1254
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1255 1255
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1256 1256
 	    		else {
1257
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1258
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1259
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1257
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1258
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1259
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1260 1260
 	    		}
1261 1261
 	    	    }
1262 1262
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 	    //$buffer = $Common->getData($hosts[$id]);
1282 1282
 	    if ($globalDebug) echo 'Get Data...'."\n";
1283 1283
 	    $buffer = $Common->getData($value['host']);
1284
-	    $all_data = json_decode($buffer,true);
1284
+	    $all_data = json_decode($buffer, true);
1285 1285
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1286 1286
 		$reset = 0;
1287 1287
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1293 1293
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1294 1294
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1295
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1295
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1296 1296
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1297 1297
 	    	    $data['altitude'] = $line['altitude']; // altitude
1298 1298
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 	    	    //$data['squawk'] = ''; // squawk
1304 1304
 	    	    //$data['emergency'] = ''; // emergency
1305 1305
 	    	    if (isset($value['timezone'])) {
1306
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1306
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1307 1307
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1308 1308
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1309 1309
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1339,14 +1339,14 @@  discard block
 block discarded – undo
1339 1339
 	    //$buffer = $Common->getData($hosts[$id]);
1340 1340
 	    if ($globalDebug) echo 'Get Data...'."\n";
1341 1341
 	    $buffer = $Common->getData($value['host']);
1342
-	    $all_data = json_decode($buffer,true);
1342
+	    $all_data = json_decode($buffer, true);
1343 1343
 	    if ($buffer != '' && is_array($all_data)) {
1344 1344
 		$reset = 0;
1345 1345
 		foreach ($all_data as $line) {
1346 1346
 	    	    $data = array();
1347 1347
 	    	    //$data['id'] = $line['id']; // id not usable
1348 1348
 	    	    $data['id'] = trim($line['flight_id']);
1349
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1349
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1350 1350
 	    	    $data['pilot_name'] = $line['pilot_name'];
1351 1351
 	    	    $data['pilot_id'] = $line['pilot_id'];
1352 1352
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1390,24 +1390,24 @@  discard block
 block discarded – undo
1390 1390
 	    //$buffer = $Common->getData($hosts[$id]);
1391 1391
 	    if ($globalDebug) echo 'Get Data...'."\n";
1392 1392
 	    $buffer = $Common->getData($value['host']);
1393
-	    $all_data = json_decode($buffer,true);
1393
+	    $all_data = json_decode($buffer, true);
1394 1394
 	    if ($buffer != '') {
1395 1395
 		$Source->deleteLocationBySource('blitzortung');
1396
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1397
-		$buffer = explode('\n',$buffer);
1396
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1397
+		$buffer = explode('\n', $buffer);
1398 1398
 		foreach ($buffer as $buffer_line) {
1399
-		    $line = json_decode($buffer_line,true);
1399
+		    $line = json_decode($buffer_line, true);
1400 1400
 		    if (isset($line['time'])) {
1401 1401
 			$data = array();
1402 1402
 			$data['altitude'] = $line['alt']; // altitude
1403 1403
 			$data['latitude'] = $line['lat']; // lat
1404 1404
 			$data['longitude'] = $line['lon']; // long
1405
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1405
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1406 1406
 			$data['id_source'] = $id_source;
1407 1407
 			$data['format_source'] = 'blitzortung';
1408 1408
 			$SI->add($data);
1409 1409
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1410
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1410
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1411 1411
 			unset($data);
1412 1412
 		    }
1413 1413
 		}
@@ -1430,11 +1430,11 @@  discard block
 block discarded – undo
1430 1430
 		    //$value = $formats[$nb];
1431 1431
 		    $format = $globalSources[$nb]['format'];
1432 1432
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1433
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1433
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1434 1434
 		    } elseif ($format === 'vrstcp') {
1435 1435
 			$buffer = @socket_read($r, 6000);
1436 1436
 		    } else {
1437
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1437
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1438 1438
 		    }
1439 1439
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1440 1440
 		    //echo $buffer."\n";
@@ -1444,8 +1444,8 @@  discard block
 block discarded – undo
1444 1444
 		    //$SI::del();
1445 1445
 		    if ($buffer !== FALSE) {
1446 1446
 			if ($format === 'vrstcp') {
1447
-			    $buffer = explode('},{',$buffer);
1448
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1447
+			    $buffer = explode('},{', $buffer);
1448
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1449 1449
 		    }
1450 1450
 		    // SBS format is CSV format
1451 1451
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 			    $ais_data = $AIS->parse_line(trim($buffer));
1470 1470
 			    $data = array();
1471 1471
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1472
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1472
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1473 1473
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1474 1474
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1475 1475
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1480,13 +1480,13 @@  discard block
 block discarded – undo
1480 1480
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1481 1481
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1482 1482
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1483
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1483
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1484 1484
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1485 1485
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1486 1486
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1487 1487
 
1488 1488
 			    if (isset($ais_data['timestamp'])) {
1489
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1489
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1490 1490
 			    } else {
1491 1491
 				$data['datetime'] = date('Y-m-d H:i:s');
1492 1492
 			    }
@@ -1497,10 +1497,10 @@  discard block
 block discarded – undo
1497 1497
                         } elseif ($format === 'flightgearsp') {
1498 1498
                     	    //echo $buffer."\n";
1499 1499
                     	    if (strlen($buffer) > 5) {
1500
-				$line = explode(',',$buffer);
1500
+				$line = explode(',', $buffer);
1501 1501
 				$data = array();
1502 1502
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1503
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1503
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1504 1504
 				$data['ident'] = $line[6];
1505 1505
 				$data['aircraft_name'] = $line[7];
1506 1506
 				$data['longitude'] = $line[1];
@@ -1517,16 +1517,16 @@  discard block
 block discarded – undo
1517 1517
                         } elseif ($format === 'acars') {
1518 1518
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1519 1519
 			    $ACARS->add(trim($buffer));
1520
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1520
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1521 1521
 			    $ACARS->deleteLiveAcarsData();
1522 1522
 			} elseif ($format === 'flightgearmp') {
1523
-			    if (substr($buffer,0,1) != '#') {
1523
+			    if (substr($buffer, 0, 1) != '#') {
1524 1524
 				$data = array();
1525 1525
 				//echo $buffer."\n";
1526
-				$line = explode(' ',$buffer);
1526
+				$line = explode(' ', $buffer);
1527 1527
 				if (count($line) === 11) {
1528
-				    $userserver = explode('@',$line[0]);
1529
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1528
+				    $userserver = explode('@', $line[0]);
1529
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1530 1530
 				    $data['ident'] = $userserver[0];
1531 1531
 				    $data['registration'] = $userserver[0];
1532 1532
 				    $data['latitude'] = $line[4];
@@ -1534,8 +1534,8 @@  discard block
 block discarded – undo
1534 1534
 				    $data['altitude'] = $line[6];
1535 1535
 				    $data['datetime'] = date('Y-m-d H:i:s');
1536 1536
 				    $aircraft_type = $line[10];
1537
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1538
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1537
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1538
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1539 1539
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1540 1540
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1541 1541
 				}
@@ -1544,8 +1544,8 @@  discard block
 block discarded – undo
1544 1544
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1545 1545
 			    die;
1546 1546
 			} elseif ($format === 'vrstcp') {
1547
-			    foreach($buffer as $all_data) {
1548
-				$line = json_decode('{'.$all_data.'}',true);
1547
+			    foreach ($buffer as $all_data) {
1548
+				$line = json_decode('{'.$all_data.'}', true);
1549 1549
 				$data = array();
1550 1550
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1551 1551
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1571,16 +1571,16 @@  discard block
 block discarded – undo
1571 1571
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1572 1572
 				unset($data);
1573 1573
 			    }
1574
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1574
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1575 1575
 			    $line = explode("\t", $buffer);
1576
-			    for($k = 0; $k < count($line); $k=$k+2) {
1576
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1577 1577
 				$key = $line[$k];
1578
-			        $lined[$key] = $line[$k+1];
1578
+			        $lined[$key] = $line[$k + 1];
1579 1579
 			    }
1580 1580
     			    if (count($lined) > 3) {
1581 1581
     				$data['hex'] = $lined['hexid'];
1582 1582
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1583
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1583
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1584 1584
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1585 1585
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1586 1586
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1599,23 +1599,23 @@  discard block
 block discarded – undo
1599 1599
     			    } else $error = true;
1600 1600
 			} elseif ($format === 'aprs' && $use_aprs) {
1601 1601
 			    if ($aprs_connect === 0) {
1602
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1602
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1603 1603
 				$aprs_connect = 1;
1604 1604
 			    }
1605 1605
 			    
1606
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1606
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1607 1607
 				$aprs_last_tx = time();
1608 1608
 				$data_aprs = "# Keep alive";
1609
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1609
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1610 1610
 			    }
1611 1611
 			    
1612 1612
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1613 1613
 			    //echo 'APRS data : '.$buffer."\n";
1614
-			    $buffer = str_replace('APRS <- ','',$buffer);
1615
-			    $buffer = str_replace('APRS -> ','',$buffer);
1614
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1615
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1616 1616
 			    //echo $buffer."\n";
1617 1617
 			    date_default_timezone_set('UTC');
1618
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1618
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1619 1619
 				$line = $APRS->parse($buffer);
1620 1620
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1621 1621
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1631 1631
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1632 1632
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1633
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1633
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1634 1634
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1635 1635
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1636 1636
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1713,29 +1713,29 @@  discard block
 block discarded – undo
1713 1713
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1714 1714
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1715 1715
 					$Source->deleteOldLocationByType('gs');
1716
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1717
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1716
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1717
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1718 1718
 					} else {
1719
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1719
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1720 1720
 					}
1721 1721
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1722 1722
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1723 1723
 					if ($globalDebug) echo '# Weather Station added'."\n";
1724 1724
 					$Source->deleteOldLocationByType('wx');
1725 1725
 					$weather_data = json_encode($line);
1726
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1727
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1726
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1727
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1728 1728
 					} else {
1729
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1729
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1730 1730
 					}
1731 1731
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1732 1732
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1733 1733
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1734 1734
 					$Source->deleteOldLocationByType('lightning');
1735
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1736
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1735
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1736
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1737 1737
 					} else {
1738
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1738
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1739 1739
 					}
1740 1740
 				    } elseif ($globalDebug) {
1741 1741
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 				    unset($data);
1745 1745
 				}
1746 1746
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1747
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1747
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1748 1748
 				}
1749 1749
 				/*
1750 1750
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) {
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 				*/
1754 1754
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1755 1755
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1756
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1756
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1757 1757
 					$Source->deleteOldLocationByType('lightning');
1758 1758
 					$Source->deleteOldLocationByType('wx');
1759 1759
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
 				connect_all($sourceee);
1839 1839
 				$sourceee = array();
1840 1840
 				//connect_all($globalSources);
1841
-				$tt[$format]=0;
1841
+				$tt[$format] = 0;
1842 1842
 				break;
1843 1843
 			    } 
1844 1844
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -1848,14 +1848,14 @@  discard block
 block discarded – undo
1848 1848
 	    } else {
1849 1849
 		$error = socket_strerror(socket_last_error());
1850 1850
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1851
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1851
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1852 1852
 			if (isset($globalDebug)) echo "Restarting...\n";
1853 1853
 			// Restart the script if possible
1854 1854
 			if (is_array($sockets)) {
1855 1855
 			    if ($globalDebug) echo "Shutdown all sockets...";
1856 1856
 			    
1857 1857
 			    foreach ($sockets as $sock) {
1858
-				@socket_shutdown($sock,2);
1858
+				@socket_shutdown($sock, 2);
1859 1859
 				@socket_close($sock);
1860 1860
 			    }
1861 1861
 			    
Please login to merge, or discard this patch.
Indentation   +1054 added lines, -1054 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,41 +149,41 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
177
-        	//$formats[$id] = 'aircraftjson';
178
-        	$globalSources[$id]['format'] = 'aircraftjson';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/opensky/i',$host)) {
182
-        	//$formats[$id] = 'aircraftlistjson';
183
-        	$globalSources[$id]['format'] = 'opensky';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
186
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/aircraft.json$/i',$host)) {
177
+			//$formats[$id] = 'aircraftjson';
178
+			$globalSources[$id]['format'] = 'aircraftjson';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
181
+			} else if (preg_match('/opensky/i',$host)) {
182
+			//$formats[$id] = 'aircraftlistjson';
183
+			$globalSources[$id]['format'] = 'opensky';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
186
+			/*
187 187
     	    // Disabled for now, site change source format
188 188
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
189 189
         	//$formats[$id] = 'radarvirtueljson';
@@ -195,125 +195,125 @@  discard block
 block discarded – undo
195 195
         	    exit(0);
196 196
         	}
197 197
     	    */
198
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
199
-        	//$formats[$id] = 'planeupdatefaa';
200
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
201
-        	//$last_exec['planeupdatefaa'] = 0;
202
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
204
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
205
-        	    exit(0);
206
-        	}
207
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
208
-        	//$formats[$id] = 'phpvmacars';
209
-        	$globalSources[$id]['format'] = 'phpvmacars';
210
-        	//$last_exec['phpvmacars'] = 0;
211
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
212
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'vaos';
215
-        	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
217
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
218
-        	//$formats[$id] = 'phpvmacars';
219
-        	$globalSources[$id]['format'] = 'vam';
220
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
221
-            } else if (preg_match('/whazzup/i',$host)) {
222
-        	//$formats[$id] = 'whazzup';
223
-        	$globalSources[$id]['format'] = 'whazzup';
224
-        	//$last_exec['whazzup'] = 0;
225
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
226
-            } else if (preg_match('/blitzortung/i',$host)) {
227
-        	$globalSources[$id]['format'] = 'blitzortung';
228
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
229
-            } else if (preg_match('/airwhere/i',$host)) {
230
-        	$globalSources[$id]['format'] = 'airwhere';
231
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
-            } else if (preg_match('/recentpireps/i',$host)) {
233
-        	//$formats[$id] = 'pirepsjson';
234
-        	$globalSources[$id]['format'] = 'pirepsjson';
235
-        	//$last_exec['pirepsjson'] = 0;
236
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
237
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
238
-        	//$formats[$id] = 'fr24json';
239
-        	$globalSources[$id]['format'] = 'fr24json';
240
-        	//$last_exec['fr24json'] = 0;
241
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
242
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
243
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
244
-        	    exit(0);
245
-        	}
246
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
247
-        	//$formats[$id] = 'fr24json';
248
-        	$globalSources[$id]['format'] = 'myshiptracking';
249
-        	//$last_exec['fr24json'] = 0;
250
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
251
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
252
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
253
-        	    exit(0);
254
-        	}
255
-            //} else if (preg_match('/10001/',$host)) {
256
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
257
-        	//$formats[$id] = 'tsv';
258
-        	$globalSources[$id]['format'] = 'tsv';
259
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260
-            }
261
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
262
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
263
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
264
-    		    if ($idf !== false) {
265
-    			$httpfeeds[$id] = $idf;
266
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
267
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
268
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
270
-	    $hostport = explode(':',$host);
271
-	    if (isset($hostport[1])) {
198
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
199
+			//$formats[$id] = 'planeupdatefaa';
200
+			$globalSources[$id]['format'] = 'planeupdatefaa';
201
+			//$last_exec['planeupdatefaa'] = 0;
202
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
204
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
205
+				exit(0);
206
+			}
207
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
208
+			//$formats[$id] = 'phpvmacars';
209
+			$globalSources[$id]['format'] = 'phpvmacars';
210
+			//$last_exec['phpvmacars'] = 0;
211
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
212
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'vaos';
215
+			//$last_exec['phpvmacars'] = 0;
216
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
217
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
218
+			//$formats[$id] = 'phpvmacars';
219
+			$globalSources[$id]['format'] = 'vam';
220
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
221
+			} else if (preg_match('/whazzup/i',$host)) {
222
+			//$formats[$id] = 'whazzup';
223
+			$globalSources[$id]['format'] = 'whazzup';
224
+			//$last_exec['whazzup'] = 0;
225
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
226
+			} else if (preg_match('/blitzortung/i',$host)) {
227
+			$globalSources[$id]['format'] = 'blitzortung';
228
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
229
+			} else if (preg_match('/airwhere/i',$host)) {
230
+			$globalSources[$id]['format'] = 'airwhere';
231
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
+			} else if (preg_match('/recentpireps/i',$host)) {
233
+			//$formats[$id] = 'pirepsjson';
234
+			$globalSources[$id]['format'] = 'pirepsjson';
235
+			//$last_exec['pirepsjson'] = 0;
236
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
237
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
238
+			//$formats[$id] = 'fr24json';
239
+			$globalSources[$id]['format'] = 'fr24json';
240
+			//$last_exec['fr24json'] = 0;
241
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
242
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
243
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
244
+				exit(0);
245
+			}
246
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
247
+			//$formats[$id] = 'fr24json';
248
+			$globalSources[$id]['format'] = 'myshiptracking';
249
+			//$last_exec['fr24json'] = 0;
250
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
251
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
252
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
253
+				exit(0);
254
+			}
255
+			//} else if (preg_match('/10001/',$host)) {
256
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
257
+			//$formats[$id] = 'tsv';
258
+			$globalSources[$id]['format'] = 'tsv';
259
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260
+			}
261
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
262
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
263
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
264
+				if ($idf !== false) {
265
+				$httpfeeds[$id] = $idf;
266
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
267
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
268
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
270
+		$hostport = explode(':',$host);
271
+		if (isset($hostport[1])) {
272 272
 		$port = $hostport[1];
273 273
 		$hostn = $hostport[0];
274
-	    } else {
274
+		} else {
275 275
 		$port = $globalSources[$id]['port'];
276 276
 		$hostn = $globalSources[$id]['host'];
277
-	    }
278
-	    $Common = new Common();
279
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
280
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
281
-    	    } else {
282
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
283
-	    }
284
-	    if ($s) {
285
-    	        $sockets[$id] = $s;
286
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
287
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
277
+		}
278
+		$Common = new Common();
279
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
280
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
281
+			} else {
282
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
283
+		}
284
+		if ($s) {
285
+				$sockets[$id] = $s;
286
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
287
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
288 288
 			//$formats[$id] = 'aprs';
289 289
 			$globalSources[$id]['format'] = 'aprs';
290 290
 			//$aprs_connect = 0;
291 291
 			//$use_aprs = true;
292
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
292
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
293 293
 			$globalSources[$id]['format'] = 'vrstcp';
294
-    		    } elseif ($port == '10001') {
295
-        		//$formats[$id] = 'tsv';
296
-        		$globalSources[$id]['format'] = 'tsv';
297
-		    } elseif ($port == '30002') {
298
-        		//$formats[$id] = 'raw';
299
-        		$globalSources[$id]['format'] = 'raw';
300
-		    } elseif ($port == '5001') {
301
-        		//$formats[$id] = 'raw';
302
-        		$globalSources[$id]['format'] = 'flightgearmp';
303
-		    } elseif ($port == '30005') {
294
+				} elseif ($port == '10001') {
295
+				//$formats[$id] = 'tsv';
296
+				$globalSources[$id]['format'] = 'tsv';
297
+			} elseif ($port == '30002') {
298
+				//$formats[$id] = 'raw';
299
+				$globalSources[$id]['format'] = 'raw';
300
+			} elseif ($port == '5001') {
301
+				//$formats[$id] = 'raw';
302
+				$globalSources[$id]['format'] = 'flightgearmp';
303
+			} elseif ($port == '30005') {
304 304
 			// Not yet supported
305
-        		//$formats[$id] = 'beast';
306
-        		$globalSources[$id]['format'] = 'beast';
307
-		    //} else $formats[$id] = 'sbs';
308
-		    } else $globalSources[$id]['format'] = 'sbs';
309
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
305
+				//$formats[$id] = 'beast';
306
+				$globalSources[$id]['format'] = 'beast';
307
+			//} else $formats[$id] = 'sbs';
308
+			} else $globalSources[$id]['format'] = 'sbs';
309
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
310 310
 		}
311 311
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
312
-            } else {
312
+			} else {
313 313
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
314
-    	    }
315
-        }
316
-    }
314
+			}
315
+		}
316
+	}
317 317
 }
318 318
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
319 319
 
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 //connect_all($globalSources);
337 337
 
338 338
 if (isset($globalProxy) && $globalProxy) {
339
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
339
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
340 340
 } else {
341
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
341
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
342 342
 }
343 343
 
344 344
 // APRS Configuration
@@ -347,21 +347,21 @@  discard block
 block discarded – undo
347 347
 	die;
348 348
 }
349 349
 foreach ($globalSources as $key => $source) {
350
-    if (!isset($source['format'])) {
351
-        $globalSources[$key]['format'] = 'auto';
352
-    }
353
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
354
-        unset($globalSources[$key]);
355
-    }
350
+	if (!isset($source['format'])) {
351
+		$globalSources[$key]['format'] = 'auto';
352
+	}
353
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
354
+		unset($globalSources[$key]);
355
+	}
356 356
 }
357 357
 connect_all($globalSources);
358 358
 foreach ($globalSources as $key => $source) {
359
-    if (isset($source['format']) && $source['format'] == 'aprs') {
359
+	if (isset($source['format']) && $source['format'] == 'aprs') {
360 360
 	$aprs_connect = 0;
361 361
 	$use_aprs = true;
362 362
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
363 363
 	break;
364
-    }
364
+	}
365 365
 }
366 366
 
367 367
 if ($use_aprs) {
@@ -402,133 +402,133 @@  discard block
 block discarded – undo
402 402
 
403 403
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
404 404
 while ($i > 0) {
405
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
405
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
406 406
 
407
-    if (!$globalDaemon) $i = $endtime-time();
408
-    // Delete old ATC
409
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
407
+	if (!$globalDaemon) $i = $endtime-time();
408
+	// Delete old ATC
409
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
410 410
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
411
-        $ATC->deleteOldATC();
412
-    }
411
+		$ATC->deleteOldATC();
412
+	}
413 413
     
414
-    if (count($last_exec) == count($globalSources)) {
414
+	if (count($last_exec) == count($globalSources)) {
415 415
 	$max = $globalMinFetch;
416 416
 	foreach ($last_exec as $last) {
417
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
417
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
418 418
 	}
419 419
 	if ($max < $globalMinFetch) {
420
-	    if ($globalDebug) echo 'Sleeping...'."\n";
421
-	    sleep($globalMinFetch-$max+2);
420
+		if ($globalDebug) echo 'Sleeping...'."\n";
421
+		sleep($globalMinFetch-$max+2);
422
+	}
422 423
 	}
423
-    }
424 424
 
425 425
     
426
-    //foreach ($formats as $id => $value) {
427
-    foreach ($globalSources as $id => $value) {
426
+	//foreach ($formats as $id => $value) {
427
+	foreach ($globalSources as $id => $value) {
428 428
 	date_default_timezone_set('UTC');
429 429
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
430 430
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
431 431
 	if ($value['format'] === 'deltadbtxt' && 
432
-	    (
432
+		(
433 433
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
434 434
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
435
-	    )
435
+		)
436 436
 	) {
437
-	    //$buffer = $Common->getData($hosts[$id]);
438
-	    $buffer = $Common->getData($value['host']);
439
-	    if ($buffer != '') $reset = 0;
440
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
441
-	    $buffer = explode('\n',$buffer);
442
-	    foreach ($buffer as $line) {
443
-    		if ($line != '' && count($line) > 7) {
444
-    		    $line = explode(',', $line);
445
-	            $data = array();
446
-	            $data['hex'] = $line[1]; // hex
447
-	            $data['ident'] = $line[2]; // ident
448
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
449
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
450
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
451
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
452
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
453
-	            $data['verticalrate'] = ''; // vertical rate
454
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
455
-	            $data['emergency'] = ''; // emergency
456
-		    $data['datetime'] = date('Y-m-d H:i:s');
457
-		    $data['format_source'] = 'deltadbtxt';
458
-    		    $data['id_source'] = $id_source;
459
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
460
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
461
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
462
-    		    $SI->add($data);
463
-		    unset($data);
464
-    		}
465
-    	    }
466
-    	    $last_exec[$id]['last'] = time();
437
+		//$buffer = $Common->getData($hosts[$id]);
438
+		$buffer = $Common->getData($value['host']);
439
+		if ($buffer != '') $reset = 0;
440
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
441
+		$buffer = explode('\n',$buffer);
442
+		foreach ($buffer as $line) {
443
+			if ($line != '' && count($line) > 7) {
444
+				$line = explode(',', $line);
445
+				$data = array();
446
+				$data['hex'] = $line[1]; // hex
447
+				$data['ident'] = $line[2]; // ident
448
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
449
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
450
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
451
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
452
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
453
+				$data['verticalrate'] = ''; // vertical rate
454
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
455
+				$data['emergency'] = ''; // emergency
456
+			$data['datetime'] = date('Y-m-d H:i:s');
457
+			$data['format_source'] = 'deltadbtxt';
458
+				$data['id_source'] = $id_source;
459
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
460
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
461
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
462
+				$SI->add($data);
463
+			unset($data);
464
+			}
465
+			}
466
+			$last_exec[$id]['last'] = time();
467 467
 	} elseif ($value['format'] === 'aisnmeatxt' && 
468
-	    (
468
+		(
469 469
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
470 470
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
471
-	    )
471
+		)
472 472
 	) {
473
-	    date_default_timezone_set('CET');
474
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
475
-	    date_default_timezone_set('UTC');
476
-	    if ($buffer != '') $reset = 0;
477
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
478
-	    $buffer = explode('\n',$buffer);
479
-	    foreach ($buffer as $line) {
473
+		date_default_timezone_set('CET');
474
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
475
+		date_default_timezone_set('UTC');
476
+		if ($buffer != '') $reset = 0;
477
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
478
+		$buffer = explode('\n',$buffer);
479
+		foreach ($buffer as $line) {
480 480
 		if ($line != '') {
481
-		    //echo "'".$line."'\n";
482
-		    $add = false;
483
-		    $ais_data = $AIS->parse_line(trim($line));
484
-		    $data = array();
485
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
486
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
487
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
488
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
489
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
490
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
491
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
492
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
493
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
494
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
495
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
496
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
497
-		    if (isset($ais_data['timestamp'])) {
481
+			//echo "'".$line."'\n";
482
+			$add = false;
483
+			$ais_data = $AIS->parse_line(trim($line));
484
+			$data = array();
485
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
486
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
487
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
488
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
489
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
490
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
491
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
492
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
493
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
494
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
495
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
496
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
497
+			if (isset($ais_data['timestamp'])) {
498 498
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
499 499
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
500
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
501
-			    $add = true;
500
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
501
+				$add = true;
502 502
 			}
503
-		    } else {
503
+			} else {
504 504
 			$data['datetime'] = date('Y-m-d H:i:s');
505 505
 			$add = true;
506
-		    }
507
-		    $data['format_source'] = 'aisnmeatxt';
508
-    		    $data['id_source'] = $id_source;
509
-		    //print_r($data);
510
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
511
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
512
-		    unset($data);
506
+			}
507
+			$data['format_source'] = 'aisnmeatxt';
508
+				$data['id_source'] = $id_source;
509
+			//print_r($data);
510
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
511
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
512
+			unset($data);
513 513
 		}
514
-    	    }
515
-    	    $last_exec[$id]['last'] = time();
514
+			}
515
+			$last_exec[$id]['last'] = time();
516 516
 	} elseif ($value['format'] === 'aisnmeahttp') {
517
-	    $arr = $httpfeeds;
518
-	    $w = $e = null;
517
+		$arr = $httpfeeds;
518
+		$w = $e = null;
519 519
 	    
520
-	    if (isset($arr[$id])) {
520
+		if (isset($arr[$id])) {
521 521
 		$nn = stream_select($arr,$w,$e,$timeout);
522 522
 		if ($nn > 0) {
523
-		    foreach ($httpfeeds as $feed) {
523
+			foreach ($httpfeeds as $feed) {
524 524
 			$buffer = stream_get_line($feed,2000,"\n");
525 525
 			if ($buffer === FALSE) {
526
-			    connect_all($globalSources);
526
+				connect_all($globalSources);
527 527
 			}
528 528
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
529 529
 			$buffer = explode('\n',$buffer);
530 530
 			foreach ($buffer as $line) {
531
-			    if ($line != '') {
531
+				if ($line != '') {
532 532
 				$ais_data = $AIS->parse_line(trim($line));
533 533
 				$data = array();
534 534
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -546,117 +546,117 @@  discard block
 block discarded – undo
546 546
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
547 547
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
548 548
 				if (isset($ais_data['timestamp'])) {
549
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
549
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
550 550
 				} else {
551
-				    $data['datetime'] = date('Y-m-d H:i:s');
551
+					$data['datetime'] = date('Y-m-d H:i:s');
552 552
 				}
553 553
 				$data['format_source'] = 'aisnmeahttp';
554 554
 				$data['id_source'] = $id_source;
555 555
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
556 556
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
557 557
 				unset($data);
558
-			    }
558
+				}
559
+			}
559 560
 			}
560
-		    }
561 561
 		} else {
562
-		    $format = $value['format'];
563
-		    if (isset($tt[$format])) $tt[$format]++;
564
-		    else $tt[$format] = 0;
565
-		    if ($tt[$format] > 30) {
562
+			$format = $value['format'];
563
+			if (isset($tt[$format])) $tt[$format]++;
564
+			else $tt[$format] = 0;
565
+			if ($tt[$format] > 30) {
566 566
 			if ($globalDebug) echo 'Reconnect...'."\n";
567 567
 			sleep(2);
568 568
 			//$sourceeen[] = $value;
569 569
 			//connect_all($sourceeen);
570 570
 			//$sourceeen = array();
571 571
 			connect_all($globalSources);
572
-		    }
572
+			}
573
+		}
573 574
 		}
574
-	    }
575 575
 	} elseif ($value['format'] === 'myshiptracking' && 
576
-	    (
576
+		(
577 577
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
578 578
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
579
-	    )
579
+		)
580 580
 	) {
581
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
582
-	    if ($buffer != '') {
581
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
582
+		if ($buffer != '') {
583 583
 		//echo $buffer;
584 584
 		$all_data = json_decode($buffer,true);
585 585
 		//print_r($all_data);
586 586
 		if (isset($all_data[0]['DATA'])) {
587
-		    foreach ($all_data[0]['DATA'] as $line) {
587
+			foreach ($all_data[0]['DATA'] as $line) {
588 588
 			if ($line != '') {
589
-			    $data = array();
590
-			    $data['ident'] = $line['NAME'];
591
-			    $data['mmsi'] = $line['MMSI'];
592
-			    if (strlen($data['mmsi']) > 9) {
589
+				$data = array();
590
+				$data['ident'] = $line['NAME'];
591
+				$data['mmsi'] = $line['MMSI'];
592
+				if (strlen($data['mmsi']) > 9) {
593 593
 				$data['mmsi'] = substr($data['mmsi'],-9);
594
-			    }
595
-			    $data['speed'] = $line['SOG'];
596
-			    $data['heading'] = $line['COG'];
597
-			    $data['latitude'] = $line['LAT'];
598
-			    $data['longitude'] = $line['LNG'];
599
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
600
-			    //$data['type_id'] = $line['TYPE'];
601
-			    $data['imo'] = $line['IMO'];
602
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
603
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
604
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
605
-			    $data['format_source'] = 'myshiptracking';
606
-			    $data['id_source'] = $id_source;
607
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
608
-			    $MI->add($data);
609
-			    unset($data);
594
+				}
595
+				$data['speed'] = $line['SOG'];
596
+				$data['heading'] = $line['COG'];
597
+				$data['latitude'] = $line['LAT'];
598
+				$data['longitude'] = $line['LNG'];
599
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
600
+				//$data['type_id'] = $line['TYPE'];
601
+				$data['imo'] = $line['IMO'];
602
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
603
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
604
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
605
+				$data['format_source'] = 'myshiptracking';
606
+				$data['id_source'] = $id_source;
607
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
608
+				$MI->add($data);
609
+				unset($data);
610 610
 			}
611
-		    }
611
+			}
612
+		}
612 613
 		}
613
-	    }
614
-	    $last_exec[$id]['last'] = time();
614
+		$last_exec[$id]['last'] = time();
615 615
 	} elseif ($value['format'] === 'boatbeaconapp' && 
616
-	    (
616
+		(
617 617
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
618 618
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
619
-	    )
619
+		)
620 620
 	) {
621
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
622
-	    if ($buffer != '') {
621
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
622
+		if ($buffer != '') {
623 623
 		$all_data = json_decode($buffer,true);
624 624
 		if (isset($all_data[0]['mmsi'])) {
625
-		    foreach ($all_data as $line) {
625
+			foreach ($all_data as $line) {
626 626
 			if ($line != '') {
627
-			    $data = array();
628
-			    $data['ident'] = $line['shipname'];
629
-			    $data['callsign'] = $line['callsign'];
630
-			    $data['mmsi'] = substr($line['mmsi'],-9);
631
-			    $data['speed'] = $line['sog'];
632
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
633
-			    $data['latitude'] = $line['latitude'];
634
-			    $data['longitude'] = $line['longitude'];
635
-			    $data['type_id'] = $line['shiptype'];
636
-			    $data['arrival_code'] = $line['destination'];
637
-			    $data['datetime'] = $line['time'];
638
-			    $data['format_source'] = 'boatbeaconapp';
639
-			    $data['id_source'] = $id_source;
640
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
641
-			    $MI->add($data);
642
-			    unset($data);
627
+				$data = array();
628
+				$data['ident'] = $line['shipname'];
629
+				$data['callsign'] = $line['callsign'];
630
+				$data['mmsi'] = substr($line['mmsi'],-9);
631
+				$data['speed'] = $line['sog'];
632
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
633
+				$data['latitude'] = $line['latitude'];
634
+				$data['longitude'] = $line['longitude'];
635
+				$data['type_id'] = $line['shiptype'];
636
+				$data['arrival_code'] = $line['destination'];
637
+				$data['datetime'] = $line['time'];
638
+				$data['format_source'] = 'boatbeaconapp';
639
+				$data['id_source'] = $id_source;
640
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
641
+				$MI->add($data);
642
+				unset($data);
643
+			}
643 644
 			}
644
-		    }
645 645
 		}
646 646
 		
647
-	    }
648
-    	    $last_exec[$id]['last'] = time();
647
+		}
648
+			$last_exec[$id]['last'] = time();
649 649
 	} elseif ($value['format'] === 'boatnerd' && 
650
-	    (
650
+		(
651 651
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
652 652
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
653
-	    )
653
+		)
654 654
 	) {
655
-	    $buffer = $Common->getData($value['host']);
656
-	    if ($buffer != '') {
655
+		$buffer = $Common->getData($value['host']);
656
+		if ($buffer != '') {
657 657
 		$all_data = json_decode($buffer,true);
658 658
 		if (isset($all_data['features'][0]['id'])) {
659
-		    foreach ($all_data['features'] as $line) {
659
+			foreach ($all_data['features'] as $line) {
660 660
 			print_r($line);
661 661
 			$data = array();
662 662
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -676,80 +676,80 @@  discard block
 block discarded – undo
676 676
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
677 677
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
678 678
 			unset($data);
679
-		    }
679
+			}
680 680
 		}
681 681
 		
682
-	    }
683
-    	    $last_exec[$id]['last'] = time();
682
+		}
683
+			$last_exec[$id]['last'] = time();
684 684
 	} elseif ($value['format'] === 'shipplotter' && 
685
-	    (
685
+		(
686 686
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
687 687
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
688
-	    )
688
+		)
689 689
 	) {
690
-	    echo 'download...';
691
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
692
-	    echo 'done !'."\n";
693
-	    // FIXME: Need more work
694
-	    if ($buffer != '') $reset = 0;
695
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
696
-	    $buffer = explode('\n',$buffer);
697
-	    foreach ($buffer as $line) {
690
+		echo 'download...';
691
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
692
+		echo 'done !'."\n";
693
+		// FIXME: Need more work
694
+		if ($buffer != '') $reset = 0;
695
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
696
+		$buffer = explode('\n',$buffer);
697
+		foreach ($buffer as $line) {
698 698
 		if ($line != '') {
699
-		    $data = array();
700
-		    echo $line."\n";
701
-		    $data['mmsi'] = (int)substr($line,0,9);
702
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
703
-		    $data['status_id'] = substr($line,21,2);
704
-		    $data['type_id'] = substr($line,24,3);
705
-		    $data['latitude'] = substr($line,29,9);
706
-		    $data['longitude'] = substr($line,41,9);
707
-		    $data['speed'] = round(substr($line,51,5));
708
-		    //$data['course'] = substr($line,57,5);
709
-		    $data['heading'] = round(substr($line,63,3));
710
-		    //$data['draft'] = substr($line,67,4);
711
-		    //$data['length'] = substr($line,72,3);
712
-		    //$data['beam'] = substr($line,76,2);
713
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
714
-		    //$data['callsign'] = trim(substr($line,100,7);
715
-		    $data['arrival_code'] = substr($line,108,20);
716
-		    //$data['etaDate'] = substr($line,129,5);
717
-		    //$data['etaTime'] = substr($line,135,5);
718
-		    $data['format_source'] = 'shipplotter';
719
-    		    $data['id_source'] = $id_source;
720
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
721
-		    //print_r($data);
722
-		    echo 'Add...'."\n";
723
-		    $MI->add($data);
724
-		    unset($data);
699
+			$data = array();
700
+			echo $line."\n";
701
+			$data['mmsi'] = (int)substr($line,0,9);
702
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
703
+			$data['status_id'] = substr($line,21,2);
704
+			$data['type_id'] = substr($line,24,3);
705
+			$data['latitude'] = substr($line,29,9);
706
+			$data['longitude'] = substr($line,41,9);
707
+			$data['speed'] = round(substr($line,51,5));
708
+			//$data['course'] = substr($line,57,5);
709
+			$data['heading'] = round(substr($line,63,3));
710
+			//$data['draft'] = substr($line,67,4);
711
+			//$data['length'] = substr($line,72,3);
712
+			//$data['beam'] = substr($line,76,2);
713
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
714
+			//$data['callsign'] = trim(substr($line,100,7);
715
+			$data['arrival_code'] = substr($line,108,20);
716
+			//$data['etaDate'] = substr($line,129,5);
717
+			//$data['etaTime'] = substr($line,135,5);
718
+			$data['format_source'] = 'shipplotter';
719
+				$data['id_source'] = $id_source;
720
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
721
+			//print_r($data);
722
+			echo 'Add...'."\n";
723
+			$MI->add($data);
724
+			unset($data);
725 725
 		}
726
-    	    }
727
-    	    $last_exec[$id]['last'] = time();
726
+			}
727
+			$last_exec[$id]['last'] = time();
728 728
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
729 729
 	} elseif (
730
-	    (
730
+		(
731 731
 		$value['format'] === 'whazzup' && 
732 732
 		(
733
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
734
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
733
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
734
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
735 735
 		)
736
-	    ) || (
736
+		) || (
737 737
 		$value['format'] === 'vatsimtxt' && 
738 738
 		(
739
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
740
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
739
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
740
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
741
+		)
741 742
 		)
742
-	    )
743 743
 	) {
744
-	    //$buffer = $Common->getData($hosts[$id]);
745
-	    $buffer = $Common->getData($value['host']);
746
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
747
-	    $buffer = explode('\n',$buffer);
748
-	    $reset = 0;
749
-	    foreach ($buffer as $line) {
750
-    		if ($line != '') {
751
-    		    $line = explode(':', $line);
752
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
744
+		//$buffer = $Common->getData($hosts[$id]);
745
+		$buffer = $Common->getData($value['host']);
746
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
747
+		$buffer = explode('\n',$buffer);
748
+		$reset = 0;
749
+		foreach ($buffer as $line) {
750
+			if ($line != '') {
751
+				$line = explode(':', $line);
752
+				if (count($line) > 30 && $line[0] != 'callsign') {
753 753
 			$data = array();
754 754
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
755 755
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -762,37 +762,37 @@  discard block
 block discarded – undo
762 762
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
763 763
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
764 764
 			$data['latitude'] = $line[5]; // lat
765
-	        	$data['longitude'] = $line[6]; // long
766
-	        	$data['verticalrate'] = ''; // vertical rate
767
-	        	$data['squawk'] = ''; // squawk
768
-	        	$data['emergency'] = ''; // emergency
769
-	        	$data['waypoints'] = $line[30];
765
+				$data['longitude'] = $line[6]; // long
766
+				$data['verticalrate'] = ''; // vertical rate
767
+				$data['squawk'] = ''; // squawk
768
+				$data['emergency'] = ''; // emergency
769
+				$data['waypoints'] = $line[30];
770 770
 			$data['datetime'] = date('Y-m-d H:i:s');
771 771
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
772 772
 			//if (isset($line[37])) $data['last_update'] = $line[37];
773
-		        $data['departure_airport_icao'] = $line[11];
774
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
775
-		        $data['arrival_airport_icao'] = $line[13];
773
+				$data['departure_airport_icao'] = $line[11];
774
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
775
+				$data['arrival_airport_icao'] = $line[13];
776 776
 			$data['frequency'] = $line[4];
777 777
 			$data['type'] = $line[18];
778 778
 			$data['range'] = $line[19];
779 779
 			if (isset($line[35])) $data['info'] = $line[35];
780
-    			$data['id_source'] = $id_source;
781
-	    		//$data['arrival_airport_time'] = ;
782
-	    		if ($line[9] != '') {
783
-	    		    $aircraft_data = explode('/',$line[9]);
784
-	    		    if (isset($aircraft_data[1])) {
785
-	    			$data['aircraft_icao'] = $aircraft_data[1];
786
-	    		    }
787
-        		}
788
-	    		/*
780
+				$data['id_source'] = $id_source;
781
+				//$data['arrival_airport_time'] = ;
782
+				if ($line[9] != '') {
783
+					$aircraft_data = explode('/',$line[9]);
784
+					if (isset($aircraft_data[1])) {
785
+					$data['aircraft_icao'] = $aircraft_data[1];
786
+					}
787
+				}
788
+				/*
789 789
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
790 790
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
791 791
 	    		*/
792
-	    		$data['format_source'] = $value['format'];
792
+				$data['format_source'] = $value['format'];
793 793
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
794 794
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
795
-    			if ($line[3] === 'PILOT') $SI->add($data);
795
+				if ($line[3] === 'PILOT') $SI->add($data);
796 796
 			elseif ($line[3] === 'ATC') {
797 797
 				//print_r($data);
798 798
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -813,21 +813,21 @@  discard block
 block discarded – undo
813 813
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
814 814
 				}
815 815
 			}
816
-    			unset($data);
817
-    		    }
818
-    		}
819
-    	    }
820
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
821
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
822
-    	    $last_exec[$id]['last'] = time();
823
-    	} elseif ($value['format'] === 'airwhere' && 
824
-    	    (
825
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
826
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
827
-    	    )
828
-    	) {
829
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
830
-	    if ($buffer != '') {
816
+				unset($data);
817
+				}
818
+			}
819
+			}
820
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
821
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
822
+			$last_exec[$id]['last'] = time();
823
+		} elseif ($value['format'] === 'airwhere' && 
824
+			(
825
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
826
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
827
+			)
828
+		) {
829
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
830
+		if ($buffer != '') {
831 831
 		$all_data = simplexml_load_string($buffer);
832 832
 		foreach($all_data->children() as $childdata) {
833 833
 			$data = array();
@@ -849,10 +849,10 @@  discard block
 block discarded – undo
849 849
 			$SI->add($data);
850 850
 			unset($data);
851 851
 		}
852
-	    }
853
-	    $Source->deleteOldLocationByType('gs');
854
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
855
-	    if ($buffer != '') {
852
+		}
853
+		$Source->deleteOldLocationByType('gs');
854
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
855
+		if ($buffer != '') {
856 856
 		$all_data = simplexml_load_string($buffer);
857 857
 		foreach($all_data->children() as $childdata) {
858 858
 			$data = array();
@@ -870,8 +870,8 @@  discard block
 block discarded – undo
870 870
 			}
871 871
 			unset($data);
872 872
 		}
873
-	    }
874
-	    $last_exec[$id]['last'] = time();
873
+		}
874
+		$last_exec[$id]['last'] = time();
875 875
 	/*
876 876
 	} if ($value['format'] === 'aircraftlistjson') {
877 877
 	    print_r($globalSources);
@@ -879,17 +879,17 @@  discard block
 block discarded – undo
879 879
 	    echo $globalMinFetch;
880 880
 	*/
881 881
 	} elseif ($value['format'] === 'aircraftlistjson' && 
882
-	    (
882
+		(
883 883
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
884 884
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
885
-	    )
885
+		)
886 886
 	) {
887
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
888
-	    if ($buffer != '') {
889
-	        $all_data = json_decode($buffer,true);
887
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
888
+		if ($buffer != '') {
889
+			$all_data = json_decode($buffer,true);
890 890
 		if (isset($all_data['acList'])) {
891
-		    $reset = 0;
892
-		    foreach ($all_data['acList'] as $line) {
891
+			$reset = 0;
892
+			foreach ($all_data['acList'] as $line) {
893 893
 			$data = array();
894 894
 			$data['hex'] = $line['Icao']; // hex
895 895
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -912,10 +912,10 @@  discard block
 block discarded – undo
912 912
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
913 913
 			if (isset($data['latitude'])) $SI->add($data);
914 914
 			unset($data);
915
-		    }
915
+			}
916 916
 		} elseif (is_array($all_data)) {
917
-		    $reset = 0;
918
-		    foreach ($all_data as $line) {
917
+			$reset = 0;
918
+			foreach ($all_data as $line) {
919 919
 			$data = array();
920 920
 			$data['hex'] = $line['hex']; // hex
921 921
 			$data['ident'] = $line['flight']; // ident
@@ -935,252 +935,252 @@  discard block
 block discarded – undo
935 935
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
936 936
 			$SI->add($data);
937 937
 			unset($data);
938
-		    }
938
+			}
939 939
 		}
940
-	    } elseif ($globalDebug) echo 'No data'."\n";
941
-    	    //$last_exec['aircraftlistjson'] = time();
942
-    	    $last_exec[$id]['last'] = time();
943
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
944
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
945
-    	    (
946
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
947
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
948
-    	    )
949
-    	) {
950
-	    $buffer = $Common->getData($value['host']);
951
-	    $all_data = json_decode($buffer,true);
952
-	    if (isset($all_data['planes'])) {
940
+		} elseif ($globalDebug) echo 'No data'."\n";
941
+			//$last_exec['aircraftlistjson'] = time();
942
+			$last_exec[$id]['last'] = time();
943
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
944
+		} elseif ($value['format'] === 'planeupdatefaa' && 
945
+			(
946
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
947
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
948
+			)
949
+		) {
950
+		$buffer = $Common->getData($value['host']);
951
+		$all_data = json_decode($buffer,true);
952
+		if (isset($all_data['planes'])) {
953 953
 		$reset = 0;
954 954
 		foreach ($all_data['planes'] as $key => $line) {
955
-		    $data = array();
956
-		    $data['hex'] = $key; // hex
957
-		    $data['ident'] = $line[3]; // ident
958
-		    $data['altitude'] = $line[6]; // altitude
959
-		    $data['speed'] = $line[8]; // speed
960
-		    $data['heading'] = $line[7]; // heading
961
-		    $data['latitude'] = $line[4]; // lat
962
-		    $data['longitude'] = $line[5]; // long
963
-		    //$data['verticalrate'] = $line[]; // verticale rate
964
-		    $data['squawk'] = $line[10]; // squawk
965
-		    $data['emergency'] = ''; // emergency
966
-		    $data['registration'] = $line[2];
967
-		    $data['aircraft_icao'] = $line[0];
968
-		    $deparr = explode('-',$line[1]);
969
-		    if (count($deparr) === 2) {
955
+			$data = array();
956
+			$data['hex'] = $key; // hex
957
+			$data['ident'] = $line[3]; // ident
958
+			$data['altitude'] = $line[6]; // altitude
959
+			$data['speed'] = $line[8]; // speed
960
+			$data['heading'] = $line[7]; // heading
961
+			$data['latitude'] = $line[4]; // lat
962
+			$data['longitude'] = $line[5]; // long
963
+			//$data['verticalrate'] = $line[]; // verticale rate
964
+			$data['squawk'] = $line[10]; // squawk
965
+			$data['emergency'] = ''; // emergency
966
+			$data['registration'] = $line[2];
967
+			$data['aircraft_icao'] = $line[0];
968
+			$deparr = explode('-',$line[1]);
969
+			if (count($deparr) === 2) {
970 970
 			$data['departure_airport_icao'] = $deparr[0];
971 971
 			$data['arrival_airport_icao'] = $deparr[1];
972
-		    }
973
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
974
-	    	    $data['format_source'] = 'planeupdatefaa';
975
-    		    $data['id_source'] = $id_source;
976
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
977
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
978
-		    $SI->add($data);
979
-		    unset($data);
972
+			}
973
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
974
+				$data['format_source'] = 'planeupdatefaa';
975
+				$data['id_source'] = $id_source;
976
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
977
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
978
+			$SI->add($data);
979
+			unset($data);
980 980
 		}
981
-	    }
982
-	    //$last_exec['planeupdatefaa'] = time();
983
-	    $last_exec[$id]['last'] = time();
981
+		}
982
+		//$last_exec['planeupdatefaa'] = time();
983
+		$last_exec[$id]['last'] = time();
984 984
 	} elseif ($value['format'] === 'opensky' && 
985
-	    (
985
+		(
986 986
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
987 987
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
988
-	    )
988
+		)
989 989
 	) {
990
-	    $buffer = $Common->getData($value['host']);
991
-	    $all_data = json_decode($buffer,true);
992
-	    if (isset($all_data['states'])) {
990
+		$buffer = $Common->getData($value['host']);
991
+		$all_data = json_decode($buffer,true);
992
+		if (isset($all_data['states'])) {
993 993
 		$reset = 0;
994 994
 		foreach ($all_data['states'] as $key => $line) {
995
-		    $data = array();
996
-		    $data['hex'] = $line[0]; // hex
997
-		    $data['ident'] = trim($line[1]); // ident
998
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
999
-		    $data['speed'] = round($line[9]*1.94384); // speed
1000
-		    $data['heading'] = round($line[10]); // heading
1001
-		    $data['latitude'] = $line[6]; // lat
1002
-		    $data['longitude'] = $line[5]; // long
1003
-		    $data['verticalrate'] = $line[11]; // verticale rate
1004
-		    //$data['squawk'] = $line[10]; // squawk
1005
-		    //$data['emergency'] = ''; // emergency
1006
-		    //$data['registration'] = $line[2];
1007
-		    //$data['aircraft_icao'] = $line[0];
1008
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1009
-		    $data['format_source'] = 'opensky';
1010
-		    $data['id_source'] = $id_source;
1011
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1012
-		    $SI->add($data);
1013
-		    unset($data);
995
+			$data = array();
996
+			$data['hex'] = $line[0]; // hex
997
+			$data['ident'] = trim($line[1]); // ident
998
+			$data['altitude'] = round($line[7]*3.28084); // altitude
999
+			$data['speed'] = round($line[9]*1.94384); // speed
1000
+			$data['heading'] = round($line[10]); // heading
1001
+			$data['latitude'] = $line[6]; // lat
1002
+			$data['longitude'] = $line[5]; // long
1003
+			$data['verticalrate'] = $line[11]; // verticale rate
1004
+			//$data['squawk'] = $line[10]; // squawk
1005
+			//$data['emergency'] = ''; // emergency
1006
+			//$data['registration'] = $line[2];
1007
+			//$data['aircraft_icao'] = $line[0];
1008
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1009
+			$data['format_source'] = 'opensky';
1010
+			$data['id_source'] = $id_source;
1011
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1012
+			$SI->add($data);
1013
+			unset($data);
1014 1014
 		}
1015
-	    }
1016
-	    //$last_exec['planeupdatefaa'] = time();
1017
-	    $last_exec[$id]['last'] = time();
1015
+		}
1016
+		//$last_exec['planeupdatefaa'] = time();
1017
+		$last_exec[$id]['last'] = time();
1018 1018
 	} elseif ($value['format'] === 'aircraftjson' && 
1019
-	    (
1019
+		(
1020 1020
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1021 1021
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1022
-	    )
1022
+		)
1023 1023
 	) {
1024
-	    $buffer = $Common->getData($value['host']);
1025
-	    $all_data = json_decode($buffer,true);
1026
-	    if (isset($all_data['aircraft'])) {
1024
+		$buffer = $Common->getData($value['host']);
1025
+		$all_data = json_decode($buffer,true);
1026
+		if (isset($all_data['aircraft'])) {
1027 1027
 		$reset = 0;
1028 1028
 		foreach ($all_data['aircraft'] as $key => $line) {
1029
-		    $data = array();
1030
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1031
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1032
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1033
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1034
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1035
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1036
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1037
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1038
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1039
-		    //$data['emergency'] = ''; // emergency
1040
-		    //$data['registration'] = $line[2];
1041
-		    //$data['aircraft_icao'] = $line[0];
1042
-		    $data['datetime'] = date('Y-m-d H:i:s');
1043
-		    $data['format_source'] = 'aircraftjson';
1044
-		    $data['id_source'] = $id_source;
1045
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1046
-		    $SI->add($data);
1047
-		    unset($data);
1029
+			$data = array();
1030
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1031
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1032
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1033
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1034
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1035
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1036
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1037
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1038
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1039
+			//$data['emergency'] = ''; // emergency
1040
+			//$data['registration'] = $line[2];
1041
+			//$data['aircraft_icao'] = $line[0];
1042
+			$data['datetime'] = date('Y-m-d H:i:s');
1043
+			$data['format_source'] = 'aircraftjson';
1044
+			$data['id_source'] = $id_source;
1045
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1046
+			$SI->add($data);
1047
+			unset($data);
1048 1048
 		}
1049
-	    }
1050
-	    //$last_exec['planeupdatefaa'] = time();
1051
-	    $last_exec[$id]['last'] = time();
1049
+		}
1050
+		//$last_exec['planeupdatefaa'] = time();
1051
+		$last_exec[$id]['last'] = time();
1052 1052
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1053 1053
 	} elseif ($value['format'] === 'fr24json' && 
1054
-	    (
1054
+		(
1055 1055
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1056 1056
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1057
-	    )
1057
+		)
1058 1058
 	) {
1059
-	    //$buffer = $Common->getData($hosts[$id]);
1060
-	    $buffer = $Common->getData($value['host']);
1061
-	    $all_data = json_decode($buffer,true);
1062
-	    if (!empty($all_data)) $reset = 0;
1063
-	    foreach ($all_data as $key => $line) {
1059
+		//$buffer = $Common->getData($hosts[$id]);
1060
+		$buffer = $Common->getData($value['host']);
1061
+		$all_data = json_decode($buffer,true);
1062
+		if (!empty($all_data)) $reset = 0;
1063
+		foreach ($all_data as $key => $line) {
1064 1064
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1065
-		    $data = array();
1066
-		    $data['hex'] = $line[0];
1067
-		    $data['ident'] = $line[16]; //$line[13]
1068
-	    	    $data['altitude'] = $line[4]; // altitude
1069
-	    	    $data['speed'] = $line[5]; // speed
1070
-	    	    $data['heading'] = $line[3]; // heading
1071
-	    	    $data['latitude'] = $line[1]; // lat
1072
-	    	    $data['longitude'] = $line[2]; // long
1073
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1074
-	    	    $data['squawk'] = $line[6]; // squawk
1075
-	    	    $data['aircraft_icao'] = $line[8];
1076
-	    	    $data['registration'] = $line[9];
1077
-		    $data['departure_airport_iata'] = $line[11];
1078
-		    $data['arrival_airport_iata'] = $line[12];
1079
-	    	    $data['emergency'] = ''; // emergency
1080
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1081
-	    	    $data['format_source'] = 'fr24json';
1082
-    		    $data['id_source'] = $id_source;
1083
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1084
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1085
-		    $SI->add($data);
1086
-		    unset($data);
1065
+			$data = array();
1066
+			$data['hex'] = $line[0];
1067
+			$data['ident'] = $line[16]; //$line[13]
1068
+				$data['altitude'] = $line[4]; // altitude
1069
+				$data['speed'] = $line[5]; // speed
1070
+				$data['heading'] = $line[3]; // heading
1071
+				$data['latitude'] = $line[1]; // lat
1072
+				$data['longitude'] = $line[2]; // long
1073
+				$data['verticalrate'] = $line[15]; // verticale rate
1074
+				$data['squawk'] = $line[6]; // squawk
1075
+				$data['aircraft_icao'] = $line[8];
1076
+				$data['registration'] = $line[9];
1077
+			$data['departure_airport_iata'] = $line[11];
1078
+			$data['arrival_airport_iata'] = $line[12];
1079
+				$data['emergency'] = ''; // emergency
1080
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1081
+				$data['format_source'] = 'fr24json';
1082
+				$data['id_source'] = $id_source;
1083
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1084
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1085
+			$SI->add($data);
1086
+			unset($data);
1087
+		}
1087 1088
 		}
1088
-	    }
1089
-	    //$last_exec['fr24json'] = time();
1090
-	    $last_exec[$id]['last'] = time();
1089
+		//$last_exec['fr24json'] = time();
1090
+		$last_exec[$id]['last'] = time();
1091 1091
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1092 1092
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1093
-	    (
1093
+		(
1094 1094
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1095 1095
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1096
-	    )
1096
+		)
1097 1097
 	) {
1098
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1099
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1100
-	    //echo $buffer;
1101
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1102
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1103
-	    $all_data = json_decode($buffer,true);
1104
-	    if (json_last_error() != JSON_ERROR_NONE) {
1098
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1099
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1100
+		//echo $buffer;
1101
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1102
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1103
+		$all_data = json_decode($buffer,true);
1104
+		if (json_last_error() != JSON_ERROR_NONE) {
1105 1105
 		die(json_last_error_msg());
1106
-	    }
1107
-	    if (isset($all_data['mrkrs'])) {
1106
+		}
1107
+		if (isset($all_data['mrkrs'])) {
1108 1108
 		$reset = 0;
1109 1109
 		foreach ($all_data['mrkrs'] as $key => $line) {
1110
-		    if (isset($line['inf'])) {
1110
+			if (isset($line['inf'])) {
1111 1111
 			$data = array();
1112 1112
 			$data['hex'] = $line['inf']['ia'];
1113 1113
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1114
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1115
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1116
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1117
-	    		$data['latitude'] = $line['pt'][0]; // lat
1118
-	    		$data['longitude'] = $line['pt'][1]; // long
1119
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1120
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1121
-	    		//$data['aircraft_icao'] = $line[8];
1122
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1114
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1115
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1116
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1117
+				$data['latitude'] = $line['pt'][0]; // lat
1118
+				$data['longitude'] = $line['pt'][1]; // long
1119
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1120
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1121
+				//$data['aircraft_icao'] = $line[8];
1122
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1123 1123
 			//$data['departure_airport_iata'] = $line[11];
1124 1124
 			//$data['arrival_airport_iata'] = $line[12];
1125
-	    		//$data['emergency'] = ''; // emergency
1125
+				//$data['emergency'] = ''; // emergency
1126 1126
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1127
-	    		$data['format_source'] = 'radarvirtueljson';
1128
-    			$data['id_source'] = $id_source;
1127
+				$data['format_source'] = 'radarvirtueljson';
1128
+				$data['id_source'] = $id_source;
1129 1129
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130 1130
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1131 1131
 			$SI->add($data);
1132 1132
 			unset($data);
1133
-		    }
1133
+			}
1134
+		}
1134 1135
 		}
1135
-	    }
1136
-	    //$last_exec['radarvirtueljson'] = time();
1137
-	    $last_exec[$id]['last'] = time();
1136
+		//$last_exec['radarvirtueljson'] = time();
1137
+		$last_exec[$id]['last'] = time();
1138 1138
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1139 1139
 	} elseif ($value['format'] === 'pirepsjson' && 
1140
-	    (
1140
+		(
1141 1141
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1142 1142
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1143
-	    )
1143
+		)
1144 1144
 	) {
1145
-	    //$buffer = $Common->getData($hosts[$id]);
1146
-	    $buffer = $Common->getData($value['host'].'?'.time());
1147
-	    $all_data = json_decode(utf8_encode($buffer),true);
1145
+		//$buffer = $Common->getData($hosts[$id]);
1146
+		$buffer = $Common->getData($value['host'].'?'.time());
1147
+		$all_data = json_decode(utf8_encode($buffer),true);
1148 1148
 	    
1149
-	    if (isset($all_data['pireps'])) {
1149
+		if (isset($all_data['pireps'])) {
1150 1150
 		$reset = 0;
1151
-	        foreach ($all_data['pireps'] as $line) {
1152
-		    $data = array();
1153
-		    $data['id'] = $line['id'];
1154
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1155
-		    $data['ident'] = $line['callsign']; // ident
1156
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1157
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1158
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1159
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1160
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1161
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1162
-		    $data['latitude'] = $line['lat']; // lat
1163
-		    $data['longitude'] = $line['lon']; // long
1164
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1165
-		    //$data['squawk'] = $line['squawk']; // squawk
1166
-		    //$data['emergency'] = ''; // emergency
1167
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1168
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1169
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1170
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1171
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1172
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1173
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1174
-		    else $data['info'] = '';
1175
-		    $data['format_source'] = 'pireps';
1176
-    		    $data['id_source'] = $id_source;
1177
-		    $data['datetime'] = date('Y-m-d H:i:s');
1178
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1179
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1180
-		    if ($line['icon'] === 'plane') {
1151
+			foreach ($all_data['pireps'] as $line) {
1152
+			$data = array();
1153
+			$data['id'] = $line['id'];
1154
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1155
+			$data['ident'] = $line['callsign']; // ident
1156
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1157
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1158
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1159
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1160
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1161
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1162
+			$data['latitude'] = $line['lat']; // lat
1163
+			$data['longitude'] = $line['lon']; // long
1164
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1165
+			//$data['squawk'] = $line['squawk']; // squawk
1166
+			//$data['emergency'] = ''; // emergency
1167
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1168
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1169
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1170
+			//$data['arrival_airport_time'] = $line['arrtime'];
1171
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1172
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1173
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1174
+			else $data['info'] = '';
1175
+			$data['format_source'] = 'pireps';
1176
+				$data['id_source'] = $id_source;
1177
+			$data['datetime'] = date('Y-m-d H:i:s');
1178
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1179
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1180
+			if ($line['icon'] === 'plane') {
1181 1181
 			$SI->add($data);
1182
-		    //    print_r($data);
1183
-    		    } elseif ($line['icon'] === 'ct') {
1182
+			//    print_r($data);
1183
+				} elseif ($line['icon'] === 'ct') {
1184 1184
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1185 1185
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1186 1186
 			$typec = substr($data['ident'],-3);
@@ -1195,209 +1195,209 @@  discard block
 block discarded – undo
1195 1195
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1196 1196
 			else $data['type'] = 'Observer';
1197 1197
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1198
-		    }
1199
-		    unset($data);
1198
+			}
1199
+			unset($data);
1200
+		}
1200 1201
 		}
1201
-	    }
1202
-	    //$last_exec['pirepsjson'] = time();
1203
-	    $last_exec[$id]['last'] = time();
1202
+		//$last_exec['pirepsjson'] = time();
1203
+		$last_exec[$id]['last'] = time();
1204 1204
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1205 1205
 	} elseif ($value['format'] === 'phpvmacars' && 
1206
-	    (
1206
+		(
1207 1207
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1208 1208
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1209
-	    )
1209
+		)
1210 1210
 	) {
1211
-	    //$buffer = $Common->getData($hosts[$id]);
1212
-	    if ($globalDebug) echo 'Get Data...'."\n";
1213
-	    $buffer = $Common->getData($value['host']);
1214
-	    $all_data = json_decode($buffer,true);
1215
-	    if ($buffer != '' && is_array($all_data)) {
1211
+		//$buffer = $Common->getData($hosts[$id]);
1212
+		if ($globalDebug) echo 'Get Data...'."\n";
1213
+		$buffer = $Common->getData($value['host']);
1214
+		$all_data = json_decode($buffer,true);
1215
+		if ($buffer != '' && is_array($all_data)) {
1216 1216
 		$reset = 0;
1217 1217
 		foreach ($all_data as $line) {
1218
-	    	    $data = array();
1219
-	    	    //$data['id'] = $line['id']; // id not usable
1220
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1221
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1222
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1223
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1224
-	    	    $data['ident'] = $line['flightnum']; // ident
1225
-	    	    $data['altitude'] = $line['alt']; // altitude
1226
-	    	    $data['speed'] = $line['gs']; // speed
1227
-	    	    $data['heading'] = $line['heading']; // heading
1228
-	    	    $data['latitude'] = $line['lat']; // lat
1229
-	    	    $data['longitude'] = $line['lng']; // long
1230
-	    	    $data['verticalrate'] = ''; // verticale rate
1231
-	    	    $data['squawk'] = ''; // squawk
1232
-	    	    $data['emergency'] = ''; // emergency
1233
-	    	    //$data['datetime'] = $line['lastupdate'];
1234
-	    	    //$data['last_update'] = $line['lastupdate'];
1235
-	    	    if (isset($value['timezone'])) {
1236
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1237
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1238
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1239
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1240
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1241
-	    	    $data['departure_airport_time'] = $line['deptime'];
1242
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1243
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1244
-    		    if (isset($line['registration'])) {
1245
-    			$data['registration'] = $line['registration'];
1246
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1247
-    		    } else $data['registration'] = $line['aircraft'];
1248
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1250
-		    if (isset($line['aircraftname'])) {
1218
+				$data = array();
1219
+				//$data['id'] = $line['id']; // id not usable
1220
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1221
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1222
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1223
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1224
+				$data['ident'] = $line['flightnum']; // ident
1225
+				$data['altitude'] = $line['alt']; // altitude
1226
+				$data['speed'] = $line['gs']; // speed
1227
+				$data['heading'] = $line['heading']; // heading
1228
+				$data['latitude'] = $line['lat']; // lat
1229
+				$data['longitude'] = $line['lng']; // long
1230
+				$data['verticalrate'] = ''; // verticale rate
1231
+				$data['squawk'] = ''; // squawk
1232
+				$data['emergency'] = ''; // emergency
1233
+				//$data['datetime'] = $line['lastupdate'];
1234
+				//$data['last_update'] = $line['lastupdate'];
1235
+				if (isset($value['timezone'])) {
1236
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1237
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1238
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1239
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1240
+				$data['departure_airport_icao'] = $line['depicao'];
1241
+				$data['departure_airport_time'] = $line['deptime'];
1242
+				$data['arrival_airport_icao'] = $line['arricao'];
1243
+				$data['arrival_airport_time'] = $line['arrtime'];
1244
+				if (isset($line['registration'])) {
1245
+				$data['registration'] = $line['registration'];
1246
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1247
+				} else $data['registration'] = $line['aircraft'];
1248
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1249
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1250
+			if (isset($line['aircraftname'])) {
1251 1251
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1252 1252
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1253
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1254
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1255
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1256
-	    		else {
1257
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1258
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1259
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1260
-	    		}
1261
-	    	    }
1262
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1263
-    		    $data['id_source'] = $id_source;
1264
-	    	    $data['format_source'] = 'phpvmacars';
1265
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1266
-		    $SI->add($data);
1267
-		    unset($data);
1253
+				$aircraft_data = explode('-',$line['aircraftname']);
1254
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1255
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1256
+				else {
1257
+					$aircraft_data = explode(' ',$line['aircraftname']);
1258
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1259
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1260
+				}
1261
+				}
1262
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1263
+				$data['id_source'] = $id_source;
1264
+				$data['format_source'] = 'phpvmacars';
1265
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1266
+			$SI->add($data);
1267
+			unset($data);
1268 1268
 		}
1269 1269
 		if ($globalDebug) echo 'No more data...'."\n";
1270 1270
 		unset($buffer);
1271 1271
 		unset($all_data);
1272
-	    }
1273
-	    //$last_exec['phpvmacars'] = time();
1274
-	    $last_exec[$id]['last'] = time();
1272
+		}
1273
+		//$last_exec['phpvmacars'] = time();
1274
+		$last_exec[$id]['last'] = time();
1275 1275
 	} elseif ($value['format'] === 'vaos' && 
1276
-	    (
1276
+		(
1277 1277
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1278 1278
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1279
-	    )
1279
+		)
1280 1280
 	) {
1281
-	    //$buffer = $Common->getData($hosts[$id]);
1282
-	    if ($globalDebug) echo 'Get Data...'."\n";
1283
-	    $buffer = $Common->getData($value['host']);
1284
-	    $all_data = json_decode($buffer,true);
1285
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1281
+		//$buffer = $Common->getData($hosts[$id]);
1282
+		if ($globalDebug) echo 'Get Data...'."\n";
1283
+		$buffer = $Common->getData($value['host']);
1284
+		$all_data = json_decode($buffer,true);
1285
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1286 1286
 		$reset = 0;
1287 1287
 		foreach ($all_data['ACARSData'] as $line) {
1288
-		    //print_r($line);
1289
-	    	    $data = array();
1290
-	    	    //$data['id'] = $line['id']; // id not usable
1291
-	    	    $data['id'] = $line['id'];
1292
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1293
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1294
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1295
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1296
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1297
-	    	    $data['altitude'] = $line['altitude']; // altitude
1298
-	    	    $data['speed'] = $line['groundspeed']; // speed
1299
-	    	    $data['heading'] = $line['heading']; // heading
1300
-	    	    $data['latitude'] = $line['lat']; // lat
1301
-	    	    $data['longitude'] = $line['lon']; // long
1302
-	    	    //$data['verticalrate'] = ''; // verticale rate
1303
-	    	    //$data['squawk'] = ''; // squawk
1304
-	    	    //$data['emergency'] = ''; // emergency
1305
-	    	    if (isset($value['timezone'])) {
1306
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1307
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1308
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1309
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1288
+			//print_r($line);
1289
+				$data = array();
1290
+				//$data['id'] = $line['id']; // id not usable
1291
+				$data['id'] = $line['id'];
1292
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1293
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1294
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1295
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1296
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1297
+				$data['altitude'] = $line['altitude']; // altitude
1298
+				$data['speed'] = $line['groundspeed']; // speed
1299
+				$data['heading'] = $line['heading']; // heading
1300
+				$data['latitude'] = $line['lat']; // lat
1301
+				$data['longitude'] = $line['lon']; // long
1302
+				//$data['verticalrate'] = ''; // verticale rate
1303
+				//$data['squawk'] = ''; // squawk
1304
+				//$data['emergency'] = ''; // emergency
1305
+				if (isset($value['timezone'])) {
1306
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1307
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1308
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1309
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1310 1310
 	    	    
1311
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1312
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1313
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1314
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1315
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1311
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1312
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1313
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1314
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1315
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1316 1316
 
1317
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1318
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1319
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1317
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1318
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1319
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1320 1320
 
1321
-    		    $data['id_source'] = $id_source;
1322
-	    	    $data['format_source'] = 'vaos';
1323
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1324
-		    $SI->add($data);
1325
-		    unset($data);
1321
+				$data['id_source'] = $id_source;
1322
+				$data['format_source'] = 'vaos';
1323
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1324
+			$SI->add($data);
1325
+			unset($data);
1326 1326
 		}
1327 1327
 		if ($globalDebug) echo 'No more data...'."\n";
1328 1328
 		unset($buffer);
1329 1329
 		unset($all_data);
1330
-	    }
1331
-	    //$last_exec['phpvmacars'] = time();
1332
-	    $last_exec[$id]['last'] = time();
1330
+		}
1331
+		//$last_exec['phpvmacars'] = time();
1332
+		$last_exec[$id]['last'] = time();
1333 1333
 	} elseif ($value['format'] === 'vam' && 
1334
-	    (
1334
+		(
1335 1335
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1336 1336
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1337
-	    )
1337
+		)
1338 1338
 	) {
1339
-	    //$buffer = $Common->getData($hosts[$id]);
1340
-	    if ($globalDebug) echo 'Get Data...'."\n";
1341
-	    $buffer = $Common->getData($value['host']);
1342
-	    $all_data = json_decode($buffer,true);
1343
-	    if ($buffer != '' && is_array($all_data)) {
1339
+		//$buffer = $Common->getData($hosts[$id]);
1340
+		if ($globalDebug) echo 'Get Data...'."\n";
1341
+		$buffer = $Common->getData($value['host']);
1342
+		$all_data = json_decode($buffer,true);
1343
+		if ($buffer != '' && is_array($all_data)) {
1344 1344
 		$reset = 0;
1345 1345
 		foreach ($all_data as $line) {
1346
-	    	    $data = array();
1347
-	    	    //$data['id'] = $line['id']; // id not usable
1348
-	    	    $data['id'] = trim($line['flight_id']);
1349
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1350
-	    	    $data['pilot_name'] = $line['pilot_name'];
1351
-	    	    $data['pilot_id'] = $line['pilot_id'];
1352
-	    	    $data['ident'] = trim($line['callsign']); // ident
1353
-	    	    $data['altitude'] = $line['altitude']; // altitude
1354
-	    	    $data['speed'] = $line['gs']; // speed
1355
-	    	    $data['heading'] = $line['heading']; // heading
1356
-	    	    $data['latitude'] = $line['latitude']; // lat
1357
-	    	    $data['longitude'] = $line['longitude']; // long
1358
-	    	    $data['verticalrate'] = ''; // verticale rate
1359
-	    	    $data['squawk'] = ''; // squawk
1360
-	    	    $data['emergency'] = ''; // emergency
1361
-	    	    //$data['datetime'] = $line['lastupdate'];
1362
-	    	    $data['last_update'] = $line['last_update'];
1363
-		    $data['datetime'] = date('Y-m-d H:i:s');
1364
-	    	    $data['departure_airport_icao'] = $line['departure'];
1365
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1366
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1367
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1368
-    		    //$data['registration'] = $line['aircraft'];
1369
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1370
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1371
-    		    $data['id_source'] = $id_source;
1372
-	    	    $data['format_source'] = 'vam';
1373
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1374
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1375
-		    $SI->add($data);
1376
-		    unset($data);
1346
+				$data = array();
1347
+				//$data['id'] = $line['id']; // id not usable
1348
+				$data['id'] = trim($line['flight_id']);
1349
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1350
+				$data['pilot_name'] = $line['pilot_name'];
1351
+				$data['pilot_id'] = $line['pilot_id'];
1352
+				$data['ident'] = trim($line['callsign']); // ident
1353
+				$data['altitude'] = $line['altitude']; // altitude
1354
+				$data['speed'] = $line['gs']; // speed
1355
+				$data['heading'] = $line['heading']; // heading
1356
+				$data['latitude'] = $line['latitude']; // lat
1357
+				$data['longitude'] = $line['longitude']; // long
1358
+				$data['verticalrate'] = ''; // verticale rate
1359
+				$data['squawk'] = ''; // squawk
1360
+				$data['emergency'] = ''; // emergency
1361
+				//$data['datetime'] = $line['lastupdate'];
1362
+				$data['last_update'] = $line['last_update'];
1363
+			$data['datetime'] = date('Y-m-d H:i:s');
1364
+				$data['departure_airport_icao'] = $line['departure'];
1365
+				//$data['departure_airport_time'] = $line['departure_time'];
1366
+				$data['arrival_airport_icao'] = $line['arrival'];
1367
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1368
+				//$data['registration'] = $line['aircraft'];
1369
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1370
+				$data['aircraft_icao'] = $line['plane_type'];
1371
+				$data['id_source'] = $id_source;
1372
+				$data['format_source'] = 'vam';
1373
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1374
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1375
+			$SI->add($data);
1376
+			unset($data);
1377 1377
 		}
1378 1378
 		if ($globalDebug) echo 'No more data...'."\n";
1379 1379
 		unset($buffer);
1380 1380
 		unset($all_data);
1381
-	    }
1382
-	    //$last_exec['phpvmacars'] = time();
1383
-	    $last_exec[$id]['last'] = time();
1381
+		}
1382
+		//$last_exec['phpvmacars'] = time();
1383
+		$last_exec[$id]['last'] = time();
1384 1384
 	} elseif ($value['format'] === 'blitzortung' && 
1385
-	    (
1385
+		(
1386 1386
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1387 1387
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1388
-	    )
1388
+		)
1389 1389
 	) {
1390
-	    //$buffer = $Common->getData($hosts[$id]);
1391
-	    if ($globalDebug) echo 'Get Data...'."\n";
1392
-	    $buffer = $Common->getData($value['host']);
1393
-	    $all_data = json_decode($buffer,true);
1394
-	    if ($buffer != '') {
1390
+		//$buffer = $Common->getData($hosts[$id]);
1391
+		if ($globalDebug) echo 'Get Data...'."\n";
1392
+		$buffer = $Common->getData($value['host']);
1393
+		$all_data = json_decode($buffer,true);
1394
+		if ($buffer != '') {
1395 1395
 		$Source->deleteLocationBySource('blitzortung');
1396 1396
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1397 1397
 		$buffer = explode('\n',$buffer);
1398 1398
 		foreach ($buffer as $buffer_line) {
1399
-		    $line = json_decode($buffer_line,true);
1400
-		    if (isset($line['time'])) {
1399
+			$line = json_decode($buffer_line,true);
1400
+			if (isset($line['time'])) {
1401 1401
 			$data = array();
1402 1402
 			$data['altitude'] = $line['alt']; // altitude
1403 1403
 			$data['latitude'] = $line['lat']; // lat
@@ -1409,94 +1409,94 @@  discard block
 block discarded – undo
1409 1409
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1410 1410
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1411 1411
 			unset($data);
1412
-		    }
1412
+			}
1413 1413
 		}
1414 1414
 		if ($globalDebug) echo 'No more data...'."\n";
1415 1415
 		unset($buffer);
1416
-	    }
1417
-	    $last_exec[$id]['last'] = time();
1416
+		}
1417
+		$last_exec[$id]['last'] = time();
1418 1418
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1419 1419
 	} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1420
-	    //$last_exec[$id]['last'] = time();
1421
-	    //$read = array( $sockets[$id] );
1422
-	    $read = $sockets;
1423
-	    $write = NULL;
1424
-	    $e = NULL;
1425
-	    $n = socket_select($read, $write, $e, $timeout);
1426
-	    if ($e != NULL) var_dump($e);
1427
-	    if ($n > 0) {
1420
+		//$last_exec[$id]['last'] = time();
1421
+		//$read = array( $sockets[$id] );
1422
+		$read = $sockets;
1423
+		$write = NULL;
1424
+		$e = NULL;
1425
+		$n = socket_select($read, $write, $e, $timeout);
1426
+		if ($e != NULL) var_dump($e);
1427
+		if ($n > 0) {
1428 1428
 		$reset = 0;
1429 1429
 		foreach ($read as $nb => $r) {
1430
-		    //$value = $formats[$nb];
1431
-		    $format = $globalSources[$nb]['format'];
1432
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1430
+			//$value = $formats[$nb];
1431
+			$format = $globalSources[$nb]['format'];
1432
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1433 1433
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1434
-		    } elseif ($format === 'vrstcp') {
1434
+			} elseif ($format === 'vrstcp') {
1435 1435
 			$buffer = @socket_read($r, 6000);
1436
-		    } else {
1436
+			} else {
1437 1437
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1438
-		    }
1439
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1440
-		    //echo $buffer."\n";
1441
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1442
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1443
-		    $error = false;
1444
-		    //$SI::del();
1445
-		    if ($buffer !== FALSE) {
1438
+			}
1439
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1440
+			//echo $buffer."\n";
1441
+			// lets play nice and handle signals such as ctrl-c/kill properly
1442
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1443
+			$error = false;
1444
+			//$SI::del();
1445
+			if ($buffer !== FALSE) {
1446 1446
 			if ($format === 'vrstcp') {
1447
-			    $buffer = explode('},{',$buffer);
1447
+				$buffer = explode('},{',$buffer);
1448 1448
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1449
-		    }
1450
-		    // SBS format is CSV format
1451
-		    if ($buffer !== FALSE && $buffer !== '') {
1449
+			}
1450
+			// SBS format is CSV format
1451
+			if ($buffer !== FALSE && $buffer !== '') {
1452 1452
 			$tt[$format] = 0;
1453 1453
 			if ($format === 'acarssbs3') {
1454
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1455
-			    $ACARS->add(trim($buffer));
1456
-			    $ACARS->deleteLiveAcarsData();
1454
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1455
+				$ACARS->add(trim($buffer));
1456
+				$ACARS->deleteLiveAcarsData();
1457 1457
 			} elseif ($format === 'raw') {
1458
-			    // AVR format
1459
-			    $data = $SBS->parse($buffer);
1460
-			    if (is_array($data)) {
1458
+				// AVR format
1459
+				$data = $SBS->parse($buffer);
1460
+				if (is_array($data)) {
1461 1461
 				$data['datetime'] = date('Y-m-d H:i:s');
1462 1462
 				$data['format_source'] = 'raw';
1463 1463
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1464 1464
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1465 1465
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1466 1466
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1467
-			    }
1467
+				}
1468 1468
 			} elseif ($format === 'ais') {
1469
-			    $ais_data = $AIS->parse_line(trim($buffer));
1470
-			    $data = array();
1471
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1472
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1473
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1474
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1475
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1476
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1477
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1478
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1479
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1480
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1481
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1482
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1483
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1484
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1485
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1486
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1469
+				$ais_data = $AIS->parse_line(trim($buffer));
1470
+				$data = array();
1471
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1472
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1473
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1474
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1475
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1476
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1477
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1478
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1479
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1480
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1481
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1482
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1483
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1484
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1485
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1486
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1487 1487
 
1488
-			    if (isset($ais_data['timestamp'])) {
1488
+				if (isset($ais_data['timestamp'])) {
1489 1489
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1490
-			    } else {
1490
+				} else {
1491 1491
 				$data['datetime'] = date('Y-m-d H:i:s');
1492
-			    }
1493
-			    $data['format_source'] = 'aisnmea';
1494
-    			    $data['id_source'] = $id_source;
1495
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1496
-			    unset($data);
1497
-                        } elseif ($format === 'flightgearsp') {
1498
-                    	    //echo $buffer."\n";
1499
-                    	    if (strlen($buffer) > 5) {
1492
+				}
1493
+				$data['format_source'] = 'aisnmea';
1494
+					$data['id_source'] = $id_source;
1495
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1496
+				unset($data);
1497
+						} elseif ($format === 'flightgearsp') {
1498
+							//echo $buffer."\n";
1499
+							if (strlen($buffer) > 5) {
1500 1500
 				$line = explode(',',$buffer);
1501 1501
 				$data = array();
1502 1502
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1513,38 +1513,38 @@  discard block
 block discarded – undo
1513 1513
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1514 1514
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1515 1515
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1516
-			    }
1517
-                        } elseif ($format === 'acars') {
1518
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1519
-			    $ACARS->add(trim($buffer));
1520
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1521
-			    $ACARS->deleteLiveAcarsData();
1516
+				}
1517
+						} elseif ($format === 'acars') {
1518
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1519
+				$ACARS->add(trim($buffer));
1520
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1521
+				$ACARS->deleteLiveAcarsData();
1522 1522
 			} elseif ($format === 'flightgearmp') {
1523
-			    if (substr($buffer,0,1) != '#') {
1523
+				if (substr($buffer,0,1) != '#') {
1524 1524
 				$data = array();
1525 1525
 				//echo $buffer."\n";
1526 1526
 				$line = explode(' ',$buffer);
1527 1527
 				if (count($line) === 11) {
1528
-				    $userserver = explode('@',$line[0]);
1529
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1530
-				    $data['ident'] = $userserver[0];
1531
-				    $data['registration'] = $userserver[0];
1532
-				    $data['latitude'] = $line[4];
1533
-				    $data['longitude'] = $line[5];
1534
-				    $data['altitude'] = $line[6];
1535
-				    $data['datetime'] = date('Y-m-d H:i:s');
1536
-				    $aircraft_type = $line[10];
1537
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1538
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1539
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1540
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1528
+					$userserver = explode('@',$line[0]);
1529
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1530
+					$data['ident'] = $userserver[0];
1531
+					$data['registration'] = $userserver[0];
1532
+					$data['latitude'] = $line[4];
1533
+					$data['longitude'] = $line[5];
1534
+					$data['altitude'] = $line[6];
1535
+					$data['datetime'] = date('Y-m-d H:i:s');
1536
+					$aircraft_type = $line[10];
1537
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1538
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1539
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1540
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1541
+				}
1541 1542
 				}
1542
-			    }
1543 1543
 			} elseif ($format === 'beast') {
1544
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1545
-			    die;
1544
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1545
+				die;
1546 1546
 			} elseif ($format === 'vrstcp') {
1547
-			    foreach($buffer as $all_data) {
1547
+				foreach($buffer as $all_data) {
1548 1548
 				$line = json_decode('{'.$all_data.'}',true);
1549 1549
 				$data = array();
1550 1550
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1564,153 +1564,153 @@  discard block
 block discarded – undo
1564 1564
 				*/
1565 1565
 				$data['datetime'] = date('Y-m-d H:i:s');
1566 1566
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1567
-		    		$data['format_source'] = 'vrstcp';
1567
+					$data['format_source'] = 'vrstcp';
1568 1568
 				$data['id_source'] = $id_source;
1569 1569
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1570 1570
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1571 1571
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1572 1572
 				unset($data);
1573
-			    }
1573
+				}
1574 1574
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1575
-			    $line = explode("\t", $buffer);
1576
-			    for($k = 0; $k < count($line); $k=$k+2) {
1575
+				$line = explode("\t", $buffer);
1576
+				for($k = 0; $k < count($line); $k=$k+2) {
1577 1577
 				$key = $line[$k];
1578
-			        $lined[$key] = $line[$k+1];
1579
-			    }
1580
-    			    if (count($lined) > 3) {
1581
-    				$data['hex'] = $lined['hexid'];
1582
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1583
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1584
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1585
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1586
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1587
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1588
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1589
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1590
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1591
-    				$data['id_source'] = $id_source;
1592
-    				$data['format_source'] = 'tsv';
1593
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1594
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1578
+					$lined[$key] = $line[$k+1];
1579
+				}
1580
+					if (count($lined) > 3) {
1581
+					$data['hex'] = $lined['hexid'];
1582
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1583
+					$data['datetime'] = date('Y-m-d H:i:s');;
1584
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1585
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1586
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1587
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1588
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1589
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1590
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1591
+					$data['id_source'] = $id_source;
1592
+					$data['format_source'] = 'tsv';
1593
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1594
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1595 1595
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1596
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1597
-    				unset($lined);
1598
-    				unset($data);
1599
-    			    } else $error = true;
1596
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1597
+					unset($lined);
1598
+					unset($data);
1599
+					} else $error = true;
1600 1600
 			} elseif ($format === 'aprs' && $use_aprs) {
1601
-			    if ($aprs_connect === 0) {
1601
+				if ($aprs_connect === 0) {
1602 1602
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1603 1603
 				$aprs_connect = 1;
1604
-			    }
1604
+				}
1605 1605
 			    
1606
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1606
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1607 1607
 				$aprs_last_tx = time();
1608 1608
 				$data_aprs = "# Keep alive";
1609 1609
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1610
-			    }
1610
+				}
1611 1611
 			    
1612
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1613
-			    //echo 'APRS data : '.$buffer."\n";
1614
-			    $buffer = str_replace('APRS <- ','',$buffer);
1615
-			    $buffer = str_replace('APRS -> ','',$buffer);
1616
-			    //echo $buffer."\n";
1617
-			    date_default_timezone_set('UTC');
1618
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1612
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1613
+				//echo 'APRS data : '.$buffer."\n";
1614
+				$buffer = str_replace('APRS <- ','',$buffer);
1615
+				$buffer = str_replace('APRS -> ','',$buffer);
1616
+				//echo $buffer."\n";
1617
+				date_default_timezone_set('UTC');
1618
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1619 1619
 				$line = $APRS->parse($buffer);
1620 1620
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1621 1621
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1622
-				    $aprs_last_tx = time();
1623
-				    $data = array();
1624
-				    //print_r($line);
1625
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1626
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1627
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1628
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1629
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1630
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1631
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1632
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1633
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1634
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1635
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1636
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1637
-				    $data['latitude'] = $line['latitude'];
1638
-				    $data['longitude'] = $line['longitude'];
1639
-				    //$data['verticalrate'] = $line[16];
1640
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1641
-				    //else $data['speed'] = 0;
1642
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1643
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1644
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1645
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1622
+					$aprs_last_tx = time();
1623
+					$data = array();
1624
+					//print_r($line);
1625
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1626
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1627
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1628
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1629
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1630
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1631
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1632
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1633
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1634
+					else $data['datetime'] = date('Y-m-d H:i:s');
1635
+					//$data['datetime'] = date('Y-m-d H:i:s');
1636
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1637
+					$data['latitude'] = $line['latitude'];
1638
+					$data['longitude'] = $line['longitude'];
1639
+					//$data['verticalrate'] = $line[16];
1640
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1641
+					//else $data['speed'] = 0;
1642
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1643
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1644
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1645
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1646 1646
 				    
1647
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1648
-				    //else echo 'No heading...'."\n";
1649
-				    //else $data['heading'] = 0;
1650
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1651
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1652
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1653
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1654
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1655
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1656
-    				    $data['id_source'] = $id_source;
1657
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1658
-				    else $data['format_source'] = 'aprs';
1659
-				    $data['source_name'] = $line['source'];
1660
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1661
-				    else $data['source_type'] = 'flarm';
1662
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1663
-				    $currentdate = date('Y-m-d H:i:s');
1664
-				    $aprsdate = strtotime($data['datetime']);
1665
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1666
-				    // Accept data if time <= system time + 20s
1667
-				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1668
-				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1647
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1648
+					//else echo 'No heading...'."\n";
1649
+					//else $data['heading'] = 0;
1650
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1651
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1652
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1653
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1654
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1655
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1656
+						$data['id_source'] = $id_source;
1657
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1658
+					else $data['format_source'] = 'aprs';
1659
+					$data['source_name'] = $line['source'];
1660
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1661
+					else $data['source_type'] = 'flarm';
1662
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1663
+					$currentdate = date('Y-m-d H:i:s');
1664
+					$aprsdate = strtotime($data['datetime']);
1665
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1666
+					// Accept data if time <= system time + 20s
1667
+					//if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1668
+					if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1669 1669
 					$send = $SI->add($data);
1670
-				    } elseif ($data['source_type'] === 'ais') {
1670
+					} elseif ($data['source_type'] === 'ais') {
1671 1671
 					$data['type'] = '';
1672 1672
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1673
-				    } elseif (isset($line['stealth'])) {
1673
+					} elseif (isset($line['stealth'])) {
1674 1674
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1675 1675
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1676
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1677
-					    //$line['symbol'] === 'Balloon' ||
1678
-					    $line['symbol'] === 'Glider' || 
1679
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1680
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1681
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1682
-					    $send = $SI->add($data);
1683
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1684
-					    $line['symbol'] === 'Yacht (Sail)' || 
1685
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1686
-					    $send = $MI->add($data);
1687
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1688
-					    $line['symbol'] === 'Car' || 
1689
-					    $line['symbol'] === 'Ambulance' || 
1690
-					    $line['symbol'] === 'Van' || 
1691
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1692
-					    $line['symbol'] === 'Motorcycle' || 
1693
-					    $line['symbol'] === 'Tractor' || 
1694
-					    $line['symbol'] === 'Police' || 
1695
-					    $line['symbol'] === 'Bike' || 
1696
-					    $line['symbol'] === 'Jogger' || 
1697
-					    $line['symbol'] === 'Horse' || 
1698
-					    $line['symbol'] === 'Bus' || 
1699
-					    $line['symbol'] === 'Jeep' || 
1700
-					    $line['symbol'] === 'Recreational Vehicle' || 
1701
-					    $line['symbol'] === 'Yacht (Sail)' || 
1702
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1703
-					    $line['symbol'] === 'Firetruck' || 
1704
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1705
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1706
-					    $line['symbol'] === 'SUV' ||
1707
-					    $line['symbol'] === 'Snowmobile' ||
1708
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1709
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1676
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1677
+						//$line['symbol'] === 'Balloon' ||
1678
+						$line['symbol'] === 'Glider' || 
1679
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1680
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1681
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1682
+						$send = $SI->add($data);
1683
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1684
+						$line['symbol'] === 'Yacht (Sail)' || 
1685
+						$line['symbol'] === 'Ship (Power Boat)')) {
1686
+						$send = $MI->add($data);
1687
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1688
+						$line['symbol'] === 'Car' || 
1689
+						$line['symbol'] === 'Ambulance' || 
1690
+						$line['symbol'] === 'Van' || 
1691
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1692
+						$line['symbol'] === 'Motorcycle' || 
1693
+						$line['symbol'] === 'Tractor' || 
1694
+						$line['symbol'] === 'Police' || 
1695
+						$line['symbol'] === 'Bike' || 
1696
+						$line['symbol'] === 'Jogger' || 
1697
+						$line['symbol'] === 'Horse' || 
1698
+						$line['symbol'] === 'Bus' || 
1699
+						$line['symbol'] === 'Jeep' || 
1700
+						$line['symbol'] === 'Recreational Vehicle' || 
1701
+						$line['symbol'] === 'Yacht (Sail)' || 
1702
+						$line['symbol'] === 'Ship (Power Boat)' || 
1703
+						$line['symbol'] === 'Firetruck' || 
1704
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1705
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1706
+						$line['symbol'] === 'SUV' ||
1707
+						$line['symbol'] === 'Snowmobile' ||
1708
+						$line['symbol'] === 'Mobile Satellite Station')) {
1709
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1710 1710
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1711 1711
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1712 1712
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1713
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1713
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1714 1714
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1715 1715
 					$Source->deleteOldLocationByType('gs');
1716 1716
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1718,7 +1718,7 @@  discard block
 block discarded – undo
1718 1718
 					} else {
1719 1719
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1720 1720
 					}
1721
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1721
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1722 1722
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1723 1723
 					if ($globalDebug) echo '# Weather Station added'."\n";
1724 1724
 					$Source->deleteOldLocationByType('wx');
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
 					} else {
1729 1729
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1730 1730
 					}
1731
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1731
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1732 1732
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1733 1733
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1734 1734
 					$Source->deleteOldLocationByType('lightning');
@@ -1737,11 +1737,11 @@  discard block
 block discarded – undo
1737 1737
 					} else {
1738 1738
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1739 1739
 					}
1740
-				    } elseif ($globalDebug) {
1741
-				    	echo '/!\ Not added: '.$buffer."\n";
1742
-				    	print_r($line);
1743
-				    }
1744
-				    unset($data);
1740
+					} elseif ($globalDebug) {
1741
+						echo '/!\ Not added: '.$buffer."\n";
1742
+						print_r($line);
1743
+					}
1744
+					unset($data);
1745 1745
 				}
1746 1746
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1747 1747
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1760,12 +1760,12 @@  discard block
 block discarded – undo
1760 1760
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1761 1761
 					$globalSources[$nb]['last_weather_clean'] = time();
1762 1762
 				}
1763
-			    }
1763
+				}
1764 1764
 			} else {
1765
-			    $line = explode(',', $buffer);
1766
-    			    if (count($line) > 20) {
1767
-    			    	$data['hex'] = $line[4];
1768
-    				/*
1765
+				$line = explode(',', $buffer);
1766
+					if (count($line) > 20) {
1767
+						$data['hex'] = $line[4];
1768
+					/*
1769 1769
     				$data['datetime'] = $line[6].' '.$line[7];
1770 1770
     					date_default_timezone_set($globalTimezone);
1771 1771
     					$datetime = new DateTime($data['datetime']);
@@ -1773,30 +1773,30 @@  discard block
 block discarded – undo
1773 1773
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1774 1774
     					date_default_timezone_set('UTC');
1775 1775
     				*/
1776
-    				// Force datetime to current UTC datetime
1777
-    				date_default_timezone_set('UTC');
1778
-    				$data['datetime'] = date('Y-m-d H:i:s');
1779
-    				$data['ident'] = trim($line[10]);
1780
-    				$data['latitude'] = $line[14];
1781
-    				$data['longitude'] = $line[15];
1782
-    				$data['verticalrate'] = $line[16];
1783
-    				$data['emergency'] = $line[20];
1784
-    				$data['speed'] = $line[12];
1785
-    				$data['squawk'] = $line[17];
1786
-    				$data['altitude'] = $line[11];
1787
-    				$data['heading'] = $line[13];
1788
-    				$data['ground'] = $line[21];
1789
-    				$data['emergency'] = $line[19];
1790
-    				$data['format_source'] = 'sbs';
1776
+					// Force datetime to current UTC datetime
1777
+					date_default_timezone_set('UTC');
1778
+					$data['datetime'] = date('Y-m-d H:i:s');
1779
+					$data['ident'] = trim($line[10]);
1780
+					$data['latitude'] = $line[14];
1781
+					$data['longitude'] = $line[15];
1782
+					$data['verticalrate'] = $line[16];
1783
+					$data['emergency'] = $line[20];
1784
+					$data['speed'] = $line[12];
1785
+					$data['squawk'] = $line[17];
1786
+					$data['altitude'] = $line[11];
1787
+					$data['heading'] = $line[13];
1788
+					$data['ground'] = $line[21];
1789
+					$data['emergency'] = $line[19];
1790
+					$data['format_source'] = 'sbs';
1791 1791
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1792
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1792
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1793 1793
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1794
-    				$data['id_source'] = $id_source;
1795
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1796
-    				else $error = true;
1797
-    				unset($data);
1798
-    			    } else $error = true;
1799
-			    if ($error) {
1794
+					$data['id_source'] = $id_source;
1795
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1796
+					else $error = true;
1797
+					unset($data);
1798
+					} else $error = true;
1799
+				if ($error) {
1800 1800
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1801 1801
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1802 1802
 				} else {
@@ -1812,13 +1812,13 @@  discard block
 block discarded – undo
1812 1812
 					connect_all($sourceer);
1813 1813
 					$sourceer = array();
1814 1814
 				}
1815
-			    }
1815
+				}
1816 1816
 			}
1817 1817
 			// Sleep for xxx microseconds
1818 1818
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1819
-		    } else {
1819
+			} else {
1820 1820
 			if ($format === 'flightgearmp') {
1821
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1821
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1822 1822
 				//@socket_close($r);
1823 1823
 				sleep($globalMinFetch);
1824 1824
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1827,9 +1827,9 @@  discard block
 block discarded – undo
1827 1827
 				break;
1828 1828
 				
1829 1829
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1830
-			    if (isset($tt[$format])) $tt[$format]++;
1831
-			    else $tt[$format] = 0;
1832
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1830
+				if (isset($tt[$format])) $tt[$format]++;
1831
+				else $tt[$format] = 0;
1832
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1833 1833
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1834 1834
 				//@socket_close($r);
1835 1835
 				sleep(2);
@@ -1840,24 +1840,24 @@  discard block
 block discarded – undo
1840 1840
 				//connect_all($globalSources);
1841 1841
 				$tt[$format]=0;
1842 1842
 				break;
1843
-			    } 
1844
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1843
+				} 
1844
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1845
+			}
1845 1846
 			}
1846
-		    }
1847 1847
 		}
1848
-	    } else {
1848
+		} else {
1849 1849
 		$error = socket_strerror(socket_last_error());
1850 1850
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1851 1851
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1852 1852
 			if (isset($globalDebug)) echo "Restarting...\n";
1853 1853
 			// Restart the script if possible
1854 1854
 			if (is_array($sockets)) {
1855
-			    if ($globalDebug) echo "Shutdown all sockets...";
1855
+				if ($globalDebug) echo "Shutdown all sockets...";
1856 1856
 			    
1857
-			    foreach ($sockets as $sock) {
1857
+				foreach ($sockets as $sock) {
1858 1858
 				@socket_shutdown($sock,2);
1859 1859
 				@socket_close($sock);
1860
-			    }
1860
+				}
1861 1861
 			    
1862 1862
 			}
1863 1863
 			if ($globalDebug) echo "Waiting...";
@@ -1872,15 +1872,15 @@  discard block
 block discarded – undo
1872 1872
 			if ($globalDebug) echo "Restart all connections...";
1873 1873
 			connect_all($globalSources);
1874 1874
 		}
1875
-	    }
1875
+		}
1876 1876
 	}
1877 1877
 	if ($globalDaemon === false) {
1878
-	    if ($globalDebug) echo 'Check all...'."\n";
1879
-	    if (isset($SI)) $SI->checkAll();
1880
-	    if (isset($TI)) $TI->checkAll();
1881
-	    if (isset($MI)) $MI->checkAll();
1878
+		if ($globalDebug) echo 'Check all...'."\n";
1879
+		if (isset($SI)) $SI->checkAll();
1880
+		if (isset($TI)) $TI->checkAll();
1881
+		if (isset($MI)) $MI->checkAll();
1882
+	}
1882 1883
 	}
1883
-    }
1884 1884
 }
1885 1885
 
1886 1886
 ?>
Please login to merge, or discard this patch.
Braces   +1135 added lines, -383 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,27 +211,37 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftjson';
178 233
         	$globalSources[$id]['format'] = 'aircraftjson';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
237
+        	}
181 238
     	    } else if (preg_match('/opensky/i',$host)) {
182 239
         	//$formats[$id] = 'aircraftlistjson';
183 240
         	$globalSources[$id]['format'] = 'opensky';
184 241
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to opensky source (".$host.")...\n";
244
+        	}
186 245
     	    /*
187 246
     	    // Disabled for now, site change source format
188 247
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -199,7 +258,9 @@  discard block
 block discarded – undo
199 258
         	//$formats[$id] = 'planeupdatefaa';
200 259
         	$globalSources[$id]['format'] = 'planeupdatefaa';
201 260
         	//$last_exec['planeupdatefaa'] = 0;
202
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
261
+        	if ($globalDebug) {
262
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
263
+        	}
203 264
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
204 265
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
205 266
         	    exit(0);
@@ -208,37 +269,53 @@  discard block
 block discarded – undo
208 269
         	//$formats[$id] = 'phpvmacars';
209 270
         	$globalSources[$id]['format'] = 'phpvmacars';
210 271
         	//$last_exec['phpvmacars'] = 0;
211
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
272
+        	if ($globalDebug) {
273
+        		echo "Connect to phpvmacars source (".$host.")...\n";
274
+        	}
212 275
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'vaos';
215 278
         	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
279
+        	if ($globalDebug) {
280
+        		echo "Connect to vaos source (".$host.")...\n";
281
+        	}
217 282
             } else if (preg_match('/VAM-json.php$/i',$host)) {
218 283
         	//$formats[$id] = 'phpvmacars';
219 284
         	$globalSources[$id]['format'] = 'vam';
220
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
285
+        	if ($globalDebug) {
286
+        		echo "Connect to Vam source (".$host.")...\n";
287
+        	}
221 288
             } else if (preg_match('/whazzup/i',$host)) {
222 289
         	//$formats[$id] = 'whazzup';
223 290
         	$globalSources[$id]['format'] = 'whazzup';
224 291
         	//$last_exec['whazzup'] = 0;
225
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
292
+        	if ($globalDebug) {
293
+        		echo "Connect to whazzup source (".$host.")...\n";
294
+        	}
226 295
             } else if (preg_match('/blitzortung/i',$host)) {
227 296
         	$globalSources[$id]['format'] = 'blitzortung';
228
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
297
+        	if ($globalDebug) {
298
+        		echo "Connect to blitzortung source (".$host.")...\n";
299
+        	}
229 300
             } else if (preg_match('/airwhere/i',$host)) {
230 301
         	$globalSources[$id]['format'] = 'airwhere';
231
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
302
+        	if ($globalDebug) {
303
+        		echo "Connect to airwhere source (".$host.")...\n";
304
+        	}
232 305
             } else if (preg_match('/recentpireps/i',$host)) {
233 306
         	//$formats[$id] = 'pirepsjson';
234 307
         	$globalSources[$id]['format'] = 'pirepsjson';
235 308
         	//$last_exec['pirepsjson'] = 0;
236
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to pirepsjson source (".$host.")...\n";
311
+        	}
237 312
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
238 313
         	//$formats[$id] = 'fr24json';
239 314
         	$globalSources[$id]['format'] = 'fr24json';
240 315
         	//$last_exec['fr24json'] = 0;
241
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to fr24 source (".$host.")...\n";
318
+        	}
242 319
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
243 320
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
244 321
         	    exit(0);
@@ -247,7 +324,9 @@  discard block
 block discarded – undo
247 324
         	//$formats[$id] = 'fr24json';
248 325
         	$globalSources[$id]['format'] = 'myshiptracking';
249 326
         	//$last_exec['fr24json'] = 0;
250
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
327
+        	if ($globalDebug) {
328
+        		echo "Connect to myshiptracking source (".$host.")...\n";
329
+        	}
251 330
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
252 331
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
253 332
         	    exit(0);
@@ -256,16 +335,24 @@  discard block
 block discarded – undo
256 335
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
257 336
         	//$formats[$id] = 'tsv';
258 337
         	$globalSources[$id]['format'] = 'tsv';
259
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
338
+        	if ($globalDebug) {
339
+        		echo "Connect to tsv source (".$host.")...\n";
340
+        	}
260 341
             }
261 342
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
262 343
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
263 344
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
264 345
     		    if ($idf !== false) {
265 346
     			$httpfeeds[$id] = $idf;
266
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
267
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
268
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
347
+        		if ($globalDebug) {
348
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
349
+        		}
350
+    		    } elseif ($globalDebug) {
351
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
352
+    		    }
353
+    		} elseif ($globalDebug) {
354
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
355
+    		}
269 356
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
270 357
 	    $hostport = explode(':',$host);
271 358
 	    if (isset($hostport[1])) {
@@ -305,17 +392,25 @@  discard block
 block discarded – undo
305 392
         		//$formats[$id] = 'beast';
306 393
         		$globalSources[$id]['format'] = 'beast';
307 394
 		    //} else $formats[$id] = 'sbs';
308
-		    } else $globalSources[$id]['format'] = 'sbs';
395
+		    } else {
396
+		    	$globalSources[$id]['format'] = 'sbs';
397
+		    }
309 398
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
310 399
 		}
311
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
400
+		if ($globalDebug) {
401
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
402
+		}
312 403
             } else {
313
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
404
+		if ($globalDebug) {
405
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
406
+		}
314 407
     	    }
315 408
         }
316 409
     }
317 410
 }
318
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
411
+if (!isset($globalMinFetch)) {
412
+	$globalMinFetch = 15;
413
+}
319 414
 
320 415
 // Initialize all
321 416
 $status = array();
@@ -324,13 +419,19 @@  discard block
 block discarded – undo
324 419
 $formats = array();
325 420
 $last_exec = array();
326 421
 $time = time();
327
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
328
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
329
-else $timeout = 20;
422
+if (isset($globalSourcesTimeout)) {
423
+	$timeout = $globalSourcesTimeOut;
424
+} else if (isset($globalSBS1TimeOut)) {
425
+	$timeout = $globalSBS1TimeOut;
426
+} else {
427
+	$timeout = 20;
428
+}
330 429
 $errno = '';
331 430
 $errstr='';
332 431
 
333
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
432
+if (!isset($globalDaemon)) {
433
+	$globalDaemon = TRUE;
434
+}
334 435
 /* Initiate connections to all the hosts simultaneously */
335 436
 //connect_all($hosts);
336 437
 //connect_all($globalSources);
@@ -359,7 +460,9 @@  discard block
 block discarded – undo
359 460
     if (isset($source['format']) && $source['format'] == 'aprs') {
360 461
 	$aprs_connect = 0;
361 462
 	$use_aprs = true;
362
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
463
+	if (isset($source['port']) && $source['port'] == '10152') {
464
+		$aprs_full = true;
465
+	}
363 466
 	break;
364 467
     }
365 468
 }
@@ -370,25 +473,46 @@  discard block
 block discarded – undo
370 473
 	$aprs_connect = 0;
371 474
 	$aprs_keep = 120;
372 475
 	$aprs_last_tx = time();
373
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
374
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
375
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
376
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
377
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
378
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
379
-	if ($aprs_full) $aprs_filter = '';
380
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
381
-	else $aprs_pass = '-1';
476
+	if (isset($globalAPRSversion)) {
477
+		$aprs_version = $globalAPRSversion;
478
+	} else {
479
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
480
+	}
481
+	if (isset($globalAPRSssid)) {
482
+		$aprs_ssid = $globalAPRSssid;
483
+	} else {
484
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
485
+	}
486
+	if (isset($globalAPRSfilter)) {
487
+		$aprs_filter = $globalAPRSfilter;
488
+	} else {
489
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
490
+	}
491
+	if ($aprs_full) {
492
+		$aprs_filter = '';
493
+	}
494
+	if (isset($globalAPRSpass)) {
495
+		$aprs_pass = $globalAPRSpass;
496
+	} else {
497
+		$aprs_pass = '-1';
498
+	}
382 499
 
383
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
384
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
385
-}
500
+	if ($aprs_filter != '') {
501
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
502
+	} else {
503
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
504
+	}
505
+	}
386 506
 
387 507
 // connected - lets do some work
388 508
 //if ($globalDebug) echo "Connected!\n";
389 509
 sleep(1);
390
-if ($globalDebug) echo "SCAN MODE \n\n";
391
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
510
+if ($globalDebug) {
511
+	echo "SCAN MODE \n\n";
512
+}
513
+if (!isset($globalCronEnd)) {
514
+	$globalCronEnd = 60;
515
+}
392 516
 $endtime = time()+$globalCronEnd;
393 517
 $i = 1;
394 518
 $tt = array();
@@ -402,22 +526,32 @@  discard block
 block discarded – undo
402 526
 
403 527
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
404 528
 while ($i > 0) {
405
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
529
+    if (function_exists('pcntl_fork')) {
530
+    	pcntl_signal_dispatch();
531
+    }
406 532
 
407
-    if (!$globalDaemon) $i = $endtime-time();
533
+    if (!$globalDaemon) {
534
+    	$i = $endtime-time();
535
+    }
408 536
     // Delete old ATC
409 537
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
410
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
538
+	if ($globalDebug) {
539
+		echo 'Delete old ATC...'."\n";
540
+	}
411 541
         $ATC->deleteOldATC();
412 542
     }
413 543
     
414 544
     if (count($last_exec) == count($globalSources)) {
415 545
 	$max = $globalMinFetch;
416 546
 	foreach ($last_exec as $last) {
417
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
547
+	    if ((time() - $last['last']) < $max) {
548
+	    	$max = time() - $last['last'];
549
+	    }
418 550
 	}
419 551
 	if ($max < $globalMinFetch) {
420
-	    if ($globalDebug) echo 'Sleeping...'."\n";
552
+	    if ($globalDebug) {
553
+	    	echo 'Sleeping...'."\n";
554
+	    }
421 555
 	    sleep($globalMinFetch-$max+2);
422 556
 	}
423 557
     }
@@ -427,7 +561,9 @@  discard block
 block discarded – undo
427 561
     foreach ($globalSources as $id => $value) {
428 562
 	date_default_timezone_set('UTC');
429 563
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
430
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
564
+	if (!isset($last_exec[$id]['last'])) {
565
+		$last_exec[$id]['last'] = 0;
566
+	}
431 567
 	if ($value['format'] === 'deltadbtxt' && 
432 568
 	    (
433 569
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -436,7 +572,9 @@  discard block
 block discarded – undo
436 572
 	) {
437 573
 	    //$buffer = $Common->getData($hosts[$id]);
438 574
 	    $buffer = $Common->getData($value['host']);
439
-	    if ($buffer != '') $reset = 0;
575
+	    if ($buffer != '') {
576
+	    	$reset = 0;
577
+	    }
440 578
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
441 579
 	    $buffer = explode('\n',$buffer);
442 580
 	    foreach ($buffer as $line) {
@@ -445,20 +583,41 @@  discard block
 block discarded – undo
445 583
 	            $data = array();
446 584
 	            $data['hex'] = $line[1]; // hex
447 585
 	            $data['ident'] = $line[2]; // ident
448
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
449
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
450
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
451
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
452
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
586
+	            if (isset($line[3])) {
587
+	            	$data['altitude'] = $line[3];
588
+	            }
589
+	            // altitude
590
+	            if (isset($line[4])) {
591
+	            	$data['speed'] = $line[4];
592
+	            }
593
+	            // speed
594
+	            if (isset($line[5])) {
595
+	            	$data['heading'] = $line[5];
596
+	            }
597
+	            // heading
598
+	            if (isset($line[6])) {
599
+	            	$data['latitude'] = $line[6];
600
+	            }
601
+	            // lat
602
+	            if (isset($line[7])) {
603
+	            	$data['longitude'] = $line[7];
604
+	            }
605
+	            // long
453 606
 	            $data['verticalrate'] = ''; // vertical rate
454 607
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
455 608
 	            $data['emergency'] = ''; // emergency
456 609
 		    $data['datetime'] = date('Y-m-d H:i:s');
457 610
 		    $data['format_source'] = 'deltadbtxt';
458 611
     		    $data['id_source'] = $id_source;
459
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
460
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
461
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
612
+		    if (isset($value['name']) && $value['name'] != '') {
613
+		    	$data['source_name'] = $value['name'];
614
+		    }
615
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
616
+		    	$data['noarchive'] = true;
617
+		    }
618
+		    if (isset($value['sourcestats'])) {
619
+		    	$data['sourcestats'] = $value['sourcestats'];
620
+		    }
462 621
     		    $SI->add($data);
463 622
 		    unset($data);
464 623
     		}
@@ -473,7 +632,9 @@  discard block
 block discarded – undo
473 632
 	    date_default_timezone_set('CET');
474 633
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
475 634
 	    date_default_timezone_set('UTC');
476
-	    if ($buffer != '') $reset = 0;
635
+	    if ($buffer != '') {
636
+	    	$reset = 0;
637
+	    }
477 638
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
478 639
 	    $buffer = explode('\n',$buffer);
479 640
 	    foreach ($buffer as $line) {
@@ -482,18 +643,42 @@  discard block
 block discarded – undo
482 643
 		    $add = false;
483 644
 		    $ais_data = $AIS->parse_line(trim($line));
484 645
 		    $data = array();
485
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
486
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
487
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
488
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
489
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
490
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
491
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
492
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
493
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
494
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
495
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
496
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
646
+		    if (isset($ais_data['ident'])) {
647
+		    	$data['ident'] = $ais_data['ident'];
648
+		    }
649
+		    if (isset($ais_data['mmsi'])) {
650
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
651
+		    }
652
+		    if (isset($ais_data['speed'])) {
653
+		    	$data['speed'] = $ais_data['speed'];
654
+		    }
655
+		    if (isset($ais_data['heading'])) {
656
+		    	$data['heading'] = $ais_data['heading'];
657
+		    }
658
+		    if (isset($ais_data['latitude'])) {
659
+		    	$data['latitude'] = $ais_data['latitude'];
660
+		    }
661
+		    if (isset($ais_data['longitude'])) {
662
+		    	$data['longitude'] = $ais_data['longitude'];
663
+		    }
664
+		    if (isset($ais_data['status'])) {
665
+		    	$data['status'] = $ais_data['status'];
666
+		    }
667
+		    if (isset($ais_data['statusid'])) {
668
+		    	$data['status_id'] = $ais_data['statusid'];
669
+		    }
670
+		    if (isset($ais_data['type'])) {
671
+		    	$data['type'] = $ais_data['type'];
672
+		    }
673
+		    if (isset($ais_data['typeid'])) {
674
+		    	$data['type_id'] = $ais_data['typeid'];
675
+		    }
676
+		    if (isset($ais_data['imo'])) {
677
+		    	$data['imo'] = $ais_data['imo'];
678
+		    }
679
+		    if (isset($ais_data['callsign'])) {
680
+		    	$data['callsign'] = $ais_data['callsign'];
681
+		    }
497 682
 		    if (isset($ais_data['timestamp'])) {
498 683
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
499 684
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -507,8 +692,12 @@  discard block
 block discarded – undo
507 692
 		    $data['format_source'] = 'aisnmeatxt';
508 693
     		    $data['id_source'] = $id_source;
509 694
 		    //print_r($data);
510
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
511
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
695
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
696
+		    	$data['noarchive'] = true;
697
+		    }
698
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
699
+		    	$MI->add($data);
700
+		    }
512 701
 		    unset($data);
513 702
 		}
514 703
     	    }
@@ -531,20 +720,48 @@  discard block
 block discarded – undo
531 720
 			    if ($line != '') {
532 721
 				$ais_data = $AIS->parse_line(trim($line));
533 722
 				$data = array();
534
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
535
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
536
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
537
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
538
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
539
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
540
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
541
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
542
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
543
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
544
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
545
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
546
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
547
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
723
+				if (isset($ais_data['ident'])) {
724
+					$data['ident'] = $ais_data['ident'];
725
+				}
726
+				if (isset($ais_data['mmsi'])) {
727
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
728
+				}
729
+				if (isset($ais_data['speed'])) {
730
+					$data['speed'] = $ais_data['speed'];
731
+				}
732
+				if (isset($ais_data['heading'])) {
733
+					$data['heading'] = $ais_data['heading'];
734
+				}
735
+				if (isset($ais_data['latitude'])) {
736
+					$data['latitude'] = $ais_data['latitude'];
737
+				}
738
+				if (isset($ais_data['longitude'])) {
739
+					$data['longitude'] = $ais_data['longitude'];
740
+				}
741
+				if (isset($ais_data['status'])) {
742
+					$data['status'] = $ais_data['status'];
743
+				}
744
+				if (isset($ais_data['statusid'])) {
745
+					$data['status_id'] = $ais_data['statusid'];
746
+				}
747
+				if (isset($ais_data['type'])) {
748
+					$data['type'] = $ais_data['type'];
749
+				}
750
+				if (isset($ais_data['typeid'])) {
751
+					$data['type_id'] = $ais_data['typeid'];
752
+				}
753
+				if (isset($ais_data['imo'])) {
754
+					$data['imo'] = $ais_data['imo'];
755
+				}
756
+				if (isset($ais_data['callsign'])) {
757
+					$data['callsign'] = $ais_data['callsign'];
758
+				}
759
+				if (isset($ais_data['destination'])) {
760
+					$data['arrival_code'] = $ais_data['destination'];
761
+				}
762
+				if (isset($ais_data['eta_ts'])) {
763
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
764
+				}
548 765
 				if (isset($ais_data['timestamp'])) {
549 766
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
550 767
 				} else {
@@ -552,18 +769,27 @@  discard block
 block discarded – undo
552 769
 				}
553 770
 				$data['format_source'] = 'aisnmeahttp';
554 771
 				$data['id_source'] = $id_source;
555
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
556
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
772
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
773
+					$data['noarchive'] = true;
774
+				}
775
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
776
+					$MI->add($data);
777
+				}
557 778
 				unset($data);
558 779
 			    }
559 780
 			}
560 781
 		    }
561 782
 		} else {
562 783
 		    $format = $value['format'];
563
-		    if (isset($tt[$format])) $tt[$format]++;
564
-		    else $tt[$format] = 0;
784
+		    if (isset($tt[$format])) {
785
+		    	$tt[$format]++;
786
+		    } else {
787
+		    	$tt[$format] = 0;
788
+		    }
565 789
 		    if ($tt[$format] > 30) {
566
-			if ($globalDebug) echo 'Reconnect...'."\n";
790
+			if ($globalDebug) {
791
+				echo 'Reconnect...'."\n";
792
+			}
567 793
 			sleep(2);
568 794
 			//$sourceeen[] = $value;
569 795
 			//connect_all($sourceeen);
@@ -599,12 +825,18 @@  discard block
 block discarded – undo
599 825
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
600 826
 			    //$data['type_id'] = $line['TYPE'];
601 827
 			    $data['imo'] = $line['IMO'];
602
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
603
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
828
+			    if ($line['DEST'] != '') {
829
+			    	$data['arrival_code'] = $line['DEST'];
830
+			    }
831
+			    if ($line['ARV'] != '') {
832
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
833
+			    }
604 834
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
605 835
 			    $data['format_source'] = 'myshiptracking';
606 836
 			    $data['id_source'] = $id_source;
607
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
837
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
838
+			    	$data['noarchive'] = true;
839
+			    }
608 840
 			    $MI->add($data);
609 841
 			    unset($data);
610 842
 			}
@@ -629,7 +861,9 @@  discard block
 block discarded – undo
629 861
 			    $data['callsign'] = $line['callsign'];
630 862
 			    $data['mmsi'] = substr($line['mmsi'],-9);
631 863
 			    $data['speed'] = $line['sog'];
632
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
864
+			    if ($line['heading'] != '511') {
865
+			    	$data['heading'] = $line['heading'];
866
+			    }
633 867
 			    $data['latitude'] = $line['latitude'];
634 868
 			    $data['longitude'] = $line['longitude'];
635 869
 			    $data['type_id'] = $line['shiptype'];
@@ -637,7 +871,9 @@  discard block
 block discarded – undo
637 871
 			    $data['datetime'] = $line['time'];
638 872
 			    $data['format_source'] = 'boatbeaconapp';
639 873
 			    $data['id_source'] = $id_source;
640
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
874
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
875
+			    	$data['noarchive'] = true;
876
+			    }
641 877
 			    $MI->add($data);
642 878
 			    unset($data);
643 879
 			}
@@ -659,22 +895,44 @@  discard block
 block discarded – undo
659 895
 		    foreach ($all_data['features'] as $line) {
660 896
 			print_r($line);
661 897
 			$data = array();
662
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
663
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
664
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
665
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
666
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
667
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
898
+			if (isset($line['properties']['name'])) {
899
+				$data['ident'] = $line['properties']['name'];
900
+			}
901
+			if (isset($line['properties']['callsign'])) {
902
+				$data['callsign'] = $line['properties']['callsign'];
903
+			}
904
+			if (isset($line['properties']['mmsi'])) {
905
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
906
+			}
907
+			if (isset($line['properties']['imo'])) {
908
+				$data['imo'] = $line['properties']['imo'];
909
+			}
910
+			if (isset($line['properties']['speed'])) {
911
+				$data['speed'] = $line['properties']['speed'];
912
+			}
913
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
914
+				$data['heading'] = $line['properties']['heading'];
915
+			}
668 916
 			$data['latitude'] = $line['geometry']['coordinates'][1];
669 917
 			$data['longitude'] = $line['geometry']['coordinates'][0];
670
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
671
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
672
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
918
+			if (isset($line['properties']['vesselType'])) {
919
+				$data['type'] = $line['properties']['vesselType'];
920
+			}
921
+			if (isset($line['properties']['destination'])) {
922
+				$data['arrival_code'] = $line['properties']['destination'];
923
+			}
924
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
925
+				$data['arrival_date'] = $line['properties']['eta'];
926
+			}
673 927
 			$data['format_source'] = 'boatnerd';
674 928
 			$data['id_source'] = $id_source;
675 929
 			$data['datetime'] = date('Y-m-d H:i:s');
676
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
677
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
930
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
931
+				$data['noarchive'] = true;
932
+			}
933
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
934
+				$MI->add($data);
935
+			}
678 936
 			unset($data);
679 937
 		    }
680 938
 		}
@@ -691,7 +949,9 @@  discard block
 block discarded – undo
691 949
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
692 950
 	    echo 'done !'."\n";
693 951
 	    // FIXME: Need more work
694
-	    if ($buffer != '') $reset = 0;
952
+	    if ($buffer != '') {
953
+	    	$reset = 0;
954
+	    }
695 955
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
696 956
 	    $buffer = explode('\n',$buffer);
697 957
 	    foreach ($buffer as $line) {
@@ -717,7 +977,9 @@  discard block
 block discarded – undo
717 977
 		    //$data['etaTime'] = substr($line,135,5);
718 978
 		    $data['format_source'] = 'shipplotter';
719 979
     		    $data['id_source'] = $id_source;
720
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
980
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
981
+		    	$data['noarchive'] = true;
982
+		    }
721 983
 		    //print_r($data);
722 984
 		    echo 'Add...'."\n";
723 985
 		    $MI->add($data);
@@ -751,16 +1013,28 @@  discard block
 block discarded – undo
751 1013
     		    $line = explode(':', $line);
752 1014
     		    if (count($line) > 30 && $line[0] != 'callsign') {
753 1015
 			$data = array();
754
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
755
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1016
+			if (isset($line[37]) && $line[37] != '') {
1017
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1018
+			} else {
1019
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1020
+			}
756 1021
 			$data['pilot_id'] = $line[1];
757 1022
 			$data['pilot_name'] = $line[2];
758 1023
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
759 1024
 			$data['ident'] = $line[0]; // ident
760
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1025
+			if ($line[7] != '' && $line[7] != 0) {
1026
+				$data['altitude'] = $line[7];
1027
+			}
1028
+			// altitude
761 1029
 			$data['speed'] = $line[8]; // speed
762
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
763
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1030
+			if (isset($line[45])) {
1031
+				$data['heading'] = $line[45];
1032
+			}
1033
+			// heading
1034
+			elseif (isset($line[38])) {
1035
+				$data['heading'] = $line[38];
1036
+			}
1037
+			// heading
764 1038
 			$data['latitude'] = $line[5]; // lat
765 1039
 	        	$data['longitude'] = $line[6]; // long
766 1040
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -776,7 +1050,9 @@  discard block
 block discarded – undo
776 1050
 			$data['frequency'] = $line[4];
777 1051
 			$data['type'] = $line[18];
778 1052
 			$data['range'] = $line[19];
779
-			if (isset($line[35])) $data['info'] = $line[35];
1053
+			if (isset($line[35])) {
1054
+				$data['info'] = $line[35];
1055
+			}
780 1056
     			$data['id_source'] = $id_source;
781 1057
 	    		//$data['arrival_airport_time'] = ;
782 1058
 	    		if ($line[9] != '') {
@@ -790,27 +1066,47 @@  discard block
 block discarded – undo
790 1066
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
791 1067
 	    		*/
792 1068
 	    		$data['format_source'] = $value['format'];
793
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
794
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
795
-    			if ($line[3] === 'PILOT') $SI->add($data);
796
-			elseif ($line[3] === 'ATC') {
1069
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1070
+				$data['noarchive'] = true;
1071
+			}
1072
+			if (isset($value['name']) && $value['name'] != '') {
1073
+				$data['source_name'] = $value['name'];
1074
+			}
1075
+    			if ($line[3] === 'PILOT') {
1076
+    				$SI->add($data);
1077
+    			} elseif ($line[3] === 'ATC') {
797 1078
 				//print_r($data);
798 1079
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
799 1080
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
800 1081
 				$typec = substr($data['ident'],-3);
801
-				if ($typec === 'APP') $data['type'] = 'Approach';
802
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
803
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
804
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
805
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
806
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
807
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
808
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
809
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
810
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1082
+				if ($typec === 'APP') {
1083
+					$data['type'] = 'Approach';
1084
+				} elseif ($typec === 'TWR') {
1085
+					$data['type'] = 'Tower';
1086
+				} elseif ($typec === 'OBS') {
1087
+					$data['type'] = 'Observer';
1088
+				} elseif ($typec === 'GND') {
1089
+					$data['type'] = 'Ground';
1090
+				} elseif ($typec === 'DEL') {
1091
+					$data['type'] = 'Delivery';
1092
+				} elseif ($typec === 'DEP') {
1093
+					$data['type'] = 'Departure';
1094
+				} elseif ($typec === 'FSS') {
1095
+					$data['type'] = 'Flight Service Station';
1096
+				} elseif ($typec === 'CTR') {
1097
+					$data['type'] = 'Control Radar or Centre';
1098
+				} elseif ($data['type'] === '') {
1099
+					$data['type'] = 'Observer';
1100
+				}
1101
+				if (!isset($data['source_name'])) {
1102
+					$data['source_name'] = '';
1103
+				}
811 1104
 				if (isset($ATC)) {
812
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
813
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1105
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1106
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1107
+					} else {
1108
+						echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1109
+					}
814 1110
 				}
815 1111
 			}
816 1112
     			unset($data);
@@ -837,14 +1133,20 @@  discard block
 block discarded – undo
837 1133
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
838 1134
 			$data['latitude'] = (float)$line['pktLatitude'];
839 1135
 			$data['longitude'] = (float)$line['pktLongitude'];
840
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
841
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1136
+			if ((float)$line['pktTrack'] != 0) {
1137
+				$data['heading'] = (float)$line['pktTrack'];
1138
+			}
1139
+			if ((int)$line['pktSpeed'] != 0) {
1140
+				$data['speed'] = (int)$line['pktSpeed'];
1141
+			}
842 1142
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
843 1143
 			$data['altitude_relative'] = 'AMSL';
844 1144
 			$data['pilot_id'] = (int)$line['pktPilotID'];
845 1145
 			$data['aircraft_icao'] = 'PARAGLIDER';
846 1146
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
847
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1147
+			if (isset($pilot_data[4])) {
1148
+				$data['pilot_name'] = $pilot_data[4];
1149
+			}
848 1150
 			$data['format_source'] = $value['format'];
849 1151
 			$SI->add($data);
850 1152
 			unset($data);
@@ -892,25 +1194,59 @@  discard block
 block discarded – undo
892 1194
 		    foreach ($all_data['acList'] as $line) {
893 1195
 			$data = array();
894 1196
 			$data['hex'] = $line['Icao']; // hex
895
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
896
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
897
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
898
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
899
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
900
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1197
+			if (isset($line['Call'])) {
1198
+				$data['ident'] = $line['Call'];
1199
+			}
1200
+			// ident
1201
+			if (isset($line['Alt'])) {
1202
+				$data['altitude'] = $line['Alt'];
1203
+			}
1204
+			// altitude
1205
+			if (isset($line['Spd'])) {
1206
+				$data['speed'] = $line['Spd'];
1207
+			}
1208
+			// speed
1209
+			if (isset($line['Trak'])) {
1210
+				$data['heading'] = $line['Trak'];
1211
+			}
1212
+			// heading
1213
+			if (isset($line['Lat'])) {
1214
+				$data['latitude'] = $line['Lat'];
1215
+			}
1216
+			// lat
1217
+			if (isset($line['Long'])) {
1218
+				$data['longitude'] = $line['Long'];
1219
+			}
1220
+			// long
901 1221
 			//$data['verticalrate'] = $line['']; // verticale rate
902
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1222
+			if (isset($line['Sqk'])) {
1223
+				$data['squawk'] = $line['Sqk'];
1224
+			}
1225
+			// squawk
903 1226
 			$data['emergency'] = ''; // emergency
904
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
905
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
906
-			else $data['datetime'] = date('Y-m-d H:i:s');
1227
+			if (isset($line['Reg'])) {
1228
+				$data['registration'] = $line['Reg'];
1229
+			}
1230
+			if (isset($line['PosTime'])) {
1231
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1232
+			} else {
1233
+				$data['datetime'] = date('Y-m-d H:i:s');
1234
+			}
907 1235
 			//$data['datetime'] = date('Y-m-d H:i:s');
908
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1236
+			if (isset($line['Type'])) {
1237
+				$data['aircraft_icao'] = $line['Type'];
1238
+			}
909 1239
 			$data['format_source'] = 'aircraftlistjson';
910 1240
 			$data['id_source'] = $id_source;
911
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
912
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
913
-			if (isset($data['latitude'])) $SI->add($data);
1241
+			if (isset($value['name']) && $value['name'] != '') {
1242
+				$data['source_name'] = $value['name'];
1243
+			}
1244
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1245
+				$data['noarchive'] = true;
1246
+			}
1247
+			if (isset($data['latitude'])) {
1248
+				$SI->add($data);
1249
+			}
914 1250
 			unset($data);
915 1251
 		    }
916 1252
 		} elseif (is_array($all_data)) {
@@ -927,17 +1263,26 @@  discard block
 block discarded – undo
927 1263
 			$data['verticalrate'] = $line['vrt']; // verticale rate
928 1264
 			$data['squawk'] = $line['squawk']; // squawk
929 1265
 			$data['emergency'] = ''; // emergency
930
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
931
-			else $data['datetime'] = date('Y-m-d H:i:s');
1266
+			if (isset($line['PosTime'])) {
1267
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1268
+			} else {
1269
+				$data['datetime'] = date('Y-m-d H:i:s');
1270
+			}
932 1271
 			$data['format_source'] = 'aircraftlistjson';
933 1272
 			$data['id_source'] = $id_source;
934
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
935
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1273
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1274
+				$data['noarchive'] = true;
1275
+			}
1276
+			if (isset($value['name']) && $value['name'] != '') {
1277
+				$data['source_name'] = $value['name'];
1278
+			}
936 1279
 			$SI->add($data);
937 1280
 			unset($data);
938 1281
 		    }
939 1282
 		}
940
-	    } elseif ($globalDebug) echo 'No data'."\n";
1283
+	    } elseif ($globalDebug) {
1284
+	    	echo 'No data'."\n";
1285
+	    }
941 1286
     	    //$last_exec['aircraftlistjson'] = time();
942 1287
     	    $last_exec[$id]['last'] = time();
943 1288
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -973,8 +1318,12 @@  discard block
 block discarded – undo
973 1318
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
974 1319
 	    	    $data['format_source'] = 'planeupdatefaa';
975 1320
     		    $data['id_source'] = $id_source;
976
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
977
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1321
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1322
+		    	$data['noarchive'] = true;
1323
+		    }
1324
+		    if (isset($value['name']) && $value['name'] != '') {
1325
+		    	$data['source_name'] = $value['name'];
1326
+		    }
978 1327
 		    $SI->add($data);
979 1328
 		    unset($data);
980 1329
 		}
@@ -1008,7 +1357,9 @@  discard block
 block discarded – undo
1008 1357
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1009 1358
 		    $data['format_source'] = 'opensky';
1010 1359
 		    $data['id_source'] = $id_source;
1011
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1360
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1361
+		    	$data['noarchive'] = true;
1362
+		    }
1012 1363
 		    $SI->add($data);
1013 1364
 		    unset($data);
1014 1365
 		}
@@ -1027,22 +1378,51 @@  discard block
 block discarded – undo
1027 1378
 		$reset = 0;
1028 1379
 		foreach ($all_data['aircraft'] as $key => $line) {
1029 1380
 		    $data = array();
1030
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1031
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1032
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1033
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1034
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1035
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1036
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1037
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1038
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1381
+		    if (isset($line['hex'])) {
1382
+		    	$data['hex'] = $line['hex'];
1383
+		    }
1384
+		    // hex
1385
+		    if (isset($line['flight'])) {
1386
+		    	$data['ident'] = trim($line['flight']);
1387
+		    }
1388
+		    // ident
1389
+		    if (isset($line['altitude'])) {
1390
+		    	$data['altitude'] = $line['altitude'];
1391
+		    }
1392
+		    // altitude
1393
+		    if (isset($line['speed'])) {
1394
+		    	$data['speed'] = $line['speed'];
1395
+		    }
1396
+		    // speed
1397
+		    if (isset($line['track'])) {
1398
+		    	$data['heading'] = $line['track'];
1399
+		    }
1400
+		    // heading
1401
+		    if (isset($line['lat'])) {
1402
+		    	$data['latitude'] = $line['lat'];
1403
+		    }
1404
+		    // lat
1405
+		    if (isset($line['lon'])) {
1406
+		    	$data['longitude'] = $line['lon'];
1407
+		    }
1408
+		    // long
1409
+		    if (isset($line['vert_rate'])) {
1410
+		    	$data['verticalrate'] = $line['vert_rate'];
1411
+		    }
1412
+		    // verticale rate
1413
+		    if (isset($line['squawk'])) {
1414
+		    	$data['squawk'] = $line['squawk'];
1415
+		    }
1416
+		    // squawk
1039 1417
 		    //$data['emergency'] = ''; // emergency
1040 1418
 		    //$data['registration'] = $line[2];
1041 1419
 		    //$data['aircraft_icao'] = $line[0];
1042 1420
 		    $data['datetime'] = date('Y-m-d H:i:s');
1043 1421
 		    $data['format_source'] = 'aircraftjson';
1044 1422
 		    $data['id_source'] = $id_source;
1045
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1423
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1424
+		    	$data['noarchive'] = true;
1425
+		    }
1046 1426
 		    $SI->add($data);
1047 1427
 		    unset($data);
1048 1428
 		}
@@ -1059,7 +1439,9 @@  discard block
 block discarded – undo
1059 1439
 	    //$buffer = $Common->getData($hosts[$id]);
1060 1440
 	    $buffer = $Common->getData($value['host']);
1061 1441
 	    $all_data = json_decode($buffer,true);
1062
-	    if (!empty($all_data)) $reset = 0;
1442
+	    if (!empty($all_data)) {
1443
+	    	$reset = 0;
1444
+	    }
1063 1445
 	    foreach ($all_data as $key => $line) {
1064 1446
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1065 1447
 		    $data = array();
@@ -1080,8 +1462,12 @@  discard block
 block discarded – undo
1080 1462
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1081 1463
 	    	    $data['format_source'] = 'fr24json';
1082 1464
     		    $data['id_source'] = $id_source;
1083
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1084
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1465
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1466
+		    	$data['noarchive'] = true;
1467
+		    }
1468
+		    if (isset($value['name']) && $value['name'] != '') {
1469
+		    	$data['source_name'] = $value['name'];
1470
+		    }
1085 1471
 		    $SI->add($data);
1086 1472
 		    unset($data);
1087 1473
 		}
@@ -1110,24 +1496,42 @@  discard block
 block discarded – undo
1110 1496
 		    if (isset($line['inf'])) {
1111 1497
 			$data = array();
1112 1498
 			$data['hex'] = $line['inf']['ia'];
1113
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1499
+			if (isset($line['inf']['cs'])) {
1500
+				$data['ident'] = $line['inf']['cs'];
1501
+			}
1502
+			//$line[13]
1114 1503
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1115
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1116
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1504
+	    		if (isset($line['inf']['gs'])) {
1505
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1506
+	    		}
1507
+	    		// speed
1508
+	    		if (isset($line['inf']['tr'])) {
1509
+	    			$data['heading'] = $line['inf']['tr'];
1510
+	    		}
1511
+	    		// heading
1117 1512
 	    		$data['latitude'] = $line['pt'][0]; // lat
1118 1513
 	    		$data['longitude'] = $line['pt'][1]; // long
1119 1514
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1120
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1515
+	    		if (isset($line['inf']['sq'])) {
1516
+	    			$data['squawk'] = $line['inf']['sq'];
1517
+	    		}
1518
+	    		// squawk
1121 1519
 	    		//$data['aircraft_icao'] = $line[8];
1122
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1520
+	    		if (isset($line['inf']['rc'])) {
1521
+	    			$data['registration'] = $line['inf']['rc'];
1522
+	    		}
1123 1523
 			//$data['departure_airport_iata'] = $line[11];
1124 1524
 			//$data['arrival_airport_iata'] = $line[12];
1125 1525
 	    		//$data['emergency'] = ''; // emergency
1126 1526
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1127 1527
 	    		$data['format_source'] = 'radarvirtueljson';
1128 1528
     			$data['id_source'] = $id_source;
1129
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1529
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1530
+				$data['noarchive'] = true;
1531
+			}
1532
+			if (isset($value['name']) && $value['name'] != '') {
1533
+				$data['source_name'] = $value['name'];
1534
+			}
1131 1535
 			$SI->add($data);
1132 1536
 			unset($data);
1133 1537
 		    }
@@ -1153,30 +1557,65 @@  discard block
 block discarded – undo
1153 1557
 		    $data['id'] = $line['id'];
1154 1558
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1155 1559
 		    $data['ident'] = $line['callsign']; // ident
1156
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1157
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1158
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1159
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1160
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1161
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1560
+		    if (isset($line['pilotid'])) {
1561
+		    	$data['pilot_id'] = $line['pilotid'];
1562
+		    }
1563
+		    // pilot id
1564
+		    if (isset($line['name'])) {
1565
+		    	$data['pilot_name'] = $line['name'];
1566
+		    }
1567
+		    // pilot name
1568
+		    if (isset($line['alt'])) {
1569
+		    	$data['altitude'] = $line['alt'];
1570
+		    }
1571
+		    // altitude
1572
+		    if (isset($line['gs'])) {
1573
+		    	$data['speed'] = $line['gs'];
1574
+		    }
1575
+		    // speed
1576
+		    if (isset($line['heading'])) {
1577
+		    	$data['heading'] = $line['heading'];
1578
+		    }
1579
+		    // heading
1580
+		    if (isset($line['route'])) {
1581
+		    	$data['waypoints'] = $line['route'];
1582
+		    }
1583
+		    // route
1162 1584
 		    $data['latitude'] = $line['lat']; // lat
1163 1585
 		    $data['longitude'] = $line['lon']; // long
1164 1586
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1165 1587
 		    //$data['squawk'] = $line['squawk']; // squawk
1166 1588
 		    //$data['emergency'] = ''; // emergency
1167
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1168
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1169
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1589
+		    if (isset($line['depicao'])) {
1590
+		    	$data['departure_airport_icao'] = $line['depicao'];
1591
+		    }
1592
+		    if (isset($line['deptime'])) {
1593
+		    	$data['departure_airport_time'] = $line['deptime'];
1594
+		    }
1595
+		    if (isset($line['arricao'])) {
1596
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1597
+		    }
1170 1598
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1171
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1172
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1173
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1174
-		    else $data['info'] = '';
1599
+		    if (isset($line['aircraft'])) {
1600
+		    	$data['aircraft_icao'] = $line['aircraft'];
1601
+		    }
1602
+		    if (isset($line['transponder'])) {
1603
+		    	$data['squawk'] = $line['transponder'];
1604
+		    }
1605
+		    if (isset($line['atis'])) {
1606
+		    	$data['info'] = $line['atis'];
1607
+		    } else {
1608
+		    	$data['info'] = '';
1609
+		    }
1175 1610
 		    $data['format_source'] = 'pireps';
1176 1611
     		    $data['id_source'] = $id_source;
1177 1612
 		    $data['datetime'] = date('Y-m-d H:i:s');
1178
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1179
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1613
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1614
+		    	$data['noarchive'] = true;
1615
+		    }
1616
+		    if (isset($value['name']) && $value['name'] != '') {
1617
+		    	$data['source_name'] = $value['name'];
1618
+		    }
1180 1619
 		    if ($line['icon'] === 'plane') {
1181 1620
 			$SI->add($data);
1182 1621
 		    //    print_r($data);
@@ -1185,16 +1624,28 @@  discard block
 block discarded – undo
1185 1624
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1186 1625
 			$typec = substr($data['ident'],-3);
1187 1626
 			$data['type'] = '';
1188
-			if ($typec === 'APP') $data['type'] = 'Approach';
1189
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1190
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1191
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1192
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1193
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1194
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1195
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1196
-			else $data['type'] = 'Observer';
1197
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1627
+			if ($typec === 'APP') {
1628
+				$data['type'] = 'Approach';
1629
+			} elseif ($typec === 'TWR') {
1630
+				$data['type'] = 'Tower';
1631
+			} elseif ($typec === 'OBS') {
1632
+				$data['type'] = 'Observer';
1633
+			} elseif ($typec === 'GND') {
1634
+				$data['type'] = 'Ground';
1635
+			} elseif ($typec === 'DEL') {
1636
+				$data['type'] = 'Delivery';
1637
+			} elseif ($typec === 'DEP') {
1638
+				$data['type'] = 'Departure';
1639
+			} elseif ($typec === 'FSS') {
1640
+				$data['type'] = 'Flight Service Station';
1641
+			} elseif ($typec === 'CTR') {
1642
+				$data['type'] = 'Control Radar or Centre';
1643
+			} else {
1644
+				$data['type'] = 'Observer';
1645
+			}
1646
+			if (isset($ATC)) {
1647
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1648
+			}
1198 1649
 		    }
1199 1650
 		    unset($data);
1200 1651
 		}
@@ -1209,7 +1660,9 @@  discard block
 block discarded – undo
1209 1660
 	    )
1210 1661
 	) {
1211 1662
 	    //$buffer = $Common->getData($hosts[$id]);
1212
-	    if ($globalDebug) echo 'Get Data...'."\n";
1663
+	    if ($globalDebug) {
1664
+	    	echo 'Get Data...'."\n";
1665
+	    }
1213 1666
 	    $buffer = $Common->getData($value['host']);
1214 1667
 	    $all_data = json_decode($buffer,true);
1215 1668
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1217,10 +1670,16 @@  discard block
 block discarded – undo
1217 1670
 		foreach ($all_data as $line) {
1218 1671
 	    	    $data = array();
1219 1672
 	    	    //$data['id'] = $line['id']; // id not usable
1220
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1673
+	    	    if (isset($line['pilotid'])) {
1674
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1675
+	    	    }
1221 1676
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1222
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1223
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1677
+	    	    if (isset($line['pilotname'])) {
1678
+	    	    	$data['pilot_name'] = $line['pilotname'];
1679
+	    	    }
1680
+	    	    if (isset($line['pilotid'])) {
1681
+	    	    	$data['pilot_id'] = $line['pilotid'];
1682
+	    	    }
1224 1683
 	    	    $data['ident'] = $line['flightnum']; // ident
1225 1684
 	    	    $data['altitude'] = $line['alt']; // altitude
1226 1685
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1236,7 +1695,9 @@  discard block
 block discarded – undo
1236 1695
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1237 1696
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1238 1697
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1239
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1698
+	    	    } else {
1699
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1700
+	    	    }
1240 1701
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1241 1702
 	    	    $data['departure_airport_time'] = $line['deptime'];
1242 1703
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1244,29 +1705,47 @@  discard block
 block discarded – undo
1244 1705
     		    if (isset($line['registration'])) {
1245 1706
     			$data['registration'] = $line['registration'];
1246 1707
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1247
-    		    } else $data['registration'] = $line['aircraft'];
1248
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1708
+    		    } else {
1709
+    		    	$data['registration'] = $line['aircraft'];
1710
+    		    }
1711
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1712
+		    	$data['noarchive'] = true;
1713
+		    }
1714
+		    if (isset($line['route'])) {
1715
+		    	$data['waypoints'] = $line['route'];
1716
+		    }
1717
+		    // route
1250 1718
 		    if (isset($line['aircraftname'])) {
1251 1719
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1252 1720
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1253 1721
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1254
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1255
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1256
-	    		else {
1722
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1723
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1724
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1725
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1726
+	    		} else {
1257 1727
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1258
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1259
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1728
+	    		    if (isset($aircraft_data[1])) {
1729
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1730
+	    		    } else {
1731
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1732
+	    		    }
1260 1733
 	    		}
1261 1734
 	    	    }
1262
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1735
+    		    if (isset($line['route'])) {
1736
+    		    	$data['waypoints'] = $line['route'];
1737
+    		    }
1263 1738
     		    $data['id_source'] = $id_source;
1264 1739
 	    	    $data['format_source'] = 'phpvmacars';
1265
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1740
+		    if (isset($value['name']) && $value['name'] != '') {
1741
+		    	$data['source_name'] = $value['name'];
1742
+		    }
1266 1743
 		    $SI->add($data);
1267 1744
 		    unset($data);
1268 1745
 		}
1269
-		if ($globalDebug) echo 'No more data...'."\n";
1746
+		if ($globalDebug) {
1747
+			echo 'No more data...'."\n";
1748
+		}
1270 1749
 		unset($buffer);
1271 1750
 		unset($all_data);
1272 1751
 	    }
@@ -1279,7 +1758,9 @@  discard block
 block discarded – undo
1279 1758
 	    )
1280 1759
 	) {
1281 1760
 	    //$buffer = $Common->getData($hosts[$id]);
1282
-	    if ($globalDebug) echo 'Get Data...'."\n";
1761
+	    if ($globalDebug) {
1762
+	    	echo 'Get Data...'."\n";
1763
+	    }
1283 1764
 	    $buffer = $Common->getData($value['host']);
1284 1765
 	    $all_data = json_decode($buffer,true);
1285 1766
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1290,10 +1771,16 @@  discard block
 block discarded – undo
1290 1771
 	    	    //$data['id'] = $line['id']; // id not usable
1291 1772
 	    	    $data['id'] = $line['id'];
1292 1773
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1293
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1294
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1774
+	    	    if (isset($line['user']['username'])) {
1775
+	    	    	$data['pilot_name'] = $line['user']['username'];
1776
+	    	    }
1777
+	    	    if (isset($line['user_id'])) {
1778
+	    	    	$data['pilot_id'] = $line['user_id'];
1779
+	    	    }
1295 1780
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1296
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1781
+	    	    if (is_numeric($data['ident'])) {
1782
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1783
+	    	    }
1297 1784
 	    	    $data['altitude'] = $line['altitude']; // altitude
1298 1785
 	    	    $data['speed'] = $line['groundspeed']; // speed
1299 1786
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1306,7 +1793,9 @@  discard block
 block discarded – undo
1306 1793
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1307 1794
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1308 1795
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1309
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1796
+	    	    } else {
1797
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1798
+	    	    }
1310 1799
 	    	    
1311 1800
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1312 1801
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1314,17 +1803,26 @@  discard block
 block discarded – undo
1314 1803
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1315 1804
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1316 1805
 
1317
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1318
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1806
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1807
+		    	$data['noarchive'] = true;
1808
+		    }
1809
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
1810
+		    	$data['waypoints'] = $line['bid']['route'];
1811
+		    }
1812
+		    // route
1319 1813
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1320 1814
 
1321 1815
     		    $data['id_source'] = $id_source;
1322 1816
 	    	    $data['format_source'] = 'vaos';
1323
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1817
+		    if (isset($value['name']) && $value['name'] != '') {
1818
+		    	$data['source_name'] = $value['name'];
1819
+		    }
1324 1820
 		    $SI->add($data);
1325 1821
 		    unset($data);
1326 1822
 		}
1327
-		if ($globalDebug) echo 'No more data...'."\n";
1823
+		if ($globalDebug) {
1824
+			echo 'No more data...'."\n";
1825
+		}
1328 1826
 		unset($buffer);
1329 1827
 		unset($all_data);
1330 1828
 	    }
@@ -1337,7 +1835,9 @@  discard block
 block discarded – undo
1337 1835
 	    )
1338 1836
 	) {
1339 1837
 	    //$buffer = $Common->getData($hosts[$id]);
1340
-	    if ($globalDebug) echo 'Get Data...'."\n";
1838
+	    if ($globalDebug) {
1839
+	    	echo 'Get Data...'."\n";
1840
+	    }
1341 1841
 	    $buffer = $Common->getData($value['host']);
1342 1842
 	    $all_data = json_decode($buffer,true);
1343 1843
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1366,16 +1866,25 @@  discard block
 block discarded – undo
1366 1866
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1367 1867
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1368 1868
     		    //$data['registration'] = $line['aircraft'];
1369
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1869
+		    if (isset($line['route'])) {
1870
+		    	$data['waypoints'] = $line['route'];
1871
+		    }
1872
+		    // route
1370 1873
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1371 1874
     		    $data['id_source'] = $id_source;
1372 1875
 	    	    $data['format_source'] = 'vam';
1373
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1374
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1876
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1877
+		    	$data['noarchive'] = true;
1878
+		    }
1879
+		    if (isset($value['name']) && $value['name'] != '') {
1880
+		    	$data['source_name'] = $value['name'];
1881
+		    }
1375 1882
 		    $SI->add($data);
1376 1883
 		    unset($data);
1377 1884
 		}
1378
-		if ($globalDebug) echo 'No more data...'."\n";
1885
+		if ($globalDebug) {
1886
+			echo 'No more data...'."\n";
1887
+		}
1379 1888
 		unset($buffer);
1380 1889
 		unset($all_data);
1381 1890
 	    }
@@ -1388,7 +1897,9 @@  discard block
 block discarded – undo
1388 1897
 	    )
1389 1898
 	) {
1390 1899
 	    //$buffer = $Common->getData($hosts[$id]);
1391
-	    if ($globalDebug) echo 'Get Data...'."\n";
1900
+	    if ($globalDebug) {
1901
+	    	echo 'Get Data...'."\n";
1902
+	    }
1392 1903
 	    $buffer = $Common->getData($value['host']);
1393 1904
 	    $all_data = json_decode($buffer,true);
1394 1905
 	    if ($buffer != '') {
@@ -1406,12 +1917,16 @@  discard block
 block discarded – undo
1406 1917
 			$data['id_source'] = $id_source;
1407 1918
 			$data['format_source'] = 'blitzortung';
1408 1919
 			$SI->add($data);
1409
-			if ($globalDebug) echo '☈ Lightning added'."\n";
1920
+			if ($globalDebug) {
1921
+				echo '☈ Lightning added'."\n";
1922
+			}
1410 1923
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1411 1924
 			unset($data);
1412 1925
 		    }
1413 1926
 		}
1414
-		if ($globalDebug) echo 'No more data...'."\n";
1927
+		if ($globalDebug) {
1928
+			echo 'No more data...'."\n";
1929
+		}
1415 1930
 		unset($buffer);
1416 1931
 	    }
1417 1932
 	    $last_exec[$id]['last'] = time();
@@ -1423,7 +1938,9 @@  discard block
 block discarded – undo
1423 1938
 	    $write = NULL;
1424 1939
 	    $e = NULL;
1425 1940
 	    $n = socket_select($read, $write, $e, $timeout);
1426
-	    if ($e != NULL) var_dump($e);
1941
+	    if ($e != NULL) {
1942
+	    	var_dump($e);
1943
+	    }
1427 1944
 	    if ($n > 0) {
1428 1945
 		$reset = 0;
1429 1946
 		foreach ($read as $nb => $r) {
@@ -1445,13 +1962,17 @@  discard block
 block discarded – undo
1445 1962
 		    if ($buffer !== FALSE) {
1446 1963
 			if ($format === 'vrstcp') {
1447 1964
 			    $buffer = explode('},{',$buffer);
1448
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1965
+			} else {
1966
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1967
+			}
1449 1968
 		    }
1450 1969
 		    // SBS format is CSV format
1451 1970
 		    if ($buffer !== FALSE && $buffer !== '') {
1452 1971
 			$tt[$format] = 0;
1453 1972
 			if ($format === 'acarssbs3') {
1454
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1973
+			    if ($globalDebug) {
1974
+			    	echo 'ACARS : '.$buffer."\n";
1975
+			    }
1455 1976
 			    $ACARS->add(trim($buffer));
1456 1977
 			    $ACARS->deleteLiveAcarsData();
1457 1978
 			} elseif ($format === 'raw') {
@@ -1460,30 +1981,70 @@  discard block
 block discarded – undo
1460 1981
 			    if (is_array($data)) {
1461 1982
 				$data['datetime'] = date('Y-m-d H:i:s');
1462 1983
 				$data['format_source'] = 'raw';
1463
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1464
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1465
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1466
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1984
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1985
+					$data['source_name'] = $globalSources[$nb]['name'];
1986
+				}
1987
+				if (isset($globalSources[$nb]['sourcestats'])) {
1988
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1989
+				}
1990
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1991
+					$data['noarchive'] = true;
1992
+				}
1993
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1994
+					$SI->add($data);
1995
+				}
1467 1996
 			    }
1468 1997
 			} elseif ($format === 'ais') {
1469 1998
 			    $ais_data = $AIS->parse_line(trim($buffer));
1470 1999
 			    $data = array();
1471
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1472
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1473
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1474
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1475
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1476
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1477
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1478
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1479
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1480
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1481
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1482
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1483
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1484
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1485
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1486
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2000
+			    if (isset($ais_data['ident'])) {
2001
+			    	$data['ident'] = $ais_data['ident'];
2002
+			    }
2003
+			    if (isset($ais_data['mmsi'])) {
2004
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2005
+			    }
2006
+			    if (isset($ais_data['speed'])) {
2007
+			    	$data['speed'] = $ais_data['speed'];
2008
+			    }
2009
+			    if (isset($ais_data['heading'])) {
2010
+			    	$data['heading'] = $ais_data['heading'];
2011
+			    }
2012
+			    if (isset($ais_data['latitude'])) {
2013
+			    	$data['latitude'] = $ais_data['latitude'];
2014
+			    }
2015
+			    if (isset($ais_data['longitude'])) {
2016
+			    	$data['longitude'] = $ais_data['longitude'];
2017
+			    }
2018
+			    if (isset($ais_data['status'])) {
2019
+			    	$data['status'] = $ais_data['status'];
2020
+			    }
2021
+			    if (isset($ais_data['statusid'])) {
2022
+			    	$data['status_id'] = $ais_data['statusid'];
2023
+			    }
2024
+			    if (isset($ais_data['type'])) {
2025
+			    	$data['type'] = $ais_data['type'];
2026
+			    }
2027
+			    if (isset($ais_data['imo'])) {
2028
+			    	$data['imo'] = $ais_data['imo'];
2029
+			    }
2030
+			    if (isset($ais_data['callsign'])) {
2031
+			    	$data['callsign'] = $ais_data['callsign'];
2032
+			    }
2033
+			    if (isset($ais_data['destination'])) {
2034
+			    	$data['arrival_code'] = $ais_data['destination'];
2035
+			    }
2036
+			    if (isset($ais_data['eta_ts'])) {
2037
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2038
+			    }
2039
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2040
+			    	$data['noarchive'] = true;
2041
+			    }
2042
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2043
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2044
+			    }
2045
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2046
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2047
+			    }
1487 2048
 
1488 2049
 			    if (isset($ais_data['timestamp'])) {
1489 2050
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1492,7 +2053,9 @@  discard block
 block discarded – undo
1492 2053
 			    }
1493 2054
 			    $data['format_source'] = 'aisnmea';
1494 2055
     			    $data['id_source'] = $id_source;
1495
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2056
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2057
+			    	$MI->add($data);
2058
+			    }
1496 2059
 			    unset($data);
1497 2060
                         } elseif ($format === 'flightgearsp') {
1498 2061
                     	    //echo $buffer."\n";
@@ -1510,12 +2073,18 @@  discard block
 block discarded – undo
1510 2073
 				$data['speed'] = round($line[5]*1.94384);
1511 2074
 				$data['datetime'] = date('Y-m-d H:i:s');
1512 2075
 				$data['format_source'] = 'flightgearsp';
1513
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1514
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2076
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2077
+					$data['noarchive'] = true;
2078
+				}
2079
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2080
+					$SI->add($data);
2081
+				}
1515 2082
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1516 2083
 			    }
1517 2084
                         } elseif ($format === 'acars') {
1518
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2085
+                    	    if ($globalDebug) {
2086
+                    	    	echo 'ACARS : '.$buffer."\n";
2087
+                    	    }
1519 2088
 			    $ACARS->add(trim($buffer));
1520 2089
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1521 2090
 			    $ACARS->deleteLiveAcarsData();
@@ -1536,8 +2105,12 @@  discard block
 block discarded – undo
1536 2105
 				    $aircraft_type = $line[10];
1537 2106
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1538 2107
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1539
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1540
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2108
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2109
+				    	$data['noarchive'] = true;
2110
+				    }
2111
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2112
+				    	$SI->add($data);
2113
+				    }
1541 2114
 				}
1542 2115
 			    }
1543 2116
 			} elseif ($format === 'beast') {
@@ -1547,28 +2120,62 @@  discard block
 block discarded – undo
1547 2120
 			    foreach($buffer as $all_data) {
1548 2121
 				$line = json_decode('{'.$all_data.'}',true);
1549 2122
 				$data = array();
1550
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1551
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1552
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1553
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1554
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1555
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1556
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2123
+				if (isset($line['Icao'])) {
2124
+					$data['hex'] = $line['Icao'];
2125
+				}
2126
+				// hex
2127
+				if (isset($line['Call'])) {
2128
+					$data['ident'] = $line['Call'];
2129
+				}
2130
+				// ident
2131
+				if (isset($line['Alt'])) {
2132
+					$data['altitude'] = $line['Alt'];
2133
+				}
2134
+				// altitude
2135
+				if (isset($line['Spd'])) {
2136
+					$data['speed'] = $line['Spd'];
2137
+				}
2138
+				// speed
2139
+				if (isset($line['Trak'])) {
2140
+					$data['heading'] = $line['Trak'];
2141
+				}
2142
+				// heading
2143
+				if (isset($line['Lat'])) {
2144
+					$data['latitude'] = $line['Lat'];
2145
+				}
2146
+				// lat
2147
+				if (isset($line['Long'])) {
2148
+					$data['longitude'] = $line['Long'];
2149
+				}
2150
+				// long
1557 2151
 				//$data['verticalrate'] = $line['']; // verticale rate
1558
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2152
+				if (isset($line['Sqk'])) {
2153
+					$data['squawk'] = $line['Sqk'];
2154
+				}
2155
+				// squawk
1559 2156
 				$data['emergency'] = ''; // emergency
1560
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2157
+				if (isset($line['Reg'])) {
2158
+					$data['registration'] = $line['Reg'];
2159
+				}
1561 2160
 				/*
1562 2161
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1563 2162
 				else $data['datetime'] = date('Y-m-d H:i:s');
1564 2163
 				*/
1565 2164
 				$data['datetime'] = date('Y-m-d H:i:s');
1566
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2165
+				if (isset($line['Type'])) {
2166
+					$data['aircraft_icao'] = $line['Type'];
2167
+				}
1567 2168
 		    		$data['format_source'] = 'vrstcp';
1568 2169
 				$data['id_source'] = $id_source;
1569
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1570
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1571
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2170
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2171
+					$data['noarchive'] = true;
2172
+				}
2173
+				if (isset($value['name']) && $value['name'] != '') {
2174
+					$data['source_name'] = $value['name'];
2175
+				}
2176
+				if (isset($data['latitude']) && isset($data['hex'])) {
2177
+					$SI->add($data);
2178
+				}
1572 2179
 				unset($data);
1573 2180
 			    }
1574 2181
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1581,22 +2188,46 @@  discard block
 block discarded – undo
1581 2188
     				$data['hex'] = $lined['hexid'];
1582 2189
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1583 2190
     				$data['datetime'] = date('Y-m-d H:i:s');;
1584
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1585
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1586
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1587
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1588
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1589
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1590
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2191
+    				if (isset($lined['ident'])) {
2192
+    					$data['ident'] = $lined['ident'];
2193
+    				}
2194
+    				if (isset($lined['lat'])) {
2195
+    					$data['latitude'] = $lined['lat'];
2196
+    				}
2197
+    				if (isset($lined['lon'])) {
2198
+    					$data['longitude'] = $lined['lon'];
2199
+    				}
2200
+    				if (isset($lined['speed'])) {
2201
+    					$data['speed'] = $lined['speed'];
2202
+    				}
2203
+    				if (isset($lined['squawk'])) {
2204
+    					$data['squawk'] = $lined['squawk'];
2205
+    				}
2206
+    				if (isset($lined['alt'])) {
2207
+    					$data['altitude'] = $lined['alt'];
2208
+    				}
2209
+    				if (isset($lined['heading'])) {
2210
+    					$data['heading'] = $lined['heading'];
2211
+    				}
1591 2212
     				$data['id_source'] = $id_source;
1592 2213
     				$data['format_source'] = 'tsv';
1593
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1594
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1595
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1596
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2214
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2215
+    					$data['source_name'] = $globalSources[$nb]['name'];
2216
+    				}
2217
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2218
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2219
+    				}
2220
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2221
+					$data['noarchive'] = true;
2222
+				}
2223
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2224
+    					$SI->add($data);
2225
+    				}
1597 2226
     				unset($lined);
1598 2227
     				unset($data);
1599
-    			    } else $error = true;
2228
+    			    } else {
2229
+    			    	$error = true;
2230
+    			    }
1600 2231
 			} elseif ($format === 'aprs' && $use_aprs) {
1601 2232
 			    if ($aprs_connect === 0) {
1602 2233
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1622,63 +2253,121 @@  discard block
 block discarded – undo
1622 2253
 				    $aprs_last_tx = time();
1623 2254
 				    $data = array();
1624 2255
 				    //print_r($line);
1625
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1626
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1627
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1628
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1629
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1630
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1631
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1632
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1633
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1634
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2256
+				    if (isset($line['address'])) {
2257
+				    	$data['hex'] = $line['address'];
2258
+				    }
2259
+				    if (isset($line['mmsi'])) {
2260
+				    	$data['mmsi'] = $line['mmsi'];
2261
+				    }
2262
+				    if (isset($line['imo'])) {
2263
+				    	$data['imo'] = $line['imo'];
2264
+				    }
2265
+				    if (isset($line['squawk'])) {
2266
+				    	$data['squawk'] = $line['squawk'];
2267
+				    }
2268
+				    if (isset($line['arrival_code'])) {
2269
+				    	$data['arrival_code'] = $line['arrival_code'];
2270
+				    }
2271
+				    if (isset($line['arrival_date'])) {
2272
+				    	$data['arrival_date'] = $line['arrival_date'];
2273
+				    }
2274
+				    if (isset($line['typeid'])) {
2275
+				    	$data['type_id'] = $line['typeid'];
2276
+				    }
2277
+				    if (isset($line['statusid'])) {
2278
+				    	$data['status_id'] = $line['statusid'];
2279
+				    }
2280
+				    if (isset($line['timestamp'])) {
2281
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2282
+				    } else {
2283
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2284
+				    }
1635 2285
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1636
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2286
+				    if (isset($line['ident'])) {
2287
+				    	$data['ident'] = $line['ident'];
2288
+				    }
1637 2289
 				    $data['latitude'] = $line['latitude'];
1638 2290
 				    $data['longitude'] = $line['longitude'];
1639 2291
 				    //$data['verticalrate'] = $line[16];
1640
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2292
+				    if (isset($line['speed'])) {
2293
+				    	$data['speed'] = $line['speed'];
2294
+				    }
1641 2295
 				    //else $data['speed'] = 0;
1642
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1643
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1644
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2296
+				    if (isset($line['altitude'])) {
2297
+				    	$data['altitude'] = $line['altitude'];
2298
+				    }
2299
+				    if (isset($line['comment'])) {
2300
+				    	$data['comment'] = $line['comment'];
2301
+				    }
2302
+				    if (isset($line['symbol'])) {
2303
+				    	$data['type'] = $line['symbol'];
2304
+				    }
1645 2305
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1646 2306
 				    
1647
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2307
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2308
+				    	$data['heading'] = $line['heading'];
2309
+				    }
1648 2310
 				    //else echo 'No heading...'."\n";
1649 2311
 				    //else $data['heading'] = 0;
1650
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2312
+				    if (isset($line['stealth'])) {
2313
+				    	$data['aircraft_type'] = $line['stealth'];
2314
+				    }
1651 2315
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1652
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1653
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1654
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1655
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2316
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2317
+				    	$data['noarchive'] = true;
2318
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2319
+				    	$data['noarchive'] = false;
2320
+				    }
2321
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2322
+				    	$data['noarchive'] = true;
2323
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2324
+				    	$data['noarchive'] = false;
2325
+				    }
1656 2326
     				    $data['id_source'] = $id_source;
1657
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1658
-				    else $data['format_source'] = 'aprs';
2327
+    				    if (isset($line['format_source'])) {
2328
+    				    	$data['format_source'] = $line['format_source'];
2329
+    				    } else {
2330
+				    	$data['format_source'] = 'aprs';
2331
+				    }
1659 2332
 				    $data['source_name'] = $line['source'];
1660
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1661
-				    else $data['source_type'] = 'flarm';
1662
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2333
+				    if (isset($line['source_type'])) {
2334
+				    	$data['source_type'] = $line['source_type'];
2335
+				    } else {
2336
+				    	$data['source_type'] = 'flarm';
2337
+				    }
2338
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2339
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2340
+    				    }
1663 2341
 				    $currentdate = date('Y-m-d H:i:s');
1664 2342
 				    $aprsdate = strtotime($data['datetime']);
1665
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2343
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2344
+				    	$data['altitude_relative'] = 'AMSL';
2345
+				    }
1666 2346
 				    // Accept data if time <= system time + 20s
1667 2347
 				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1668 2348
 				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1669 2349
 					$send = $SI->add($data);
1670 2350
 				    } elseif ($data['source_type'] === 'ais') {
1671 2351
 					$data['type'] = '';
1672
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2352
+					if (isset($globalMarine) && $globalMarine) {
2353
+						$send = $MI->add($data);
2354
+					}
1673 2355
 				    } elseif (isset($line['stealth'])) {
1674
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1675
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2356
+					if ($line['stealth'] != 0) {
2357
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2358
+					} else {
2359
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2360
+					}
1676 2361
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1677 2362
 					    //$line['symbol'] === 'Balloon' ||
1678 2363
 					    $line['symbol'] === 'Glider' || 
1679 2364
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1680
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1681
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2365
+					    if ($line['symbol'] === 'Ballon') {
2366
+					    	$data['aircraft_icao'] = 'BALL';
2367
+					    }
2368
+					    if ($line['symbol'] === 'Glider') {
2369
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2370
+					    }
1682 2371
 					    $send = $SI->add($data);
1683 2372
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1684 2373
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1709,9 +2398,13 @@  discard block
 block discarded – undo
1709 2398
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1710 2399
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1711 2400
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1712
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2401
+					if (isset($globalTracker) && $globalTracker) {
2402
+						$send = $TI->add($data);
2403
+					}
1713 2404
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1714
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2405
+					if (!isset($data['altitude'])) {
2406
+						$data['altitude'] = 0;
2407
+					}
1715 2408
 					$Source->deleteOldLocationByType('gs');
1716 2409
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1717 2410
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1720,7 +2413,9 @@  discard block
 block discarded – undo
1720 2413
 					}
1721 2414
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1722 2415
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1723
-					if ($globalDebug) echo '# Weather Station added'."\n";
2416
+					if ($globalDebug) {
2417
+						echo '# Weather Station added'."\n";
2418
+					}
1724 2419
 					$Source->deleteOldLocationByType('wx');
1725 2420
 					$weather_data = json_encode($line);
1726 2421
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1730,7 +2425,9 @@  discard block
 block discarded – undo
1730 2425
 					}
1731 2426
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1732 2427
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1733
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2428
+					if ($globalDebug) {
2429
+						echo '☈ Lightning added'."\n";
2430
+					}
1734 2431
 					$Source->deleteOldLocationByType('lightning');
1735 2432
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1736 2433
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1742,8 +2439,7 @@  discard block
 block discarded – undo
1742 2439
 				    	print_r($line);
1743 2440
 				    }
1744 2441
 				    unset($data);
1745
-				}
1746
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2442
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1747 2443
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1748 2444
 				}
1749 2445
 				/*
@@ -1752,7 +2448,9 @@  discard block
 block discarded – undo
1752 2448
 				}
1753 2449
 				*/
1754 2450
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1755
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2451
+				elseif ($line === true && $globalDebug) {
2452
+					echo '!! Failed : '.$buffer."!!\n";
2453
+				}
1756 2454
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1757 2455
 					$Source->deleteOldLocationByType('lightning');
1758 2456
 					$Source->deleteOldLocationByType('wx');
@@ -1788,26 +2486,45 @@  discard block
 block discarded – undo
1788 2486
     				$data['ground'] = $line[21];
1789 2487
     				$data['emergency'] = $line[19];
1790 2488
     				$data['format_source'] = 'sbs';
1791
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1792
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1793
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2489
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2490
+					$data['source_name'] = $globalSources[$nb]['name'];
2491
+				}
2492
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2493
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2494
+    				}
2495
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2496
+					$data['noarchive'] = true;
2497
+				}
1794 2498
     				$data['id_source'] = $id_source;
1795
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1796
-    				else $error = true;
2499
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2500
+    					$send = $SI->add($data);
2501
+    				} else {
2502
+    					$error = true;
2503
+    				}
1797 2504
     				unset($data);
1798
-    			    } else $error = true;
2505
+    			    } else {
2506
+    			    	$error = true;
2507
+    			    }
1799 2508
 			    if ($error) {
1800 2509
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1801
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2510
+					if ($globalDebug) {
2511
+						echo "Not a message. Ignoring... \n";
2512
+					}
1802 2513
 				} else {
1803
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2514
+					if ($globalDebug) {
2515
+						echo "Wrong line format. Ignoring... \n";
2516
+					}
1804 2517
 					if ($globalDebug) {
1805 2518
 						echo $buffer;
1806 2519
 						//print_r($line);
1807 2520
 					}
1808 2521
 					//socket_close($r);
1809
-					if ($globalDebug) echo "Reconnect after an error...\n";
1810
-					if ($format === 'aprs') $aprs_connect = 0;
2522
+					if ($globalDebug) {
2523
+						echo "Reconnect after an error...\n";
2524
+					}
2525
+					if ($format === 'aprs') {
2526
+						$aprs_connect = 0;
2527
+					}
1811 2528
 					$sourceer[$nb] = $globalSources[$nb];
1812 2529
 					connect_all($sourceer);
1813 2530
 					$sourceer = array();
@@ -1815,10 +2532,14 @@  discard block
 block discarded – undo
1815 2532
 			    }
1816 2533
 			}
1817 2534
 			// Sleep for xxx microseconds
1818
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2535
+			if (isset($globalSBSSleep)) {
2536
+				usleep($globalSBSSleep);
2537
+			}
1819 2538
 		    } else {
1820 2539
 			if ($format === 'flightgearmp') {
1821
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2540
+			    	if ($globalDebug) {
2541
+			    		echo "Reconnect FlightGear MP...";
2542
+			    	}
1822 2543
 				//@socket_close($r);
1823 2544
 				sleep($globalMinFetch);
1824 2545
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1827,10 +2548,15 @@  discard block
 block discarded – undo
1827 2548
 				break;
1828 2549
 				
1829 2550
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1830
-			    if (isset($tt[$format])) $tt[$format]++;
1831
-			    else $tt[$format] = 0;
2551
+			    if (isset($tt[$format])) {
2552
+			    	$tt[$format]++;
2553
+			    } else {
2554
+			    	$tt[$format] = 0;
2555
+			    }
1832 2556
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1833
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2557
+				if ($globalDebug) {
2558
+					echo "ERROR : Reconnect ".$format."...";
2559
+				}
1834 2560
 				//@socket_close($r);
1835 2561
 				sleep(2);
1836 2562
 				$aprs_connect = 0;
@@ -1848,11 +2574,17 @@  discard block
 block discarded – undo
1848 2574
 	    } else {
1849 2575
 		$error = socket_strerror(socket_last_error());
1850 2576
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1851
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1852
-			if (isset($globalDebug)) echo "Restarting...\n";
2577
+			if ($globalDebug) {
2578
+				echo "ERROR : socket_select give this error ".$error . "\n";
2579
+			}
2580
+			if (isset($globalDebug)) {
2581
+				echo "Restarting...\n";
2582
+			}
1853 2583
 			// Restart the script if possible
1854 2584
 			if (is_array($sockets)) {
1855
-			    if ($globalDebug) echo "Shutdown all sockets...";
2585
+			    if ($globalDebug) {
2586
+			    	echo "Shutdown all sockets...";
2587
+			    }
1856 2588
 			    
1857 2589
 			    foreach ($sockets as $sock) {
1858 2590
 				@socket_shutdown($sock,2);
@@ -1860,25 +2592,45 @@  discard block
 block discarded – undo
1860 2592
 			    }
1861 2593
 			    
1862 2594
 			}
1863
-			if ($globalDebug) echo "Waiting...";
2595
+			if ($globalDebug) {
2596
+				echo "Waiting...";
2597
+			}
1864 2598
 			sleep(2);
1865 2599
 			$time = time();
1866 2600
 			//connect_all($hosts);
1867 2601
 			$aprs_connect = 0;
1868
-			if ($reset%5 === 0) sleep(20);
1869
-			if ($reset%10 === 0) sleep(100);
1870
-			if ($reset%20 === 0) sleep(200);
1871
-			if ($reset > 100) exit('Too many attempts...');
1872
-			if ($globalDebug) echo "Restart all connections...";
2602
+			if ($reset%5 === 0) {
2603
+				sleep(20);
2604
+			}
2605
+			if ($reset%10 === 0) {
2606
+				sleep(100);
2607
+			}
2608
+			if ($reset%20 === 0) {
2609
+				sleep(200);
2610
+			}
2611
+			if ($reset > 100) {
2612
+				exit('Too many attempts...');
2613
+			}
2614
+			if ($globalDebug) {
2615
+				echo "Restart all connections...";
2616
+			}
1873 2617
 			connect_all($globalSources);
1874 2618
 		}
1875 2619
 	    }
1876 2620
 	}
1877 2621
 	if ($globalDaemon === false) {
1878
-	    if ($globalDebug) echo 'Check all...'."\n";
1879
-	    if (isset($SI)) $SI->checkAll();
1880
-	    if (isset($TI)) $TI->checkAll();
1881
-	    if (isset($MI)) $MI->checkAll();
2622
+	    if ($globalDebug) {
2623
+	    	echo 'Check all...'."\n";
2624
+	    }
2625
+	    if (isset($SI)) {
2626
+	    	$SI->checkAll();
2627
+	    }
2628
+	    if (isset($TI)) {
2629
+	    	$TI->checkAll();
2630
+	    }
2631
+	    if (isset($MI)) {
2632
+	    	$MI->checkAll();
2633
+	    }
1882 2634
 	}
1883 2635
     }
1884 2636
 }
Please login to merge, or discard this patch.
install/index.php 3 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
 			<p>
189 189
 				<label for="siteurl">Site directory</label>
190 190
 				<?php
191
-				    // Try to detect site directory
192
-				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
191
+					// Try to detect site directory
192
+					if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
193 193
 					if (isset($_SERVER['REQUEST_URI'])) {
194 194
 						$URL = $_SERVER['REQUEST_URI'];
195 195
 						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
196 196
 					}
197
-				    }
197
+					}
198 198
 				?>
199 199
 				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
200 200
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
@@ -373,17 +373,17 @@  discard block
 block discarded – undo
373 373
 				</tr>
374 374
 				
375 375
 		<?php
376
-		    if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
376
+			if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
377 377
 		?>
378 378
 		<!--
379 379
 		<?php
380
-			    require_once(dirname(__FILE__).'/../require/class.Connection.php');
381
-			    $Connection = new Connection();
380
+				require_once(dirname(__FILE__).'/../require/class.Connection.php');
381
+				$Connection = new Connection();
382 382
 		?>
383 383
 		-->
384 384
 		<?php
385 385
 			if ($Connection->db != NULL) {
386
-			    if ($Connection->tableExists('source_location')) {
386
+				if ($Connection->tableExists('source_location')) {
387 387
 				require_once(dirname(__FILE__).'/../require/class.Source.php');
388 388
 				$Source = new Source();
389 389
 				//$alllocations = $Source->getAllLocationInfo();
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
 		
404 404
 		<?php
405 405
 				}
406
-			    }
406
+				}
407
+			}
407 408
 			}
408
-		    }
409 409
 		?>
410 410
 
411 411
 				<tr>
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 ?>
516 516
 							<tr>
517 517
 								<?php
518
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
518
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
519 519
 								?>
520 520
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
521 521
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
522 522
 								<?php
523
-								    } else {
523
+									} else {
524 524
 									$hostport = explode(':',$source['host']);
525 525
 									if (isset($hostport[1])) {
526 526
 										$host = $hostport[0];
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
534 534
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td>
535 535
 								<?php
536
-								    }
536
+									}
537 537
 								?>
538 538
 								<td>
539 539
 									<select name="format[]" id="format">
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 			    </thead>
674 674
 			    <tbody>
675 675
 				<?php
676
-				    if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
676
+					if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
677 677
 					foreach ($globalNewsFeeds as $type => $feedslng) {
678
-					    foreach ($feedslng as $lng => $feeds) {
678
+						foreach ($feedslng as $lng => $feeds) {
679 679
 						foreach ($feeds as $feed) {
680 680
 				?>
681 681
 				<tr>
@@ -700,9 +700,9 @@  discard block
 block discarded – undo
700 700
 				
701 701
 				<?php
702 702
 						}
703
-					    }
703
+						}
704
+					}
704 705
 					}
705
-				    }
706 706
 				?>
707 707
 				<tr>
708 708
 				    <td><input type="url" name="newsurl[]" /></td>
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 			<br />
1093 1093
 			<p>
1094 1094
 			<?php 
1095
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
1095
+				if (extension_loaded('gd') && function_exists('gd_info')) {
1096 1096
 			?>
1097 1097
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1098 1098
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -1102,11 +1102,11 @@  discard block
 block discarded – undo
1102 1102
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
1103 1103
 			<?php
1104 1104
 				}
1105
-			    } else {
1105
+				} else {
1106 1106
 			?>
1107 1107
 				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
1108 1108
 			<?php
1109
-			    }
1109
+				}
1110 1110
 			?>
1111 1111
 			</p>
1112 1112
 			<br />
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 	</p>
1131 1131
 <?php
1132 1132
 	require('../footer.php');
1133
-        exit;
1133
+		exit;
1134 1134
 }
1135 1135
 // '	
1136 1136
 $settings = array();
@@ -1221,8 +1221,8 @@  discard block
 block discarded – undo
1221 1221
 	
1222 1222
 	$sources = array();
1223 1223
 	foreach ($source_name as $keys => $name) {
1224
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1225
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1224
+		if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1225
+		else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1226 1226
 	}
1227 1227
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1228 1228
 
@@ -1232,13 +1232,13 @@  discard block
 block discarded – undo
1232 1232
 	
1233 1233
 	$newsfeeds = array();
1234 1234
 	foreach($newsurl as $newskey => $url) {
1235
-	    if ($url != '') {
1235
+		if ($url != '') {
1236 1236
 		$type = $newstype[$newskey];
1237 1237
 		$lng = $newslng[$newskey];
1238 1238
 		if (isset($newsfeeds[$type][$lng])) {
1239
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1239
+			$newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1240 1240
 		} else $newsfeeds[$type][$lng] = array($url);
1241
-	    }
1241
+		}
1242 1242
 	}
1243 1243
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1244 1244
 
@@ -1681,14 +1681,14 @@  discard block
 block discarded – undo
1681 1681
 
1682 1682
 	// Set some defaults values...
1683 1683
 	if (!isset($globalAircraftImageSources)) {
1684
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1685
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1684
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1685
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1686 1686
 	}
1687 1687
 
1688 1688
 	if (!isset($globalSchedulesSources)) {
1689
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1690
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1691
-    	}
1689
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1690
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1691
+		}
1692 1692
 
1693 1693
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1694 1694
 
@@ -1736,21 +1736,21 @@  discard block
 block discarded – undo
1736 1736
 	$popi = false;
1737 1737
 	$popw = false;
1738 1738
 	foreach ($_SESSION['done'] as $done) {
1739
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1740
-	    if ($done == 'Create database') $pop = true;
1741
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1742
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1743
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1739
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1740
+		if ($done == 'Create database') $pop = true;
1741
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1742
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1743
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1744 1744
 	}
1745 1745
 	if ($pop) {
1746
-	    sleep(5);
1747
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1746
+		sleep(5);
1747
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1748 1748
 	} else if ($popi) {
1749
-	    sleep(5);
1750
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1749
+		sleep(5);
1750
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1751 1751
 	} else if ($popw) {
1752
-	    sleep(5);
1753
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1752
+		sleep(5);
1753
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1754 1754
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1755 1755
 	print '</div></ul>';
1756 1756
 	print '<div id="error"></div>';
@@ -1816,7 +1816,7 @@  discard block
 block discarded – undo
1816 1816
 	unset($_COOKIE['install']);
1817 1817
 	print '<div class="info column"><ul>';
1818 1818
 	foreach ($_SESSION['done'] as $done) {
1819
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1819
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1820 1820
 	}
1821 1821
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1822 1822
 	print '</ul></div>';
Please login to merge, or discard this patch.
Braces   +592 added lines, -159 removed lines patch added patch discarded remove patch
@@ -4,11 +4,19 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	}
12 20
 /*
13 21
 if (isset($_SESSION['errorlst'])) {
14 22
 	header('Content-Encoding: none;');
@@ -159,31 +167,49 @@  discard block
 block discarded – undo
159 167
 			</div>
160 168
 			<p>
161 169
 				<label for="dbhost">Database hostname</label>
162
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
170
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
171
+	print $globalDBhost;
172
+}
173
+?>" />
163 174
 			</p>
164 175
 			<p>
165 176
 				<label for="dbport">Database port</label>
166
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
177
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
178
+	print $globalDBport;
179
+}
180
+?>" />
167 181
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
168 182
 			</p>
169 183
 			<p>
170 184
 				<label for="dbname">Database name</label>
171
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
185
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
186
+	print $globalDBname;
187
+}
188
+?>" />
172 189
 			</p>
173 190
 			<p>
174 191
 				<label for="dbuser">Database user</label>
175
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
192
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
193
+	print $globalDBuser;
194
+}
195
+?>" />
176 196
 			</p>
177 197
 			<p>
178 198
 				<label for="dbuserpass">Database user password</label>
179
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
199
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
200
+	print $globalDBpass;
201
+}
202
+?>" />
180 203
 			</p>
181 204
 		</fieldset>
182 205
 		<fieldset id="site">
183 206
 			<legend>Site configuration</legend>
184 207
 			<p>
185 208
 				<label for="sitename">Site name</label>
186
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
209
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
210
+	print $globalName;
211
+}
212
+?>" />
187 213
 			</p>
188 214
 			<p>
189 215
 				<label for="siteurl">Site directory</label>
@@ -196,18 +222,27 @@  discard block
 block discarded – undo
196 222
 					}
197 223
 				    }
198 224
 				?>
199
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
225
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
226
+	print $globalURL;
227
+}
228
+?>" />
200 229
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
201 230
 				<p class="help-block">Can be empty</p>
202 231
 			</p>
203 232
 			<p>
204 233
 				<label for="timezone">Timezone</label>
205
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
234
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
235
+	print $globalTimezone;
236
+}
237
+?>" />
206 238
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
207 239
 			</p>
208 240
 			<p>
209 241
 				<label for="language">Language</label>
210
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
242
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
243
+	print $globalLanguage;
244
+}
245
+?>" />
211 246
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
212 247
 			</p>
213 248
 		</fieldset>
@@ -227,11 +262,17 @@  discard block
 block discarded – undo
227 262
 			<div id="mapbox_data">
228 263
 				<p>
229 264
 					<label for="mapboxid">Mapbox id</label>
230
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
265
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
266
+	print $globalMapboxId;
267
+}
268
+?>" />
231 269
 				</p>
232 270
 				<p>
233 271
 					<label for="mapboxtoken">Mapbox token</label>
234
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
272
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
273
+	print $globalMapboxToken;
274
+}
275
+?>" />
235 276
 				</p>
236 277
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
237 278
 			</div>
@@ -239,7 +280,10 @@  discard block
 block discarded – undo
239 280
 			<div id="google_data">
240 281
 				<p>
241 282
 					<label for="googlekey">Google API key</label>
242
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
283
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
284
+	print $globalGoogleAPIKey;
285
+}
286
+?>" />
243 287
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
244 288
 				</p>
245 289
 			</div>
@@ -247,7 +291,10 @@  discard block
 block discarded – undo
247 291
 			<div id="bing_data">
248 292
 				<p>
249 293
 					<label for="bingkey">Bing Map key</label>
250
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
294
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
295
+	print $globalBingMapKey;
296
+}
297
+?>" />
251 298
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
252 299
 				</p>
253 300
 			</div>
@@ -255,7 +302,10 @@  discard block
 block discarded – undo
255 302
 			<div id="mapquest_data">
256 303
 				<p>
257 304
 					<label for="mapquestkey">MapQuest key</label>
258
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
305
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
306
+	print $globalMapQuestKey;
307
+}
308
+?>" />
259 309
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
260 310
 				</p>
261 311
 			</div>
@@ -263,11 +313,17 @@  discard block
 block discarded – undo
263 313
 			<div id="here_data">
264 314
 				<p>
265 315
 					<label for="hereappid">Here App_Id</label>
266
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
316
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
317
+	print $globalHereappId;
318
+}
319
+?>" />
267 320
 				</p>
268 321
 				<p>
269 322
 					<label for="hereappcode">Here App_Code</label>
270
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
323
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
324
+	print $globalHereappCode;
325
+}
326
+?>" />
271 327
 				</p>
272 328
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
273 329
 			</div>
@@ -275,7 +331,10 @@  discard block
 block discarded – undo
275 331
 			<div id="openweathermap_data">
276 332
 				<p>
277 333
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
278
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
334
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
335
+	print $globalOpenWeatherMapKey;
336
+}
337
+?>" />
279 338
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
280 339
 				</p>
281 340
 			</div>
@@ -304,42 +363,86 @@  discard block
 block discarded – undo
304 363
 			<legend>Coverage area</legend>
305 364
 			<p>
306 365
 				<label for="latitudemax">The maximum latitude (north)</label>
307
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
366
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
367
+	print $globalLatitudeMax;
368
+}
369
+?>" />
308 370
 			</p>
309 371
 			<p>
310 372
 				<label for="latitudemin">The minimum latitude (south)</label>
311
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
373
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
374
+	print $globalLatitudeMin;
375
+}
376
+?>" />
312 377
 			</p>
313 378
 			<p>
314 379
 				<label for="longitudemax">The maximum longitude (west)</label>
315
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
380
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
381
+	print $globalLongitudeMax;
382
+}
383
+?>" />
316 384
 			</p>
317 385
 			<p>
318 386
 				<label for="longitudemin">The minimum longitude (east)</label>
319
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
387
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
388
+	print $globalLongitudeMin;
389
+}
390
+?>" />
320 391
 			</p>
321 392
 			<p>
322 393
 				<label for="latitudecenter">The latitude center</label>
323
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
394
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
395
+	print $globalCenterLatitude;
396
+}
397
+?>" />
324 398
 			</p>
325 399
 			<p>
326 400
 				<label for="longitudecenter">The longitude center</label>
327
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
401
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
402
+	print $globalCenterLongitude;
403
+}
404
+?>" />
328 405
 			</p>
329 406
 			<p>
330 407
 				<label for="livezoom">Default Zoom on live map</label>
331
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
408
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
409
+	print $globalLiveZoom;
410
+} else {
411
+	print '9';
412
+}
413
+?>" />
332 414
 			</p>
333 415
 			<p>
334 416
 				<label for="squawk_country">Country for squawk usage</label>
335 417
 				<select name="squawk_country" id="squawk_country">
336
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
337
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
338
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
339
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
340
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
341
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
342
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
418
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
419
+	print ' selected ';
420
+}
421
+?>>UK</option>
422
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
423
+	print ' selected ';
424
+}
425
+?>>NZ</option>
426
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
427
+	print ' selected ';
428
+}
429
+?>>US</option>
430
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
431
+	print ' selected ';
432
+}
433
+?>>AU</option>
434
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
435
+	print ' selected ';
436
+}
437
+?>>NL</option>
438
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
439
+	print ' selected ';
440
+}
441
+?>>FR</option>
442
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
443
+	print ' selected ';
444
+}
445
+?>>TR</option>
343 446
 				</select>
344 447
 			</p>
345 448
 		</fieldset>
@@ -348,15 +451,24 @@  discard block
 block discarded – undo
348 451
 			<p><i>Only put in DB flights that are inside a circle</i></p>
349 452
 			<p>
350 453
 				<label for="latitude">Center latitude</label>
351
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
454
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
455
+	echo $globalDistanceIgnore['latitude'];
456
+}
457
+?>" />
352 458
 			</p>
353 459
 			<p>
354 460
 				<label for="longitude">Center longitude</label>
355
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
461
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
462
+	echo $globalDistanceIgnore['longitude'];
463
+}
464
+?>" />
356 465
 			</p>
357 466
 			<p>
358 467
 				<label for="Distance">Distance (in km)</label>
359
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
468
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
469
+	echo $globalDistanceIgnore['distance'];
470
+}
471
+?>" />
360 472
 			</p>
361 473
 		</fieldset>
362 474
 		<fieldset id="sourceloc">
@@ -472,11 +584,17 @@  discard block
 block discarded – undo
472 584
 			<div id="flightaware_data">
473 585
 				<p>
474 586
 					<label for="flightawareusername">FlightAware username</label>
475
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
587
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
588
+	print $globalFlightAwareUsername;
589
+}
590
+?>" />
476 591
 				</p>
477 592
 				<p>
478 593
 					<label for="flightawarepassword">FlightAware password/API key</label>
479
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
594
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
595
+	print $globalFlightAwarePassword;
596
+}
597
+?>" />
480 598
 				</p>
481 599
 			</div>
482 600
 -->
@@ -518,7 +636,10 @@  discard block
 block discarded – undo
518 636
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
519 637
 								?>
520 638
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
521
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
639
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
640
+	print $source['port'];
641
+}
642
+?>" /></td>
522 643
 								<?php
523 644
 								    } else {
524 645
 									$hostport = explode(':',$source['host']);
@@ -537,35 +658,110 @@  discard block
 block discarded – undo
537 658
 								?>
538 659
 								<td>
539 660
 									<select name="format[]" id="format">
540
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
541
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
542
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
543
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
544
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
545
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
546
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
547
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
548
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
549
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
550
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
551
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
552
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
553
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
554
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
555
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
556
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
557
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
558
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
559
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
560
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
561
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
661
+										<option value="auto" <?php if (!isset($source['format'])) {
662
+	print 'selected';
663
+}
664
+?>>Auto</option>
665
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
666
+	print 'selected';
667
+}
668
+?>>SBS</option>
669
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
670
+	print 'selected';
671
+}
672
+?>>TSV</option>
673
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
674
+	print 'selected';
675
+}
676
+?>>Raw</option>
677
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
678
+	print 'selected';
679
+}
680
+?>>Dump1090 aircraft.json</option>
681
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
682
+	print 'selected';
683
+}
684
+?>>APRS</option>
685
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
686
+	print 'selected';
687
+}
688
+?>>Radarcape deltadb.txt</option>
689
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
690
+	print 'selected';
691
+}
692
+?>>Vatsim</option>
693
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
694
+	print 'selected';
695
+}
696
+?>>Virtual Radar Server AircraftList.json</option>
697
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
698
+	print 'selected';
699
+}
700
+?>>Virtual Radar Server TCP</option>
701
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
702
+	print 'selected';
703
+}
704
+?>>phpVMS</option>
705
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
706
+	print 'selected';
707
+}
708
+?>>Virtual Airline Operations System (VAOS)</option>
709
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
710
+	print 'selected';
711
+}
712
+?>>Virtual Airlines Manager</option>
713
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
714
+	print 'selected';
715
+}
716
+?>>IVAO</option>
717
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
718
+	print 'selected';
719
+}
720
+?>>FlightGear Multiplayer</option>
721
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
722
+	print 'selected';
723
+}
724
+?>>FlightGear Singleplayer</option>
725
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
726
+	print 'selected';
727
+}
728
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
729
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
730
+	print 'selected';
731
+}
732
+?>>ACARS SBS-3 over TCP</option>
733
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
734
+	print 'selected';
735
+}
736
+?>>NMEA AIS over TCP</option>
737
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
738
+	print 'selected';
739
+}
740
+?>>AirWhere website</option>
741
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
742
+	print 'selected';
743
+}
744
+?>>HidnSeek Callback</option>
745
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
746
+	print 'selected';
747
+}
748
+?>>Blitzortung</option>
562 749
 									</select>
563 750
 								</td>
564 751
 								<td>
565
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
752
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
753
+	print $source['name'];
754
+}
755
+?>" />
566 756
 								</td>
567
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
568
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
757
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
758
+	print 'checked';
759
+}
760
+?> /></td>
761
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
762
+	print 'checked';
763
+}
764
+?> /></td>
569 765
 								<td>
570 766
 									<select name="timezones[]" id="timezones">
571 767
 								<?php
@@ -575,7 +771,9 @@  discard block
 block discarded – undo
575 771
 											print '<option selected>'.$timezones.'</option>';
576 772
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
577 773
 											print '<option selected>'.$timezones.'</option>';
578
-										} else print '<option>'.$timezones.'</option>';
774
+										} else {
775
+											print '<option>'.$timezones.'</option>';
776
+										}
579 777
 									}
580 778
 								?>
581 779
 									</select>
@@ -627,7 +825,9 @@  discard block
 block discarded – undo
627 825
 									foreach($timezonelist as $timezones){
628 826
 										if ($timezones == 'UTC') {
629 827
 											print '<option selected>'.$timezones.'</option>';
630
-										} else print '<option>'.$timezones.'</option>';
828
+										} else {
829
+											print '<option>'.$timezones.'</option>';
830
+										}
631 831
 									}
632 832
 								?>
633 833
 									</select>
@@ -652,11 +852,17 @@  discard block
 block discarded – undo
652 852
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
653 853
 					<p>
654 854
 						<label for="acarshost">ACARS UDP host</label>
655
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
855
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
856
+	print $globalACARSHost;
857
+}
858
+?>" />
656 859
 					</p>
657 860
 					<p>
658 861
 						<label for="acarsport">ACARS UDP port</label>
659
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
862
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
863
+	print $globalACARSPort;
864
+}
865
+?>" />
660 866
 					</p>
661 867
 				</fieldset>
662 868
 			</div>
@@ -682,17 +888,38 @@  discard block
 block discarded – undo
682 888
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
683 889
 				    <td>
684 890
 					<select name="newslang[]">
685
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
686
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
891
+					    <option value="en"<?php if ($lng == 'en') {
892
+	print ' selected';
893
+}
894
+?>>English</option>
895
+					    <option value="fr"<?php if ($lng == 'fr') {
896
+	print ' selected';
897
+}
898
+?>>French</option>
687 899
 					</select>
688 900
 				    </td>
689 901
 				    <td>
690 902
 					<select name="newstype[]">
691
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
692
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
693
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
694
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
695
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
903
+					    <option value="global"<?php if ($type == 'global') {
904
+	print ' selected';
905
+}
906
+?>>Global</option>
907
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
908
+	print ' selected';
909
+}
910
+?>>Aircraft</option>
911
+					    <option value="marine"<?php if ($type == 'marine') {
912
+	print ' selected';
913
+}
914
+?>>Marine</option>
915
+					    <option value="tracker"<?php if ($type == 'tracker') {
916
+	print ' selected';
917
+}
918
+?>>Tracker</option>
919
+					    <option value="satellite"<?php if ($type == 'Satellite') {
920
+	print ' selected';
921
+}
922
+?>>Satellite</option>
696 923
 					</select>
697 924
 				    </td>
698 925
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -825,13 +1052,19 @@  discard block
 block discarded – undo
825 1052
 			<div id="schedules_options">
826 1053
 				<p>
827 1054
 					<label for="britishairways">British Airways API Key</label>
828
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1055
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
1056
+	print $globalBritishAirwaysKey;
1057
+}
1058
+?>" />
829 1059
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
830 1060
 				</p>
831 1061
 				<!--
832 1062
 				<p>
833 1063
 					<label for="transavia">Transavia Test API Consumer Key</label>
834
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1064
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1065
+	print $globalTransaviaKey;
1066
+}
1067
+?>" />
835 1068
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
836 1069
 				</p>
837 1070
 				-->
@@ -840,10 +1073,16 @@  discard block
 block discarded – undo
840 1073
 						<b>Lufthansa API Key</b>
841 1074
 						<p>
842 1075
 							<label for="lufthansakey">Key</label>
843
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1076
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1077
+	print $globalLufthansaKey['key'];
1078
+}
1079
+?>" />
844 1080
 						</p><p>
845 1081
 							<label for="lufthansasecret">Secret</label>
846
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1082
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1083
+	print $globalLufthansaKey['secret'];
1084
+}
1085
+?>" />
847 1086
 						</p>
848 1087
 					</div>
849 1088
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -853,11 +1092,17 @@  discard block
 block discarded – undo
853 1092
 						<b>FlightAware API Key</b>
854 1093
 						<p>
855 1094
 							<label for="flightawareusername">Username</label>
856
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1095
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1096
+	print $globalFlightAwareUsername;
1097
+}
1098
+?>" />
857 1099
 						</p>
858 1100
 						<p>
859 1101
 							<label for="flightawarepassword">API key</label>
860
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1102
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1103
+	print $globalFlightAwarePassword;
1104
+}
1105
+?>" />
861 1106
 						</p>
862 1107
 					</div>
863 1108
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -874,10 +1119,22 @@  discard block
 block discarded – undo
874 1119
 				<p>
875 1120
 					<label for="mapmatchingsource">Map Matching source</label>
876 1121
 					<select name="mapmatchingsource" id="mapmatchingsource">
877
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
878
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
879
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
880
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1122
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1123
+	print 'selected="selected" ';
1124
+}
1125
+?>>FlightAirMap Map Matching</option>
1126
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1127
+	print 'selected="selected" ';
1128
+}
1129
+?>>GraphHopper</option>
1130
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1131
+	print 'selected="selected" ';
1132
+}
1133
+?>>OSMR</option>
1134
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1135
+	print 'selected="selected" ';
1136
+}
1137
+?>>Mapbox</option>
881 1138
 					</select>
882 1139
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
883 1140
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -885,7 +1142,10 @@  discard block
 block discarded – undo
885 1142
 				<br />
886 1143
 				<p>
887 1144
 					<label for="graphhopper">GraphHopper API Key</label>
888
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1145
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1146
+	print $globalGraphHopperKey;
1147
+}
1148
+?>" />
889 1149
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
890 1150
 				</p>
891 1151
 			</div>
@@ -903,7 +1163,10 @@  discard block
 block discarded – undo
903 1163
 			</p>
904 1164
 			<p>
905 1165
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
906
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1166
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1167
+	print $globalNOTAMSource;
1168
+}
1169
+?>" />
907 1170
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
908 1171
 			</p>
909 1172
 			<br />
@@ -919,14 +1182,20 @@  discard block
 block discarded – undo
919 1182
 			<div id="metarsrc">
920 1183
 				<p>
921 1184
 					<label for="metarsource">URL of your METAR source</label>
922
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1185
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1186
+	print $globalMETARurl;
1187
+}
1188
+?>" />
923 1189
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
924 1190
 				</p>
925 1191
 			</div>
926 1192
 			<br />
927 1193
 			<p>
928 1194
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
929
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1195
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1196
+	print $globalBitlyAccessToken;
1197
+}
1198
+?>" />
930 1199
 			</p>
931 1200
 			<br />
932 1201
 			<p>
@@ -942,11 +1211,26 @@  discard block
 block discarded – undo
942 1211
 			<p>
943 1212
 				<label for="geoid_source">Geoid Source</label>
944 1213
 				<select name="geoid_source" id="geoid_source">
945
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
946
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
947
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
948
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
949
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1214
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1215
+	print ' selected="selected"';
1216
+}
1217
+?>>EGM96 15' (2.1MB)</option>
1218
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1219
+	print ' selected="selected"';
1220
+}
1221
+?>>EGM96 5' (19MB)</option>
1222
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1223
+	print ' selected="selected"';
1224
+}
1225
+?>>EGM2008 5' (19MB)</option>
1226
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1227
+	print ' selected="selected"';
1228
+}
1229
+?>>EGM2008 2.5' (75MB)</option>
1230
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1231
+	print ' selected="selected"';
1232
+}
1233
+?>>EGM2008 1' (470MB)</option>
950 1234
 				</select>
951 1235
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
952 1236
 			</p>
@@ -968,7 +1252,12 @@  discard block
 block discarded – undo
968 1252
 			</p>
969 1253
 			<p>
970 1254
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
971
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1255
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1256
+	print $globalArchiveMonths;
1257
+} else {
1258
+	echo '1';
1259
+}
1260
+?>" />
972 1261
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
973 1262
 			</p>
974 1263
 			<p>
@@ -978,12 +1267,22 @@  discard block
 block discarded – undo
978 1267
 			</p>
979 1268
 			<p>
980 1269
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
981
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1270
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1271
+	print $globalArchiveKeepMonths;
1272
+} else {
1273
+	echo '1';
1274
+}
1275
+?>" />
982 1276
 				<p class="help-block">0 to disable</p>
983 1277
 			</p>
984 1278
 			<p>
985 1279
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
986
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1280
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1281
+	print $globalArchiveKeepTrackMonths;
1282
+} else {
1283
+	echo '1';
1284
+}
1285
+?>" />
987 1286
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
988 1287
 			</p>
989 1288
 			<br />
@@ -993,7 +1292,12 @@  discard block
 block discarded – undo
993 1292
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
994 1293
 				<div id="cronends"> 
995 1294
 					<label for="cronend">Run script for xx seconds</label>
996
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1295
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1296
+	print $globalCronEnd;
1297
+} else {
1298
+	print '0';
1299
+}
1300
+?>" />
997 1301
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
998 1302
 				</div>
999 1303
 			</p>
@@ -1046,20 +1350,40 @@  discard block
 block discarded – undo
1046 1350
 			<br />
1047 1351
 			<p>
1048 1352
 				<label for="refresh">Show flights detected since xxx seconds</label>
1049
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1353
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1354
+	echo $globalLiveInterval;
1355
+} else {
1356
+	echo '200';
1357
+}
1358
+?>" />
1050 1359
 			</p>
1051 1360
 			<p>
1052 1361
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1053
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1362
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1363
+	echo $globalMapRefresh;
1364
+} else {
1365
+	echo '30';
1366
+}
1367
+?>" />
1054 1368
 			</p>
1055 1369
 			<p>
1056 1370
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1057
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1371
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1372
+	echo $globalMapIdleTimeout;
1373
+} else {
1374
+	echo '30';
1375
+}
1376
+?>" />
1058 1377
 				<p class="help-block">0 to disable</p>
1059 1378
 			</p>
1060 1379
 			<p>
1061 1380
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1062
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1381
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1382
+	echo $globalMinFetch;
1383
+} else {
1384
+	echo '20';
1385
+}
1386
+?>" />
1063 1387
 			</p>
1064 1388
 			<p>
1065 1389
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1073,12 +1397,20 @@  discard block
 block discarded – undo
1073 1397
 			<br />
1074 1398
 			<p>
1075 1399
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1076
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1400
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1401
+	echo $globalClosestMinDist;
1402
+} else {
1403
+	echo '50';
1404
+}
1405
+?>" />
1077 1406
 			</p>
1078 1407
 			<br />
1079 1408
 			<p>
1080 1409
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1081
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1410
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1411
+	echo $globalAircraftSize;
1412
+}
1413
+?>" />
1082 1414
 			</p>
1083 1415
 			<br />
1084 1416
 			<p>
@@ -1097,7 +1429,12 @@  discard block
 block discarded – undo
1097 1429
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
1098 1430
 			?>
1099 1431
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1100
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1432
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1433
+	echo $globalAircraftIconColor;
1434
+} else {
1435
+	echo '1a3151';
1436
+}
1437
+?>" />
1101 1438
 			<?php
1102 1439
 				if (!is_writable('../cache')) {
1103 1440
 			?>
@@ -1115,14 +1452,27 @@  discard block
 block discarded – undo
1115 1452
 			<p>
1116 1453
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1117 1454
 				<div class="range">
1118
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1119
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1455
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1456
+	echo $globalAirportZoom;
1457
+} else {
1458
+	echo '7';
1459
+}
1460
+?>" />
1461
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1462
+	echo $globalAirportZoom;
1463
+} else {
1464
+	echo '7';
1465
+}
1466
+?></output>
1120 1467
 				</div>
1121 1468
 			</p>
1122 1469
 			<br />
1123 1470
 			<p>
1124 1471
 				<label for="customcss">Custom CSS web path</label>
1125
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1472
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1473
+	echo $globalCustomCSS;
1474
+}
1475
+?>" />
1126 1476
 			</p>
1127 1477
 		</fieldset>
1128 1478
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1149,8 +1499,12 @@  discard block
 block discarded – undo
1149 1499
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1150 1500
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1151 1501
 
1152
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1153
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1502
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1503
+		$error .= 'Mysql driver for PDO must be loaded';
1504
+	}
1505
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1506
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1507
+	}
1154 1508
 	
1155 1509
 	$_SESSION['database_root'] = $dbroot;
1156 1510
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1218,15 +1572,23 @@  discard block
 block discarded – undo
1218 1572
 	$source_city = $_POST['source_city'];
1219 1573
 	$source_country = $_POST['source_country'];
1220 1574
 	$source_ref = $_POST['source_ref'];
1221
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1222
-	else $source_id = array();
1575
+	if (isset($source_id)) {
1576
+		$source_id = $_POST['source_id'];
1577
+	} else {
1578
+		$source_id = array();
1579
+	}
1223 1580
 	
1224 1581
 	$sources = array();
1225 1582
 	foreach ($source_name as $keys => $name) {
1226
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1227
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1583
+	    if (isset($source_id[$keys])) {
1584
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1585
+	    } else {
1586
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1587
+	    }
1588
+	}
1589
+	if (count($sources) > 0) {
1590
+		$_SESSION['sources'] = $sources;
1228 1591
 	}
1229
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1230 1592
 
1231 1593
 	$newsurl = $_POST['newsurl'];
1232 1594
 	$newslng = $_POST['newslang'];
@@ -1239,7 +1601,9 @@  discard block
 block discarded – undo
1239 1601
 		$lng = $newslng[$newskey];
1240 1602
 		if (isset($newsfeeds[$type][$lng])) {
1241 1603
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1242
-		} else $newsfeeds[$type][$lng] = array($url);
1604
+		} else {
1605
+			$newsfeeds[$type][$lng] = array($url);
1606
+		}
1243 1607
 	    }
1244 1608
 	}
1245 1609
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1263,17 +1627,29 @@  discard block
 block discarded – undo
1263 1627
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1264 1628
 
1265 1629
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1266
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1267
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1630
+	if ($globalaircraft == 'aircraft') {
1631
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1632
+	} else {
1633
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1634
+	}
1268 1635
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1269
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1270
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1636
+	if ($globaltracker == 'tracker') {
1637
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1638
+	} else {
1639
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1640
+	}
1271 1641
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1272
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1273
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1642
+	if ($globalmarine == 'marine') {
1643
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1644
+	} else {
1645
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1646
+	}
1274 1647
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1275
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1276
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1648
+	if ($globalsatellite == 'satellite') {
1649
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1650
+	} else {
1651
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1652
+	}
1277 1653
 
1278 1654
 /*	
1279 1655
 	$globalSBS1Hosts = array();
@@ -1295,23 +1671,37 @@  discard block
 block discarded – undo
1295 1671
 	$name = $_POST['name'];
1296 1672
 	$format = $_POST['format'];
1297 1673
 	$timezones = $_POST['timezones'];
1298
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1299
-	else $sourcestats = array();
1300
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1301
-	else $noarchive = array();
1674
+	if (isset($_POST['sourcestats'])) {
1675
+		$sourcestats = $_POST['sourcestats'];
1676
+	} else {
1677
+		$sourcestats = array();
1678
+	}
1679
+	if (isset($_POST['noarchive'])) {
1680
+		$noarchive = $_POST['noarchive'];
1681
+	} else {
1682
+		$noarchive = array();
1683
+	}
1302 1684
 	$gSources = array();
1303 1685
 	$forcepilots = false;
1304 1686
 	foreach ($host as $key => $h) {
1305
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1306
-		else $cov = 'FALSE';
1307
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1308
-		else $arch = 'FALSE';
1687
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1688
+			$cov = 'TRUE';
1689
+		} else {
1690
+			$cov = 'FALSE';
1691
+		}
1692
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1693
+			$arch = 'TRUE';
1694
+		} else {
1695
+			$arch = 'FALSE';
1696
+		}
1309 1697
 		if (strpos($format[$key],'_callback')) {
1310 1698
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1311 1699
 		} elseif ($h != '' || $name[$key] != '') {
1312 1700
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1313 1701
 		}
1314
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1702
+		if ($format[$key] == 'airwhere') {
1703
+			$forcepilots = true;
1704
+		}
1315 1705
 	}
1316 1706
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1317 1707
 
@@ -1342,7 +1732,9 @@  discard block
 block discarded – undo
1342 1732
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1343 1733
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1344 1734
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1345
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1735
+	} else {
1736
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1737
+	}
1346 1738
 
1347 1739
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1348 1740
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1383,7 +1775,9 @@  discard block
 block discarded – undo
1383 1775
 
1384 1776
 	// Create in settings.php keys not yet configurable if not already here
1385 1777
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1386
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1778
+	if (!isset($globalDebug)) {
1779
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1780
+	}
1387 1781
 
1388 1782
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1389 1783
 	if ($resetyearstats == 'resetyearstats') {
@@ -1426,37 +1820,56 @@  discard block
 block discarded – undo
1426 1820
 	}
1427 1821
 */
1428 1822
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1429
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1430
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1431
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1432
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1823
+	if ($globalsbs == 'sbs') {
1824
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1825
+	} else {
1826
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1827
+	}
1828
+	if ($globalaprs == 'aprs') {
1829
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1830
+	} else {
1831
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1832
+	}
1433 1833
 	$va = false;
1434 1834
 	if ($globalivao == 'ivao') {
1435 1835
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1436 1836
 		$va = true;
1437
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1837
+	} else {
1838
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1839
+	}
1438 1840
 	if ($globalvatsim == 'vatsim') {
1439 1841
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1440 1842
 		$va = true;
1441
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1843
+	} else {
1844
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1845
+	}
1442 1846
 	if ($globalphpvms == 'phpvms') {
1443 1847
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1444 1848
 		$va = true;
1445
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1849
+	} else {
1850
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1851
+	}
1446 1852
 	if ($globalvam == 'vam') {
1447 1853
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1448 1854
 		$va = true;
1449
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1855
+	} else {
1856
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1857
+	}
1450 1858
 	if ($va) {
1451 1859
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1452
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1860
+	} else {
1861
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1862
+	}
1453 1863
 	if ($globalva == 'va' || $va) {
1454 1864
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1455 1865
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1456 1866
 	} else {
1457 1867
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1458
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1459
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1868
+		if ($forcepilots) {
1869
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1870
+		} else {
1871
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1872
+		}
1460 1873
 	}
1461 1874
 	
1462 1875
 	
@@ -1679,7 +2092,9 @@  discard block
 block discarded – undo
1679 2092
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1680 2093
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1681 2094
 
1682
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2095
+	if (!isset($globalTransaction)) {
2096
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2097
+	}
1683 2098
 
1684 2099
 	// Set some defaults values...
1685 2100
 	if (!isset($globalAircraftImageSources)) {
@@ -1694,15 +2109,23 @@  discard block
 block discarded – undo
1694 2109
 
1695 2110
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1696 2111
 
1697
-	if ($error == '') settings::modify_settings($settings);
1698
-	if ($error == '') settings::comment_settings($settings_comment);
2112
+	if ($error == '') {
2113
+		settings::modify_settings($settings);
2114
+	}
2115
+	if ($error == '') {
2116
+		settings::comment_settings($settings_comment);
2117
+	}
1699 2118
 	if ($error != '') {
1700 2119
 		print '<div class="info column">'.$error.'</div>';
1701 2120
 		require('../footer.php');
1702 2121
 		exit;
1703 2122
 	} else {
1704
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1705
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2123
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2124
+			$_SESSION['waypoints'] = 1;
2125
+		}
2126
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2127
+			$_SESSION['owner'] = 1;
2128
+		}
1706 2129
 		if (isset($_POST['createdb'])) {
1707 2130
 			$_SESSION['install'] = 'database_create';
1708 2131
 		} else {
@@ -1739,10 +2162,18 @@  discard block
 block discarded – undo
1739 2162
 	$popw = false;
1740 2163
 	foreach ($_SESSION['done'] as $done) {
1741 2164
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1742
-	    if ($done == 'Create database') $pop = true;
1743
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1744
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1745
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2165
+	    if ($done == 'Create database') {
2166
+	    	$pop = true;
2167
+	    }
2168
+	    if ($_SESSION['install'] == 'database_create') {
2169
+	    	$pop = true;
2170
+	    }
2171
+	    if ($_SESSION['install'] == 'database_import') {
2172
+	    	$popi = true;
2173
+	    }
2174
+	    if ($_SESSION['install'] == 'waypoints') {
2175
+	    	$popw = true;
2176
+	    }
1746 2177
 	}
1747 2178
 	if ($pop) {
1748 2179
 	    sleep(5);
@@ -1753,7 +2184,9 @@  discard block
 block discarded – undo
1753 2184
 	} else if ($popw) {
1754 2185
 	    sleep(5);
1755 2186
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1756
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2187
+	} else {
2188
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2189
+	}
1757 2190
 	print '</div></ul>';
1758 2191
 	print '<div id="error"></div>';
1759 2192
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
Spacing   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 require_once(dirname(__FILE__).'/class.create_db.php');
23 23
 require_once(dirname(__FILE__).'/class.update_schema.php');
24 24
 require_once(dirname(__FILE__).'/class.settings.php');
25
-$title="Install";
25
+$title = "Install";
26 26
 require(dirname(__FILE__).'/../require/settings.php');
27 27
 require_once(dirname(__FILE__).'/../require/class.Common.php');
28 28
 require(dirname(__FILE__).'/header.php');
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 	if (!extension_loaded('curl')) {
96 96
 		$error[] = "Curl is not loaded.";
97 97
 	}
98
-	if(function_exists('apache_get_modules') ){
99
-		if(!in_array('mod_rewrite',apache_get_modules())) {
98
+	if (function_exists('apache_get_modules')) {
99
+		if (!in_array('mod_rewrite', apache_get_modules())) {
100 100
 			$error[] = "mod_rewrite is not available.";
101 101
 		}
102 102
 	/*
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 	if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
114 114
 		if (function_exists('get_headers')) {
115 115
 			//$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
116
-			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'live/geojson?test',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
117
-			if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
116
+			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'live/geojson?test', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
117
+			if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
118 118
 				print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
119 119
 			} else {
120
-				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
121
-				if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
120
+				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'search', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
121
+				if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
122 122
 					print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
123 123
 				}
124 124
 			}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
199 199
 					if (isset($_SERVER['REQUEST_URI'])) {
200 200
 						$URL = $_SERVER['REQUEST_URI'];
201
-						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
201
+						$globalURL = str_replace('/install', '', str_replace('/install/', '', str_replace('/install/index.php', '', $URL)));
202 202
 					}
203 203
 				    }
204 204
 				?>
@@ -521,13 +521,13 @@  discard block
 block discarded – undo
521 521
 ?>
522 522
 							<tr>
523 523
 								<?php
524
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
524
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
525 525
 								?>
526 526
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
527 527
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
528 528
 								<?php
529 529
 								    } else {
530
-									$hostport = explode(':',$source['host']);
530
+									$hostport = explode(':', $source['host']);
531 531
 									if (isset($hostport[1])) {
532 532
 										$host = $hostport[0];
533 533
 										$port = $hostport[1];
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 									<select name="timezones[]" id="timezones">
577 577
 								<?php
578 578
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
579
-									foreach($timezonelist as $timezones){
579
+									foreach ($timezonelist as $timezones) {
580 580
 										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
581 581
 											print '<option selected>'.$timezones.'</option>';
582 582
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 									<select name="timezones[]" id="timezones">
631 631
 								<?php
632 632
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
633
-									foreach($timezonelist as $timezones){
633
+									foreach ($timezonelist as $timezones) {
634 634
 										if ($timezones == 'UTC') {
635 635
 											print '<option selected>'.$timezones.'</option>';
636 636
 										} else print '<option>'.$timezones.'</option>';
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 			<br />
1085 1085
 			<p>
1086 1086
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1087
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1087
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
1088 1088
 			</p>
1089 1089
 			<br />
1090 1090
 			<p>
@@ -1146,14 +1146,14 @@  discard block
 block discarded – undo
1146 1146
 $error = '';
1147 1147
 
1148 1148
 if (isset($_POST['dbtype'])) {
1149
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
1150
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
1151
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
1152
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
1153
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
1154
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
1155
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1156
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1149
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
1150
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
1151
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
1152
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
1153
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
1154
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
1155
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
1156
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
1157 1157
 
1158 1158
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1159 1159
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -1173,49 +1173,49 @@  discard block
 block discarded – undo
1173 1173
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1174 1174
 	*/
1175 1175
 	
1176
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1176
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
1177 1177
 
1178
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
1179
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
1180
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
1181
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
1182
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
1178
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
1179
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
1180
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
1181
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
1182
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
1183 1183
 
1184
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
1185
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
1186
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
1187
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
1188
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
1189
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
1190
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
1191
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
1192
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
1193
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
1184
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
1185
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
1186
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
1187
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
1188
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
1189
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
1190
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
1191
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
1192
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
1193
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
1194 1194
 	
1195
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
1196
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
1197
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
1198
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
1199
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
1200
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
1195
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
1196
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
1197
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
1198
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
1199
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
1200
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
1201 1201
 
1202
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
1203
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
1202
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
1203
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
1204 1204
 
1205
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
1206
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
1207
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
1205
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
1206
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
1207
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
1208 1208
 
1209
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
1209
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
1210 1210
 	if ($acars == 'acars') {
1211
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
1211
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
1212 1212
 	} else {
1213
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
1213
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
1214 1214
 	}
1215 1215
 
1216
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1217
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1218
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1216
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
1217
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
1218
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
1219 1219
 	
1220 1220
 	$source_name = $_POST['source_name'];
1221 1221
 	$source_latitude = $_POST['source_latitude'];
@@ -1229,8 +1229,8 @@  discard block
 block discarded – undo
1229 1229
 	
1230 1230
 	$sources = array();
1231 1231
 	foreach ($source_name as $keys => $name) {
1232
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1233
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1232
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
1233
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
1234 1234
 	}
1235 1235
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1236 1236
 
@@ -1239,16 +1239,16 @@  discard block
 block discarded – undo
1239 1239
 	$newstype = $_POST['newstype'];
1240 1240
 	
1241 1241
 	$newsfeeds = array();
1242
-	foreach($newsurl as $newskey => $url) {
1242
+	foreach ($newsurl as $newskey => $url) {
1243 1243
 	    if ($url != '') {
1244 1244
 		$type = $newstype[$newskey];
1245 1245
 		$lng = $newslng[$newskey];
1246 1246
 		if (isset($newsfeeds[$type][$lng])) {
1247
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1247
+		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng], array($url));
1248 1248
 		} else $newsfeeds[$type][$lng] = array($url);
1249 1249
 	    }
1250 1250
 	}
1251
-	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1251
+	$settings = array_merge($settings, array('globalNewsFeeds' => $newsfeeds));
1252 1252
 
1253 1253
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1254 1254
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1259,27 +1259,27 @@  discard block
 block discarded – undo
1259 1259
 	$sbsurl = $_POST['sbsurl'];
1260 1260
 	*/
1261 1261
 
1262
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1263
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1264
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1265
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1266
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1267
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1268
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1269
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1262
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1263
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1264
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1265
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1266
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1267
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1268
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1269
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1270 1270
 
1271
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1272
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1273
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1274
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1275
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1276
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1277
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1278
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1279
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1280
-	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1281
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1282
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1271
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1272
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1273
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1274
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1275
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1276
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1277
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1278
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1279
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1280
+	$globalsatellite = filter_input(INPUT_POST, 'globalsatellite', FILTER_SANITIZE_STRING);
1281
+	if ($globalsatellite == 'satellite') $settings = array_merge($settings, array('globalSatellite' => 'TRUE'));
1282
+	else $settings = array_merge($settings, array('globalSatellite' => 'FALSE'));
1283 1283
 
1284 1284
 /*	
1285 1285
 	$globalSBS1Hosts = array();
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
 	}
1296 1296
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1297 1297
 */
1298
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1298
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1299 1299
 	$host = $_POST['host'];
1300 1300
 	$port = $_POST['port'];
1301 1301
 	$name = $_POST['name'];
@@ -1312,115 +1312,115 @@  discard block
 block discarded – undo
1312 1312
 		else $cov = 'FALSE';
1313 1313
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1314 1314
 		else $arch = 'FALSE';
1315
-		if (strpos($format[$key],'_callback')) {
1316
-			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1315
+		if (strpos($format[$key], '_callback')) {
1316
+			$gSources[] = array('host' => $h, 'pass' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'TRUE');
1317 1317
 		} elseif ($h != '' || $name[$key] != '') {
1318
-			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1318
+			$gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'FALSE');
1319 1319
 		}
1320 1320
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1321 1321
 	}
1322
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1322
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1323 1323
 
1324 1324
 /*
1325 1325
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1326 1326
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1327 1327
 */
1328
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1329
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1330
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1328
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1329
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1330
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1331 1331
 
1332
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1333
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1332
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1333
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1334 1334
 
1335
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1336
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1335
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1336
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1337 1337
 
1338
-	$map3dtile = filter_input(INPUT_POST,'map3dtileset',FILTER_SANITIZE_STRING);
1339
-	$settings = array_merge($settings,array('globalMap3DTiles' => $map3dtile));
1338
+	$map3dtile = filter_input(INPUT_POST, 'map3dtileset', FILTER_SANITIZE_STRING);
1339
+	$settings = array_merge($settings, array('globalMap3DTiles' => $map3dtile));
1340 1340
 
1341
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1342
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1343
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1344
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1341
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1342
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1343
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1344
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1345 1345
 
1346
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1347
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1348
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1346
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1347
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1348
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1349 1349
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1350
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1351
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1350
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1351
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1352 1352
 
1353
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1354
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1355
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1356
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1357
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1358
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1359
-	$minfetch = filter_input(INPUT_POST,'minfetch',FILTER_SANITIZE_NUMBER_INT);
1360
-	$settings = array_merge($settings,array('globalMinFetch' => $minfetch));
1361
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1362
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1353
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1354
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1355
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1356
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1357
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1358
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1359
+	$minfetch = filter_input(INPUT_POST, 'minfetch', FILTER_SANITIZE_NUMBER_INT);
1360
+	$settings = array_merge($settings, array('globalMinFetch' => $minfetch));
1361
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1362
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1363 1363
 
1364
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1365
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1364
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1365
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1366 1366
 
1367
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1368
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1367
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1368
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1369 1369
 	
1370
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1370
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1371 1371
 	if ($archiveyear == "archiveyear") {
1372
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1372
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1373 1373
 	} else {
1374
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1374
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1375 1375
 	}
1376
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1377
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1378
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1379
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1376
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1377
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1378
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1379
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1380 1380
 
1381
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1382
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1383
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1384
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1381
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1382
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1383
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1384
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1385 1385
 
1386
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1387
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1388
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1386
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1387
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1388
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1389 1389
 
1390 1390
 	// Create in settings.php keys not yet configurable if not already here
1391 1391
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1392
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1392
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1393 1393
 
1394
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1394
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1395 1395
 	if ($resetyearstats == 'resetyearstats') {
1396
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1396
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1397 1397
 	} else {
1398
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1398
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1399 1399
 	}
1400 1400
 
1401
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1401
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1402 1402
 	if ($archive == 'archive') {
1403
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1403
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1404 1404
 	} else {
1405
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1405
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1406 1406
 	}
1407
-	$archiveresults = filter_input(INPUT_POST,'archiveresults',FILTER_SANITIZE_STRING);
1407
+	$archiveresults = filter_input(INPUT_POST, 'archiveresults', FILTER_SANITIZE_STRING);
1408 1408
 	if ($archiveresults == 'archiveresults') {
1409
-		$settings = array_merge($settings,array('globalArchiveResults' => 'TRUE'));
1409
+		$settings = array_merge($settings, array('globalArchiveResults' => 'TRUE'));
1410 1410
 	} else {
1411
-		$settings = array_merge($settings,array('globalArchiveResults' => 'FALSE'));
1411
+		$settings = array_merge($settings, array('globalArchiveResults' => 'FALSE'));
1412 1412
 	}
1413
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1413
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1414 1414
 	if ($daemon == 'daemon') {
1415
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1415
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1416 1416
 	} else {
1417
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1417
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1418 1418
 	}
1419
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1419
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1420 1420
 	if ($schedules == 'schedules') {
1421
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1421
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1422 1422
 	} else {
1423
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1423
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1424 1424
 	}
1425 1425
 
1426 1426
 /*
@@ -1431,274 +1431,274 @@  discard block
 block discarded – undo
1431 1431
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1432 1432
 	}
1433 1433
 */
1434
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1435
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1436
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1437
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1438
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1434
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1435
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1436
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1437
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1438
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1439 1439
 	$va = false;
1440 1440
 	if ($globalivao == 'ivao') {
1441
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1441
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1442 1442
 		$va = true;
1443
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1443
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1444 1444
 	if ($globalvatsim == 'vatsim') {
1445
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1445
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1446 1446
 		$va = true;
1447
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1447
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1448 1448
 	if ($globalphpvms == 'phpvms') {
1449
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1449
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1450 1450
 		$va = true;
1451
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1451
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1452 1452
 	if ($globalvam == 'vam') {
1453
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1453
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1454 1454
 		$va = true;
1455
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1455
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1456 1456
 	if ($va) {
1457
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1458
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1457
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1458
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1459 1459
 	if ($globalva == 'va' || $va) {
1460
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1461
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1460
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1461
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1462 1462
 	} else {
1463
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1464
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1465
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1463
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1464
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1465
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1466 1466
 	}
1467 1467
 	
1468 1468
 	
1469
-	$mapoffline = filter_input(INPUT_POST,'mapoffline',FILTER_SANITIZE_STRING);
1469
+	$mapoffline = filter_input(INPUT_POST, 'mapoffline', FILTER_SANITIZE_STRING);
1470 1470
 	if ($mapoffline == 'mapoffline') {
1471
-		$settings = array_merge($settings,array('globalMapOffline' => 'TRUE'));
1471
+		$settings = array_merge($settings, array('globalMapOffline' => 'TRUE'));
1472 1472
 	} else {
1473
-		$settings = array_merge($settings,array('globalMapOffline' => 'FALSE'));
1473
+		$settings = array_merge($settings, array('globalMapOffline' => 'FALSE'));
1474 1474
 	}
1475
-	$globaloffline = filter_input(INPUT_POST,'globaloffline',FILTER_SANITIZE_STRING);
1475
+	$globaloffline = filter_input(INPUT_POST, 'globaloffline', FILTER_SANITIZE_STRING);
1476 1476
 	if ($globaloffline == 'globaloffline') {
1477
-		$settings = array_merge($settings,array('globalOffline' => 'TRUE'));
1477
+		$settings = array_merge($settings, array('globalOffline' => 'TRUE'));
1478 1478
 	} else {
1479
-		$settings = array_merge($settings,array('globalOffline' => 'FALSE'));
1479
+		$settings = array_merge($settings, array('globalOffline' => 'FALSE'));
1480 1480
 	}
1481 1481
 
1482
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1482
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1483 1483
 	if ($notam == 'notam') {
1484
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1484
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1485 1485
 	} else {
1486
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1486
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1487 1487
 	}
1488
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1488
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1489 1489
 	if ($owner == 'owner') {
1490
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1490
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1491 1491
 	} else {
1492
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1492
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1493 1493
 	}
1494
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1494
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1495 1495
 	if ($map3d == 'map3d') {
1496
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1496
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1497 1497
 	} else {
1498
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1498
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1499 1499
 	}
1500
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1500
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1501 1501
 	if ($crash == 'crash') {
1502
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1502
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1503 1503
 	} else {
1504
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1504
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1505 1505
 	}
1506
-	$fires = filter_input(INPUT_POST,'fires',FILTER_SANITIZE_STRING);
1506
+	$fires = filter_input(INPUT_POST, 'fires', FILTER_SANITIZE_STRING);
1507 1507
 	if ($fires == 'fires') {
1508
-		$settings = array_merge($settings,array('globalMapFires' => 'TRUE'));
1508
+		$settings = array_merge($settings, array('globalMapFires' => 'TRUE'));
1509 1509
 	} else {
1510
-		$settings = array_merge($settings,array('globalMapFires' => 'FALSE'));
1510
+		$settings = array_merge($settings, array('globalMapFires' => 'FALSE'));
1511 1511
 	}
1512
-	$firessupport = filter_input(INPUT_POST,'firessupport',FILTER_SANITIZE_STRING);
1512
+	$firessupport = filter_input(INPUT_POST, 'firessupport', FILTER_SANITIZE_STRING);
1513 1513
 	if ($firessupport == 'firessupport') {
1514
-		$settings = array_merge($settings,array('globalFires' => 'TRUE'));
1514
+		$settings = array_merge($settings, array('globalFires' => 'TRUE'));
1515 1515
 	} else {
1516
-		$settings = array_merge($settings,array('globalFires' => 'FALSE'));
1516
+		$settings = array_merge($settings, array('globalFires' => 'FALSE'));
1517 1517
 	}
1518
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1518
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1519 1519
 	if ($mapsatellites == 'mapsatellites') {
1520
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1520
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1521 1521
 	} else {
1522
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1522
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1523 1523
 	}
1524
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1524
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1525 1525
 	if ($map3ddefault == 'map3ddefault') {
1526
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1526
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1527 1527
 	} else {
1528
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1528
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1529 1529
 	}
1530
-	$map3dliveries = filter_input(INPUT_POST,'map3dliveries',FILTER_SANITIZE_STRING);
1530
+	$map3dliveries = filter_input(INPUT_POST, 'map3dliveries', FILTER_SANITIZE_STRING);
1531 1531
 	if ($map3dliveries == 'map3dliveries') {
1532
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'TRUE'));
1532
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'TRUE'));
1533 1533
 	} else {
1534
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'FALSE'));
1534
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'FALSE'));
1535 1535
 	}
1536
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1536
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1537 1537
 	if ($translate == 'translate') {
1538
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1538
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1539 1539
 	} else {
1540
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1540
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1541 1541
 	}
1542
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1542
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1543 1543
 	if ($realairlines == 'realairlines') {
1544
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1544
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1545 1545
 	} else {
1546
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1546
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1547 1547
 	}
1548
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1548
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1549 1549
 	if ($estimation == 'estimation') {
1550
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1550
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1551 1551
 	} else {
1552
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1552
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1553 1553
 	}
1554
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1554
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1555 1555
 	if ($metar == 'metar') {
1556
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1556
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1557 1557
 	} else {
1558
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1558
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1559 1559
 	}
1560
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1560
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1561 1561
 	if ($metarcycle == 'metarcycle') {
1562
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1562
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1563 1563
 	} else {
1564
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1564
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1565 1565
 	}
1566
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1566
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1567 1567
 	if ($fork == 'fork') {
1568
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1568
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1569 1569
 	} else {
1570
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1570
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1571 1571
 	}
1572 1572
 
1573
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1573
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1574 1574
 	if ($colormap == 'colormap') {
1575
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1575
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1576 1576
 	} else {
1577
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1577
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1578 1578
 	}
1579 1579
 	
1580 1580
 	if (isset($_POST['aircrafticoncolor'])) {
1581
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1582
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1581
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1582
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1583 1583
 	}
1584 1584
 
1585
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1586
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1585
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1586
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1587 1587
 
1588
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1589
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1590
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1591
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1592
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1593
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1588
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1589
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1590
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1591
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1592
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1593
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1594 1594
 
1595
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1595
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1596 1596
 	if ($mappopup == 'mappopup') {
1597
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1597
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1598 1598
 	} else {
1599
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1599
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1600 1600
 	}
1601
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1601
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1602 1602
 	if ($airportpopup == 'airportpopup') {
1603
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1603
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1604 1604
 	} else {
1605
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1605
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1606 1606
 	}
1607
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1607
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1608 1608
 	if ($maphistory == 'maphistory') {
1609
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1609
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1610 1610
 	} else {
1611
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1611
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1612 1612
 	}
1613
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1613
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1614 1614
 	if ($maptooltip == 'maptooltip') {
1615
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1615
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1616 1616
 	} else {
1617
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1617
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1618 1618
 	}
1619
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1619
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1620 1620
 	if ($flightroute == 'flightroute') {
1621
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1621
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1622 1622
 	} else {
1623
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1623
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1624 1624
 	}
1625
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1625
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1626 1626
 	if ($flightremainingroute == 'flightremainingroute') {
1627
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1627
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1628 1628
 	} else {
1629
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1629
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1630 1630
 	}
1631
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1631
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1632 1632
 	if ($allflights == 'allflights') {
1633
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1633
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1634 1634
 	} else {
1635
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1635
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1636 1636
 	}
1637
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1637
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1638 1638
 	if ($bbox == 'bbox') {
1639
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1639
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1640 1640
 	} else {
1641
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1641
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1642 1642
 	}
1643
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1643
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1644 1644
 	if ($groundaltitude == 'groundaltitude') {
1645
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1645
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1646 1646
 	} else {
1647
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1647
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1648 1648
 	}
1649
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1649
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1650 1650
 	if ($waypoints == 'waypoints') {
1651
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1651
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1652 1652
 	} else {
1653
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1653
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1654 1654
 	}
1655
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1655
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1656 1656
 	if ($geoid == 'geoid') {
1657
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1657
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1658 1658
 	} else {
1659
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1659
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1660 1660
 	}
1661
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1662
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1661
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1662
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1663 1663
 
1664
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1664
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1665 1665
 	if ($noairlines == 'noairlines') {
1666
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1666
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1667 1667
 	} else {
1668
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1668
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1669 1669
 	}
1670 1670
 
1671
-	$tsk = filter_input(INPUT_POST,'tsk',FILTER_SANITIZE_STRING);
1671
+	$tsk = filter_input(INPUT_POST, 'tsk', FILTER_SANITIZE_STRING);
1672 1672
 	if ($tsk == 'tsk') {
1673
-		$settings = array_merge($settings,array('globalTSK' => 'TRUE'));
1673
+		$settings = array_merge($settings, array('globalTSK' => 'TRUE'));
1674 1674
 	} else {
1675
-		$settings = array_merge($settings,array('globalTSK' => 'FALSE'));
1675
+		$settings = array_merge($settings, array('globalTSK' => 'FALSE'));
1676 1676
 	}
1677
-	$mapmatching = filter_input(INPUT_POST,'mapmatching',FILTER_SANITIZE_STRING);
1677
+	$mapmatching = filter_input(INPUT_POST, 'mapmatching', FILTER_SANITIZE_STRING);
1678 1678
 	if ($mapmatching == 'mapmatching') {
1679
-		$settings = array_merge($settings,array('globalMapMatching' => 'TRUE'));
1679
+		$settings = array_merge($settings, array('globalMapMatching' => 'TRUE'));
1680 1680
 	} else {
1681
-		$settings = array_merge($settings,array('globalMapMatching' => 'FALSE'));
1681
+		$settings = array_merge($settings, array('globalMapMatching' => 'FALSE'));
1682 1682
 	}
1683
-	$mapmatchingsource = filter_input(INPUT_POST,'mapmatchingsource',FILTER_SANITIZE_STRING);
1684
-	$settings = array_merge($settings,array('globalMapMatchingSource' => $mapmatchingsource));
1685
-	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1686
-	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1683
+	$mapmatchingsource = filter_input(INPUT_POST, 'mapmatchingsource', FILTER_SANITIZE_STRING);
1684
+	$settings = array_merge($settings, array('globalMapMatchingSource' => $mapmatchingsource));
1685
+	$graphhopper = filter_input(INPUT_POST, 'graphhopper', FILTER_SANITIZE_STRING);
1686
+	$settings = array_merge($settings, array('globalGraphHopperKey' => $graphhopper));
1687 1687
 
1688
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1688
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1689 1689
 
1690 1690
 	// Set some defaults values...
1691 1691
 	if (!isset($globalAircraftImageSources)) {
1692
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1693
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1692
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1693
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1694 1694
 	}
1695 1695
 
1696 1696
 	if (!isset($globalSchedulesSources)) {
1697
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1698
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1697
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1698
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1699 1699
     	}
1700 1700
 
1701
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1701
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1702 1702
 
1703 1703
 	if ($error == '') settings::modify_settings($settings);
1704 1704
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
require/class.TrackerImport.php 3 patches
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
47
+		if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49
-    		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
-            }
49
+			$Tracker = new Tracker($this->db);
50
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 72
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
181
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
@@ -223,131 +223,131 @@  discard block
 block discarded – undo
223 223
 				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
-		    //$dataFound = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
+			//$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
-		    //$dataFound = true;
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
+			//$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249 249
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
-		    //$dataFound = true;
261
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
+			//$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
266
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} else $recent_ident = '';
288 288
 				$TrackerLive->db=null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292
-			    } else {
292
+				} else {
293 293
 				$recent_ident = '';
294 294
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
295
-			    }
296
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
298
-			    {
295
+				}
296
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
+				if($recent_ident == "")
298
+				{
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301
-				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
-				    $timeelapsed = microtime(true);
304
-				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
-				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+					$highlight = '';
302
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
+					$timeelapsed = microtime(true);
304
+					$Tracker = new Tracker($this->db);
305
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
+					$Tracker->db = null;
307
+					if ($globalDebug && isset($result)) echo $result."\n";
308
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309 309
 				    
310 310
 				    
311
-				    // Add source stat in DB
312
-				    $Stats = new Stats($this->db);
313
-				    if (!empty($this->stats)) {
311
+					// Add source stat in DB
312
+					$Stats = new Stats($this->db);
313
+					if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
317
-					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
-				    		if (isset($sourced['msg'])) {
321
-				    		    if (time() - $sourced['msg']['date'] > 10) {
322
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
-			    			        unset($this->stats[$date][$source]['msg']);
325
-			    			    }
326
-			    			}
327
-			    		    }
328
-			    		    if ($date != date('Y-m-d')) {
329
-			    			unset($this->stats[$date]);
330
-			    		    }
331
-				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
315
+						foreach($this->stats as $date => $data) {
316
+						foreach($data as $source => $sourced) {
317
+							//print_r($sourced);
318
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
+							if (isset($sourced['msg'])) {
321
+								if (time() - $sourced['msg']['date'] > 10) {
322
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
+									unset($this->stats[$date][$source]['msg']);
325
+								}
326
+							}
327
+							}
328
+							if ($date != date('Y-m-d')) {
329
+							unset($this->stats[$date]);
330
+							}
331
+						}
332
+						if ($globalDebug) echo 'Done'."\n";
333 333
 
334
-				    }
335
-				    $Stats->db = null;
334
+					}
335
+					$Stats->db = null;
336 336
 				    
337
-				    $this->del();
337
+					$this->del();
338 338
 				//$ignoreImport = false;
339 339
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 340
 				//print_r($this->all_tracked[$id]);
341 341
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344
-				    $TrackerLive = new TrackerLive($this->db);
345
-				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
348
-				    $this->last_delete = time();
342
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
344
+					$TrackerLive = new TrackerLive($this->db);
345
+					$TrackerLive->deleteLiveTrackerData();
346
+					$TrackerLive->db=null;
347
+					if ($globalDebug) echo " Done\n";
348
+					$this->last_delete = time();
349 349
 				}
350
-			    } else {
350
+				} else {
351 351
 				$this->all_tracked[$id]['id'] = $recent_ident;
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
359
-			    }
359
+				}
360 360
 			}
361
-		    }
362
-		    //adds the spotter LIVE data
363
-		    if ($globalDebug) {
361
+			}
362
+			//adds the spotter LIVE data
363
+			if ($globalDebug) {
364 364
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
365
-		    }
366
-		    $ignoreImport = false;
365
+			}
366
+			$ignoreImport = false;
367 367
 
368
-		    if (!$ignoreImport) {
368
+			if (!$ignoreImport) {
369 369
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 405
 						for ($i=0;$i<=15;$i++) {
406
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
406
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
409 409
 					} else {
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 					//var_dump($this->stats);
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419
-						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
+							end($this->stats[$current_date][$source]['hist']);
420
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
421 421
 						} else $mini = 0;
422 422
 						for ($i=$mini;$i<=$distance;$i+=10) {
423
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
423
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
426 426
 					} else {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115 115
 		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
119 119
 		    if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
122
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
123 123
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
127 127
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
129 129
 		    } else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133 133
 		    }
134
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
181
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'], 0.08)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,75 +197,75 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222
-				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223
-				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
222
+				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
223
+				echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226 226
 		    }
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229 229
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
240 240
 		    //$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
244 244
 		    //$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 248
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude']));
251
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253 253
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
264 264
 		    //$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
267
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
268
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269 269
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -273,54 +273,54 @@  discard block
 block discarded – undo
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274 274
 		    $this->all_tracked[$id]['lastupdate'] = time();
275 275
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 277
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282 282
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 285
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
287 287
 				} else $recent_ident = '';
288
-				$TrackerLive->db=null;
288
+				$TrackerLive->db = null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292 292
 			    } else {
293 293
 				$recent_ident = '';
294
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
294
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
295 295
 			    }
296 296
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
297
+			    if ($recent_ident == "")
298 298
 			    {
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301 301
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303 303
 				    $timeelapsed = microtime(true);
304 304
 				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
306 306
 				    $Tracker->db = null;
307 307
 				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
308
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
309 309
 				    
310 310
 				    
311 311
 				    // Add source stat in DB
312 312
 				    $Stats = new Stats($this->db);
313 313
 				    if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
315
+				        foreach ($this->stats as $date => $data) {
316
+					    foreach ($data as $source => $sourced) {
317 317
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
319
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
320 320
 				    		if (isset($sourced['msg'])) {
321 321
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 322
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
323
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
324 324
 			    			        unset($this->stats[$date][$source]['msg']);
325 325
 			    			    }
326 326
 			    			}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 344
 				    $TrackerLive = new TrackerLive($this->db);
345 345
 				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
346
+				    $TrackerLive->db = null;
347 347
 				    if ($globalDebug) echo " Done\n";
348 348
 				    $this->last_delete = time();
349 349
 				}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
354 354
 					$Tracker = new Tracker($this->db);
355
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
355
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 		    $ignoreImport = false;
367 367
 
368 368
 		    if (!$ignoreImport) {
369
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
372 372
 				$TrackerLive = new TrackerLive($this->db);
373
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
374 374
 				$TrackerLive->db = null;
375 375
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
377 377
 
378 378
 				// Put statistics in $this->stats variable
379 379
 				
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 							$latitude = $globalCenterLatitude;
391 391
 							$longitude = $globalCenterLongitude;
392 392
 						}
393
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
393
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
394 394
 					} else {
395 395
 						$latitude = $this->source_location[$source]['latitude'];
396 396
 						$longitude = $this->source_location[$source]['longitude'];
397 397
 					}
398
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
398
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
399 399
 					//$stats_heading = $stats_heading%22.5;
400 400
 					$stats_heading = round($stats_heading/22.5);
401
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
401
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
402 402
 					$current_date = date('Y-m-d');
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405
-						for ($i=0;$i<=15;$i++) {
405
+						for ($i = 0; $i <= 15; $i++) {
406 406
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 419
 						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
420
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
421 421
 						} else $mini = 0;
422
-						for ($i=$mini;$i<=$distance;$i+=10) {
422
+						for ($i = $mini; $i <= $distance; $i += 10) {
423 423
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$this->all_tracked[$id]['lastupdate'] = time();
432 432
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433 433
 				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
434
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
435 435
 			//$this->del();
436 436
 			
437 437
 			
Please login to merge, or discard this patch.
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
94
+	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') {
95
+		$globalCoordMinChangeTracker = '0.015';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
130
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 228
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181 229
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -226,7 +288,9 @@  discard block
 block discarded – undo
226 288
 		    }
227 289
 		}
228 290
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
291
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
292
+		    	$dataFound = true;
293
+		    }
230 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 295
 		}
232 296
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -246,7 +310,9 @@  discard block
 block discarded – undo
246 310
 
247 311
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 312
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
313
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
314
+				$this->all_tracked[$id]['putinarchive'] = true;
315
+			}
250 316
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 317
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 318
 			//$dataFound = true;
@@ -258,15 +324,21 @@  discard block
 block discarded – undo
258 324
 		}
259 325
 		
260 326
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
262 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264 332
 		    //$dataFound = true;
265 333
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266 334
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
270 342
   		}
271 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 344
 
@@ -275,20 +347,31 @@  discard block
 block discarded – undo
275 347
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276 348
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 349
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
350
+				if ($globalDebug) {
351
+					echo "Check if aircraft is already in DB...";
352
+				}
279 353
 				$timeelapsed = microtime(true);
280 354
 				$TrackerLive = new TrackerLive($this->db);
281 355
 				if (isset($line['id'])) {
282 356
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    if ($globalDebugTimeElapsed) {
358
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+				    }
284 360
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 361
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-				} else $recent_ident = '';
362
+				    if ($globalDebugTimeElapsed) {
363
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+				    }
365
+				} else {
366
+					$recent_ident = '';
367
+				}
288 368
 				$TrackerLive->db=null;
289 369
 
290
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
292 375
 			    } else {
293 376
 				$recent_ident = '';
294 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -296,27 +379,41 @@  discard block
 block discarded – undo
296 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297 380
 			    if($recent_ident == "")
298 381
 			    {
299
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
384
+				}
300 385
 				//adds the spotter data for the archive
301 386
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
389
+				    }
303 390
 				    $timeelapsed = microtime(true);
304 391
 				    $Tracker = new Tracker($this->db);
305 392
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306 393
 				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
309 400
 				    
310 401
 				    
311 402
 				    // Add source stat in DB
312 403
 				    $Stats = new Stats($this->db);
313 404
 				    if (!empty($this->stats)) {
314
-					if ($globalDebug) echo 'Add source stats : ';
405
+					if ($globalDebug) {
406
+						echo 'Add source stats : ';
407
+					}
315 408
 				        foreach($this->stats as $date => $data) {
316 409
 					    foreach($data as $source => $sourced) {
317 410
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
411
+				    	        if (isset($sourced['polar'])) {
412
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
413
+				    	        }
414
+				    	        if (isset($sourced['hist'])) {
415
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
416
+				    	        }
320 417
 				    		if (isset($sourced['msg'])) {
321 418
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 419
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -329,7 +426,9 @@  discard block
 block discarded – undo
329 426
 			    			unset($this->stats[$date]);
330 427
 			    		    }
331 428
 				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
429
+				    	if ($globalDebug) {
430
+				    		echo 'Done'."\n";
431
+				    	}
333 432
 
334 433
 				    }
335 434
 				    $Stats->db = null;
@@ -339,12 +438,16 @@  discard block
 block discarded – undo
339 438
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 439
 				//print_r($this->all_tracked[$id]);
341 440
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    if ($globalDebug) {
442
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
443
+				    }
343 444
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 445
 				    $TrackerLive = new TrackerLive($this->db);
345 446
 				    $TrackerLive->deleteLiveTrackerData();
346 447
 				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
448
+				    if ($globalDebug) {
449
+				    	echo " Done\n";
450
+				    }
348 451
 				    $this->last_delete = time();
349 452
 				}
350 453
 			    } else {
@@ -367,19 +470,25 @@  discard block
 block discarded – undo
367 470
 
368 471
 		    if (!$ignoreImport) {
369 472
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				if ($globalDebug) {
474
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
475
+				}
371 476
 				$timeelapsed = microtime(true);
372 477
 				$TrackerLive = new TrackerLive($this->db);
373 478
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
374 479
 				$TrackerLive->db = null;
375 480
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
377 484
 
378 485
 				// Put statistics in $this->stats variable
379 486
 				
380 487
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
381 488
 					$source = $this->all_tracked[$id]['source_name'];
382
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
489
+					if ($source == '') {
490
+						$source = $this->all_tracked[$id]['format_source'];
491
+					}
383 492
 					if (!isset($this->source_location[$source])) {
384 493
 						$Location = new Source($this->db);
385 494
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -400,7 +509,9 @@  discard block
 block discarded – undo
400 509
 					$stats_heading = round($stats_heading/22.5);
401 510
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
402 511
 					$current_date = date('Y-m-d');
403
-					if ($stats_heading == 16) $stats_heading = 0;
512
+					if ($stats_heading == 16) {
513
+						$stats_heading = 0;
514
+					}
404 515
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 516
 						for ($i=0;$i<=15;$i++) {
406 517
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -418,7 +529,9 @@  discard block
 block discarded – undo
418 529
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 530
 						    end($this->stats[$current_date][$source]['hist']);
420 531
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
421
-						} else $mini = 0;
532
+						} else {
533
+							$mini = 0;
534
+						}
422 535
 						for ($i=$mini;$i<=$distance;$i+=10) {
423 536
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 537
 						}
@@ -429,19 +542,29 @@  discard block
 block discarded – undo
429 542
 				}
430 543
 
431 544
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433
-				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
545
+				if ($this->all_tracked[$id]['putinarchive']) {
546
+					$send = true;
547
+				}
548
+				if ($globalDebug) {
549
+					echo $result."\n";
550
+				}
551
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
552
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
553
+			}
435 554
 			//$this->del();
436 555
 			
437 556
 			
438 557
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    if ($globalDebug) {
559
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
560
+			    }
440 561
 			    $TrackerLive = new TrackerLive($this->db);
441 562
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 563
 			    $TrackerLive->db = null;
443 564
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
565
+			    if ($globalDebug) {
566
+			    	echo " Done\n";
567
+			    }
445 568
 			    $this->last_delete_hourly = time();
446 569
 			}
447 570
 			
@@ -449,7 +572,9 @@  discard block
 block discarded – undo
449 572
 		    //$ignoreImport = false;
450 573
 		}
451 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
575
+		if ($send) {
576
+			return $this->all_tracked[$id];
577
+		}
453 578
 	    }
454 579
 	}
455 580
     }
Please login to merge, or discard this patch.
require/class.MapMatching.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 		$gpx .= '<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpsies="http://www.gpsies.com/GPX/1/0" creator="GPSies http://www.gpsies.com - Sendl.-O&amp;apos;sch-heim" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.gpsies.com/GPX/1/0 http://www.gpsies.com/gpsies.xsd">';
45 45
 		$gpx .= '<trk>';
46 46
 		$gpx .= '<trkseg>';
47
-		foreach($spotter_history_array as $spotter_data) {
48
-			$gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">';
49
-			if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
50
-			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>';
47
+		foreach ($spotter_history_array as $spotter_data) {
48
+			$gpx .= '<trkpt lat="'.sprintf("%.8f", $spotter_data['latitude']).'" lon="'.sprintf("%.8f", $spotter_data['longitude']).'">';
49
+			if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f", $spotter_data['altitude']).'</ele>';
50
+			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z", strtotime($spotter_data['date'])).'</time>';
51 51
 			$gpx .= '</trkpt>';
52 52
 		}
53 53
 		$gpx .= '</trkseg>';
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 		global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId;
85 85
 		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
86 86
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
87
-		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
87
+		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
88 88
 		$data = $this->create_gpx($spotter_history_array);
89 89
 		$url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true';
90 90
 		$Common = new Common();
91
-		$matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml','Accept: application/json'));
92
-		$matching = json_decode($matching,true);
91
+		$matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml', 'Accept: application/json'));
92
+		$matching = json_decode($matching, true);
93 93
 		if (isset($matching['diary']['entries'][0]['route']['links'])) {
94 94
 			$spotter_history_array = array();
95 95
 			foreach ($matching['diary']['entries'][0]['route']['links'] as $match) {
96 96
 				if (isset($match['wpts'])) {
97 97
 					foreach ($match['wpts'] as $coord) {
98
-						$spotter_history_array[] = array('longitude' => $coord['x'],'latitude' => $coord['y']);
98
+						$spotter_history_array[] = array('longitude' => $coord['x'], 'latitude' => $coord['y']);
99 99
 					}
100 100
 				}
101 101
 			}
@@ -115,22 +115,22 @@  discard block
 block discarded – undo
115 115
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
116 116
 		$spotter_history_initial_array = array();
117 117
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
118
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
119
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
118
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
119
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
120 120
 		}
121 121
 		$data = $this->create_gpx($spotter_history_array);
122 122
 		$url = 'https://graphhopper.com/api/1/match?vehicle=car&points_encoded=0&instructions=false&key='.$globalGraphHopperKey;
123 123
 		$Common = new Common();
124
-		$matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml'));
125
-		$matching = json_decode($matching,true);
124
+		$matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml'));
125
+		$matching = json_decode($matching, true);
126 126
 		if (isset($matching['paths'][0]['points']['coordinates'])) {
127 127
 			$spotter_history_array = array();
128 128
 			foreach ($matching['paths'][0]['points']['coordinates'] as $match) {
129 129
 				$coord = $match;
130
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
130
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
131 131
 			}
132 132
 		}
133
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
133
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
134 134
 		$spotter_history_array[0]['mapmatching_engine'] = 'graphhopper';
135 135
 		return $spotter_history_array;
136 136
 	}
@@ -146,23 +146,23 @@  discard block
 block discarded – undo
146 146
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
147 147
 		$spotter_history_initial_array = array();
148 148
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
149
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
150
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
149
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
150
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
151 151
 		}
152 152
 		$data = $this->create_gpx($spotter_history_array);
153 153
 		$url = 'https://mapmatching.flightairmap.com/api/1/match?vehicle=car&points_encoded=0&instructions=false';
154 154
 		//$url = 'https://mapmatching.flightairmap.com/api/1/match?vehicle=car&points_encoded=0';
155 155
 		$Common = new Common();
156
-		$matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml'));
157
-		$matching = json_decode($matching,true);
156
+		$matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml'));
157
+		$matching = json_decode($matching, true);
158 158
 		if (isset($matching['paths'][0]['points']['coordinates'])) {
159 159
 			$spotter_history_array = array();
160 160
 			foreach ($matching['paths'][0]['points']['coordinates'] as $match) {
161 161
 				$coord = $match;
162
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
162
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
163 163
 			}
164 164
 		}
165
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
165
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
166 166
 		$spotter_history_array[0]['mapmatching_engine'] = 'fam';
167 167
 		return $spotter_history_array;
168 168
 	}
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
179 179
 		$spotter_history_initial_array = array();
180 180
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
181
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
182
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
181
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
182
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
183 183
 		}
184 184
 		$coord = '';
185 185
 		$ts = '';
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 		$url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore';
196 196
 		$Common = new Common();
197 197
 		$matching = $Common->getData($url);
198
-		$matching  = json_decode($matching,true);
198
+		$matching = json_decode($matching, true);
199 199
 		if (isset($matching['matchings'][0]['geometry']['coordinates'])) {
200 200
 			$spotter_history_array = array();
201 201
 			foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) {
202 202
 				$coord = $match;
203
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
203
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
204 204
 			}
205 205
 		}
206
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
206
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
207 207
 		$spotter_history_array[0]['mapmatching_engine'] = 'osmr';
208 208
 		return $spotter_history_array;
209 209
 	}
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
220 220
 		$spotter_history_initial_array = array();
221 221
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
222
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
223
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
222
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
223
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
224 224
 		}
225 225
 		$coord = '';
226 226
 		$ts = '';
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
 		$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'&timestamps='.$ts.'&overview=full&tidy=true&geometries=geojson';
238 238
 		$Common = new Common();
239 239
 		$matching = $Common->getData($url);
240
-		$matching  = json_decode($matching,true);
240
+		$matching = json_decode($matching, true);
241 241
 		if (isset($matching['matchings'][0]['geometry']['coordinates'])) {
242 242
 			$spotter_history_array = array();
243 243
 			foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) {
244 244
 				$coord = $match;
245
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
245
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
246 246
 			}
247 247
 		}
248
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
248
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
249 249
 		$spotter_history_array[0]['mapmatching_engine'] = 'mapbox';
250 250
 		return $spotter_history_array;
251 251
 	}
Please login to merge, or discard this patch.
Braces   +54 added lines, -18 removed lines patch added patch discarded remove patch
@@ -46,7 +46,9 @@  discard block
 block discarded – undo
46 46
 		$gpx .= '<trkseg>';
47 47
 		foreach($spotter_history_array as $spotter_data) {
48 48
 			$gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">';
49
-			if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
49
+			if (isset($spotter_data['altitude'])) {
50
+				$gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
51
+			}
50 52
 			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>';
51 53
 			$gpx .= '</trkpt>';
52 54
 		}
@@ -82,9 +84,15 @@  discard block
 block discarded – undo
82 84
 
83 85
 	public function TrackMatching($spotter_history_array) {
84 86
 		global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId;
85
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
86
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
87
-		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
87
+		if (!isset($globalMapMatchingMaxPts)) {
88
+			$globalMapMatchingMaxPts = 100;
89
+		}
90
+		if (count($spotter_history_array) < 2) {
91
+			return $spotter_history_array;
92
+		}
93
+		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
94
+			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
95
+		}
88 96
 		$data = $this->create_gpx($spotter_history_array);
89 97
 		$url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true';
90 98
 		$Common = new Common();
@@ -111,8 +119,12 @@  discard block
 block discarded – undo
111 119
 	*/
112 120
 	public function GraphHopper($spotter_history_array) {
113 121
 		global $globalMapMatchingMaxPts, $globalGraphHopperKey;
114
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
115
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
122
+		if (!isset($globalMapMatchingMaxPts)) {
123
+			$globalMapMatchingMaxPts = 100;
124
+		}
125
+		if (count($spotter_history_array) < 2) {
126
+			return $spotter_history_array;
127
+		}
116 128
 		$spotter_history_initial_array = array();
117 129
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
118 130
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -142,8 +154,12 @@  discard block
 block discarded – undo
142 154
 	*/
143 155
 	public function FAMMapMatching($spotter_history_array) {
144 156
 		global $globalMapMatchingMaxPts, $globalGraphHopperKey;
145
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
146
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
157
+		if (!isset($globalMapMatchingMaxPts)) {
158
+			$globalMapMatchingMaxPts = 100;
159
+		}
160
+		if (count($spotter_history_array) < 2) {
161
+			return $spotter_history_array;
162
+		}
147 163
 		$spotter_history_initial_array = array();
148 164
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
149 165
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -174,8 +190,12 @@  discard block
 block discarded – undo
174 190
 	*/
175 191
 	public function osmr($spotter_history_array) {
176 192
 		global $globalMapMatchingMaxPts;
177
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50;
178
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
193
+		if (!isset($globalMapMatchingMaxPts)) {
194
+			$globalMapMatchingMaxPts = 50;
195
+		}
196
+		if (count($spotter_history_array) < 2) {
197
+			return $spotter_history_array;
198
+		}
179 199
 		$spotter_history_initial_array = array();
180 200
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
181 201
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -185,11 +205,17 @@  discard block
 block discarded – undo
185 205
 		$ts = '';
186 206
 		$rd = '';
187 207
 		foreach ($spotter_history_array as $spotter_data) {
188
-			if ($coord != '') $coord .= ';';
208
+			if ($coord != '') {
209
+				$coord .= ';';
210
+			}
189 211
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
190
-			if ($ts != '') $ts .= ';';
212
+			if ($ts != '') {
213
+				$ts .= ';';
214
+			}
191 215
 			$ts .= strtotime($spotter_data['date']);
192
-			if ($rd != '') $rd .= ';';
216
+			if ($rd != '') {
217
+				$rd .= ';';
218
+			}
193 219
 			$rd .= '20';
194 220
 		}
195 221
 		$url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore';
@@ -215,8 +241,12 @@  discard block
 block discarded – undo
215 241
 	*/
216 242
 	public function mapbox($spotter_history_array) {
217 243
 		global $globalMapMatchingMaxPts, $globalMapboxToken;
218
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60;
219
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
244
+		if (!isset($globalMapMatchingMaxPts)) {
245
+			$globalMapMatchingMaxPts = 60;
246
+		}
247
+		if (count($spotter_history_array) < 2) {
248
+			return $spotter_history_array;
249
+		}
220 250
 		$spotter_history_initial_array = array();
221 251
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
222 252
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -226,11 +256,17 @@  discard block
 block discarded – undo
226 256
 		$ts = '';
227 257
 		$rd = '';
228 258
 		foreach ($spotter_history_array as $spotter_data) {
229
-			if ($coord != '') $coord .= ';';
259
+			if ($coord != '') {
260
+				$coord .= ';';
261
+			}
230 262
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
231
-			if ($ts != '') $ts .= ';';
263
+			if ($ts != '') {
264
+				$ts .= ';';
265
+			}
232 266
 			$ts .= strtotime($spotter_data['date']);
233
-			if ($rd != '') $rd .= ';';
267
+			if ($rd != '') {
268
+				$rd .= ';';
269
+			}
234 270
 			$rd .= '20';
235 271
 		}
236 272
 		//$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'&timestamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd;
Please login to merge, or discard this patch.
live-geojson.php 3 patches
Braces   +321 added lines, -130 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,28 +59,55 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $from_archive = false;
64 69
 $min = true;
65 70
 $allhistory = false;
66 71
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
77
+}
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
83
+}
84
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
86
+}
87
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
88
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
91
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
94
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
97
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
100
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
103
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
104
+}
78 105
 
79 106
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
80 107
 	$min = true;
81
-} else $min = false;
108
+} else {
109
+	$min = false;
110
+}
82 111
 
83 112
 $spotter_array = array();
84 113
 
@@ -189,24 +218,38 @@  discard block
 block discarded – undo
189 218
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
190 219
 		}
191 220
 	}
192
-	if ($flightcnt == '') $flightcnt = 0;
193
-} else $flightcnt = 0;
221
+	if ($flightcnt == '') {
222
+		$flightcnt = 0;
223
+	}
224
+	} else {
225
+	$flightcnt = 0;
226
+}
194 227
 
195 228
 $sqltime = round(microtime(true)-$begintime,2);
196 229
 
197 230
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
198
-if ($currenttime != '') $currenttime = round($currenttime/1000);
231
+if ($currenttime != '') {
232
+	$currenttime = round($currenttime/1000);
233
+}
199 234
 
200
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
201
-else $usenextlatlon = true;
202
-if ($usenextlatlon === false) $currenttime = '';
235
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
236
+	$usenextlatlon = false;
237
+} else {
238
+	$usenextlatlon = true;
239
+}
240
+if ($usenextlatlon === false) {
241
+	$currenttime = '';
242
+}
203 243
 $j = 0;
204 244
 $prev_flightaware_id = '';
205 245
 $aircrafts_shadow = array();
206 246
 $output = '{';
207 247
 	$output .= '"type": "FeatureCollection",';
208
-		if ($min) $output .= '"minimal": "true",';
209
-		else $output .= '"minimal": "false",';
248
+		if ($min) {
249
+			$output .= '"minimal": "true",';
250
+		} else {
251
+			$output .= '"minimal": "false",';
252
+		}
210 253
 		//$output .= '"fc": "'.$flightcnt.'",';
211 254
 		$output .= '"sqt": "'.$sqltime.'",';
212 255
 
@@ -251,18 +294,29 @@  discard block
 block discarded – undo
251 294
 						}
252 295
 						$output .= '"properties": {';
253 296
 						if (isset($spotter_item['flightaware_id'])) {
254
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
255
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
297
+							if ($compress) {
298
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
299
+							} else {
300
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
301
+							}
256 302
 						} elseif (isset($spotter_item['famtrackid'])) {
257
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
258
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
303
+							if ($compress) {
304
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
305
+							} else {
306
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
307
+							}
259 308
 						} elseif (isset($spotter_item['fammarine_id'])) {
260
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
261
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
309
+							if ($compress) {
310
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
311
+							} else {
312
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
313
+							}
262 314
 						}
263 315
 							$output .= '"fc": "'.$flightcnt.'",';
264 316
 							$output .= '"sqt": "'.$sqltime.'",';
265
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
317
+							if (isset($begindate)) {
318
+								$output .= '"archive_date": "'.$begindate.'",';
319
+							}
266 320
 
267 321
 /*
268 322
 							if ($min) $output .= '"minimal": "true",';
@@ -270,14 +324,22 @@  discard block
 block discarded – undo
270 324
 */
271 325
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
272 326
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
273
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
274
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
327
+							if ($compress) {
328
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
329
+							} else {
330
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
331
+							}
275 332
 							//"
276 333
 						} else {
277
-							if ($compress) $output .= '"c": "NA",';
278
-							else $output .= '"callsign": "NA",';
334
+							if ($compress) {
335
+								$output .= '"c": "NA",';
336
+							} else {
337
+								$output .= '"callsign": "NA",';
338
+							}
339
+						}
340
+						if (isset($spotter_item['registration'])) {
341
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
279 342
 						}
280
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
281 343
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
282 344
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
283 345
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -290,16 +352,23 @@  discard block
 block discarded – undo
290 352
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
291 353
 						}
292 354
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
293
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
294
-							else {
355
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
356
+								$spotter_item['aircraft_shadow'] = '';
357
+							} else {
295 358
 								$aircraft_icao = $spotter_item['aircraft_icao'];
296
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
297
-								else {
359
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
360
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
361
+								} else {
298 362
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
299
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
300
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
301
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
302
-									else $spotter_item['aircraft_shadow'] = '';
363
+									if (count($aircraft_info) > 0) {
364
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
365
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
366
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
367
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
368
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
369
+									} else {
370
+										$spotter_item['aircraft_shadow'] = '';
371
+									}
303 372
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
304 373
 								}
305 374
 							}
@@ -307,73 +376,139 @@  discard block
 block discarded – undo
307 376
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
308 377
 							if ($tracker) {
309 378
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
310
-									if ($compress) $output .= '"as": "ambulance.png",';
311
-									else $output .= '"aircraft_shadow": "ambulance.png",';
379
+									if ($compress) {
380
+										$output .= '"as": "ambulance.png",';
381
+									} else {
382
+										$output .= '"aircraft_shadow": "ambulance.png",';
383
+									}
312 384
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
313
-									if ($compress) $output .= '"as": "police.png",';
314
-									else $output .= '"aircraft_shadow": "police.png",';
385
+									if ($compress) {
386
+										$output .= '"as": "police.png",';
387
+									} else {
388
+										$output .= '"aircraft_shadow": "police.png",';
389
+									}
315 390
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
316
-									if ($compress) $output .= '"as": "ship.png",';
317
-									else $output .= '"aircraft_shadow": "ship.png",';
391
+									if ($compress) {
392
+										$output .= '"as": "ship.png",';
393
+									} else {
394
+										$output .= '"aircraft_shadow": "ship.png",';
395
+									}
318 396
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
319
-									if ($compress) $output .= '"as": "ship.png",';
320
-									else $output .= '"aircraft_shadow": "ship.png",';
397
+									if ($compress) {
398
+										$output .= '"as": "ship.png",';
399
+									} else {
400
+										$output .= '"aircraft_shadow": "ship.png",';
401
+									}
321 402
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
322
-									if ($compress) $output .= '"as": "ship.png",';
323
-									else $output .= '"aircraft_shadow": "ship.png",';
403
+									if ($compress) {
404
+										$output .= '"as": "ship.png",';
405
+									} else {
406
+										$output .= '"aircraft_shadow": "ship.png",';
407
+									}
324 408
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
325
-									if ($compress) $output .= '"as": "truck.png",';
326
-									else $output .= '"aircraft_shadow": "truck.png",';
409
+									if ($compress) {
410
+										$output .= '"as": "truck.png",';
411
+									} else {
412
+										$output .= '"aircraft_shadow": "truck.png",';
413
+									}
327 414
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
328
-									if ($compress) $output .= '"as": "truck.png",';
329
-									else $output .= '"aircraft_shadow": "truck.png",';
415
+									if ($compress) {
416
+										$output .= '"as": "truck.png",';
417
+									} else {
418
+										$output .= '"aircraft_shadow": "truck.png",';
419
+									}
330 420
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
331
-									if ($compress) $output .= '"as": "aircraft.png",';
332
-									else $output .= '"aircraft_shadow": "aircraft.png",';
421
+									if ($compress) {
422
+										$output .= '"as": "aircraft.png",';
423
+									} else {
424
+										$output .= '"aircraft_shadow": "aircraft.png",';
425
+									}
333 426
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
334
-									if ($compress) $output .= '"as": "aircraft.png",';
335
-									else $output .= '"aircraft_shadow": "aircraft.png",';
427
+									if ($compress) {
428
+										$output .= '"as": "aircraft.png",';
429
+									} else {
430
+										$output .= '"aircraft_shadow": "aircraft.png",';
431
+									}
336 432
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
337
-									if ($compress) $output .= '"as": "helico.png",';
338
-									else $output .= '"aircraft_shadow": "helico.png",';
433
+									if ($compress) {
434
+										$output .= '"as": "helico.png",';
435
+									} else {
436
+										$output .= '"aircraft_shadow": "helico.png",';
437
+									}
339 438
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
340
-									if ($compress) $output .= '"as": "rail.png",';
341
-									else $output .= '"aircraft_shadow": "rail.png",';
439
+									if ($compress) {
440
+										$output .= '"as": "rail.png",';
441
+									} else {
442
+										$output .= '"aircraft_shadow": "rail.png",';
443
+									}
342 444
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
343
-									if ($compress) $output .= '"as": "firetruck.png",';
344
-									else $output .= '"aircraft_shadow": "firetruck.png",';
445
+									if ($compress) {
446
+										$output .= '"as": "firetruck.png",';
447
+									} else {
448
+										$output .= '"aircraft_shadow": "firetruck.png",';
449
+									}
345 450
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
346
-									if ($compress) $output .= '"as": "bus.png",';
347
-									else $output .= '"aircraft_shadow": "bus.png",';
451
+									if ($compress) {
452
+										$output .= '"as": "bus.png",';
453
+									} else {
454
+										$output .= '"aircraft_shadow": "bus.png",';
455
+									}
348 456
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
349
-									if ($compress) $output .= '"as": "phone.png",';
350
-									else $output .= '"aircraft_shadow": "phone.png",';
457
+									if ($compress) {
458
+										$output .= '"as": "phone.png",';
459
+									} else {
460
+										$output .= '"aircraft_shadow": "phone.png",';
461
+									}
351 462
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
352
-									if ($compress) $output .= '"as": "jogger.png",';
353
-									else $output .= '"aircraft_shadow": "jogger.png",';
463
+									if ($compress) {
464
+										$output .= '"as": "jogger.png",';
465
+									} else {
466
+										$output .= '"aircraft_shadow": "jogger.png",';
467
+									}
354 468
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
355
-									if ($compress) $output .= '"as": "bike.png",';
356
-									else $output .= '"aircraft_shadow": "bike.png",';
469
+									if ($compress) {
470
+										$output .= '"as": "bike.png",';
471
+									} else {
472
+										$output .= '"aircraft_shadow": "bike.png",';
473
+									}
357 474
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
358
-									if ($compress) $output .= '"as": "motorcycle.png",';
359
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
475
+									if ($compress) {
476
+										$output .= '"as": "motorcycle.png",';
477
+									} else {
478
+										$output .= '"aircraft_shadow": "motorcycle.png",';
479
+									}
360 480
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
361
-									if ($compress) $output .= '"as": "balloon.png",';
362
-									else $output .= '"aircraft_shadow": "balloon.png",';
481
+									if ($compress) {
482
+										$output .= '"as": "balloon.png",';
483
+									} else {
484
+										$output .= '"aircraft_shadow": "balloon.png",';
485
+									}
363 486
 								} else {
364
-									if ($compress) $output .= '"as": "car.png",';
365
-									else $output .= '"aircraft_shadow": "car.png",';
487
+									if ($compress) {
488
+										$output .= '"as": "car.png",';
489
+									} else {
490
+										$output .= '"aircraft_shadow": "car.png",';
491
+									}
366 492
 								}
367 493
 							} elseif ($marine) {
368
-								if ($compress) $output .= '"as": "ship.png",';
369
-								else $output .= '"aircraft_shadow": "ship.png",';
494
+								if ($compress) {
495
+									$output .= '"as": "ship.png",';
496
+								} else {
497
+									$output .= '"aircraft_shadow": "ship.png",';
498
+								}
370 499
 							} else {
371
-								if ($compress) $output .= '"as": "default.png",';
372
-								else $output .= '"aircraft_shadow": "default.png",';
500
+								if ($compress) {
501
+									$output .= '"as": "default.png",';
502
+								} else {
503
+									$output .= '"aircraft_shadow": "default.png",';
504
+								}
373 505
 							}
374 506
 						} else {
375
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
376
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
507
+							if ($compress) {
508
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
509
+							} else {
510
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
511
+							}
377 512
 						}
378 513
 						if (isset($spotter_item['airline_name'])) {
379 514
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -381,8 +516,11 @@  discard block
 block discarded – undo
381 516
 							$output .= '"airline_name": "NA",';
382 517
 						}
383 518
 						if (isset($spotter_item['departure_airport'])) {
384
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
385
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
519
+							if ($compress) {
520
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
521
+							} else {
522
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
523
+							}
386 524
 						}
387 525
 						if (isset($spotter_item['departure_airport_city'])) {
388 526
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -394,8 +532,11 @@  discard block
 block discarded – undo
394 532
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
395 533
 						}
396 534
 						if (isset($spotter_item['arrival_airport'])) {
397
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
398
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
535
+							if ($compress) {
536
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
537
+							} else {
538
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
539
+							}
399 540
 						}
400 541
 						if (isset($spotter_item['arrival_airport_city'])) {
401 542
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -414,8 +555,11 @@  discard block
 block discarded – undo
414 555
 						}
415 556
 						
416 557
 						if (isset($spotter_item['altitude'])) {
417
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
418
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
558
+							if ($compress) {
559
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
560
+							} else {
561
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
562
+							}
419 563
 						}
420 564
 						
421 565
 						$heading = $spotter_item['heading'];
@@ -439,19 +583,24 @@  discard block
 block discarded – undo
439 583
 							}
440 584
 						}
441 585
 						
442
-						if ($compress)$output .= '"h": "'.$heading.'",';
443
-						else $output .= '"heading": "'.$heading.'",';
586
+						if ($compress) {
587
+							$output .= '"h": "'.$heading.'",';
588
+						} else {
589
+							$output .= '"heading": "'.$heading.'",';
590
+						}
444 591
 						if ($currenttime != '') {
445 592
 							if (strtotime($spotter_item['date']) < $currenttime) {
446 593
 								if (isset($archivespeed)) {
447 594
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
448 595
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
449
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
450
-									else {
596
+									if (!isset($idistance) || $fdistance < $idistance) {
597
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
598
+									} else {
451 599
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
452 600
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
453
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
454
-										else {
601
+										if (!isset($idistance) || $fdistance < $idistance) {
602
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
603
+										} else {
455 604
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
456 605
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
457 606
 										}
@@ -459,12 +608,14 @@  discard block
 block discarded – undo
459 608
 								} elseif ($usenextlatlon) {
460 609
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
461 610
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
462
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
463
-									else {
611
+									if (!isset($idistance) || $fdistance < $idistance) {
612
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
613
+									} else {
464 614
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
465 615
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
466
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
467
-										else {
616
+										if (!isset($idistance) || $fdistance < $idistance) {
617
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
618
+										} else {
468 619
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
469 620
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
470 621
 										}
@@ -503,7 +654,9 @@  discard block
 block discarded – undo
503 654
 							}
504 655
 						}
505 656
 
506
-						if (!$min) $output .= '"image": "'.$image.'",';
657
+						if (!$min) {
658
+							$output .= '"image": "'.$image.'",';
659
+						}
507 660
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
508 661
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
509 662
 						}
@@ -511,8 +664,11 @@  discard block
 block discarded – undo
511 664
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
512 665
 						}
513 666
 						if (isset($spotter_item['squawk'])) {
514
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
515
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
667
+							if ($compress) {
668
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
669
+							} else {
670
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
671
+							}
516 672
 						}
517 673
 						if (isset($spotter_item['squawk_usage'])) {
518 674
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -531,14 +687,23 @@  discard block
 block discarded – undo
531 687
 						}
532 688
 						// type when not aircraft ?
533 689
 						if (isset($spotter_item['type'])) {
534
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
535
-							else $output .= '"type": "'.$spotter_item['type'].'"';
690
+							if ($compress) {
691
+								$output .= '"t": "'.$spotter_item['type'].'"';
692
+							} else {
693
+								$output .= '"type": "'.$spotter_item['type'].'"';
694
+							}
536 695
 						} elseif ($marine) {
537
-							if ($compress) $output .= '"t": "ship"';
538
-							else $output .= '"type": "ship"';
696
+							if ($compress) {
697
+								$output .= '"t": "ship"';
698
+							} else {
699
+								$output .= '"type": "ship"';
700
+							}
539 701
 						} else {
540
-							if ($compress) $output .= '"t": "aircraft"';
541
-							else $output .= '"type": "aircraft"';
702
+							if ($compress) {
703
+								$output .= '"t": "aircraft"';
704
+							} else {
705
+								$output .= '"type": "aircraft"';
706
+							}
542 707
 						}
543 708
 						$output .= '},';
544 709
 						$output .= '"geometry": {';
@@ -546,15 +711,19 @@  discard block
 block discarded – undo
546 711
 								$output .= '"coordinates": [';
547 712
 								if ($currenttime != '') {
548 713
 									if (strtotime($spotter_item['date']) < $currenttime) {
549
-										if (!isset($archivespeed)) $archivespeed = 1;
714
+										if (!isset($archivespeed)) {
715
+											$archivespeed = 1;
716
+										}
550 717
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
551 718
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
552
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
553
-										else {
719
+										if (!isset($idistance) || $fdistance < $idistance) {
720
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
721
+										} else {
554 722
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
555 723
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
556
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
557
-											else {
724
+											if (!isset($idistance) || $fdistance < $idistance) {
725
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
726
+											} else {
558 727
 												$output .= $spotter_item['longitude'].', ';
559 728
 												$output .= $spotter_item['latitude'];
560 729
 											}
@@ -632,7 +801,9 @@  discard block
 block discarded – undo
632 801
 			}
633 802
 */
634 803
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
635
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
804
+				if ($history == '' && isset($_COOKIE['history'])) {
805
+					$history = $_COOKIE['history'];
806
+				}
636 807
 				
637 808
 				if (
638 809
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -698,8 +869,11 @@  discard block
 block discarded – undo
698 869
 									$output_history .= ']}},';
699 870
 									$output .= $output_history;
700 871
 								}
701
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
702
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
872
+								if ($compress) {
873
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
874
+								} else {
875
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
876
+								}
703 877
 							}
704 878
 							$output_history .= '[';
705 879
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -720,10 +894,15 @@  discard block
 block discarded – undo
720 894
 							if ($d == false) {
721 895
 								if ($compress) {
722 896
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
723
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
724
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
897
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
898
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
899
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
900
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
901
+									}
725 902
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
726
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
903
+								} else {
904
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
905
+								}
727 906
 								$d = true;
728 907
 							}
729 908
 							$output_history .= '[';
@@ -746,7 +925,9 @@  discard block
 block discarded – undo
746 925
 							$output_historyd = '[';
747 926
 							$output_historyd .=  $spotter_item['longitude'].', ';
748 927
 							$output_historyd .=  $spotter_item['latitude'];
749
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
928
+							if (isset($spotter_history['altitude'])) {
929
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
930
+							}
750 931
 							$output_historyd .= '],';
751 932
 							//$output_history = $output_historyd.$output_history;
752 933
 							$output_history = $output_history.$output_historyd;
@@ -773,8 +954,11 @@  discard block
 block discarded – undo
773 954
 				        && $spotter_item['arrival_airport'] != 'NA' 
774 955
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
775 956
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
776
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
777
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
957
+				    if ($compress) {
958
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
959
+				    } else {
960
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
961
+				    }
778 962
 				    if (isset($spotter_item['departure_airport_latitude'])) {
779 963
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
780 964
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -807,8 +991,11 @@  discard block
 block discarded – undo
807 991
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
808 992
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
809 993
 				    $havedata = false;
810
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
811
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
994
+				    if ($compress) {
995
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
996
+				    } else {
997
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
998
+				    }
812 999
 				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
813 1000
 
814 1001
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -823,7 +1010,9 @@  discard block
 block discarded – undo
823 1010
 				    }
824 1011
 				    //$output_dest  = substr($output_dest, 0, -1);
825 1012
 				    $output_dest .= ']}},';
826
-				    if ($havedata) $output .= $output_dest;
1013
+				    if ($havedata) {
1014
+				    	$output .= $output_dest;
1015
+				    }
827 1016
 				    unset($output_dest);
828 1017
 				}
829 1018
 			}
@@ -831,7 +1020,9 @@  discard block
 block discarded – undo
831 1020
 			$output .= ']';
832 1021
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
833 1022
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
834
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1023
+			if (isset($begindate)) {
1024
+				$output .= '"archive_date": "'.$begindate.'",';
1025
+			}
835 1026
 			$output .= '"fc": "'.$j.'"';
836 1027
 		} else {
837 1028
 			$output .= '"features": ';
Please login to merge, or discard this patch.
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -14,23 +14,23 @@  discard block
 block discarded – undo
14 14
 $usecoord = false;
15 15
 if (isset($_GET['test'])) exit();
16 16
 if (isset($_GET['tracker'])) {
17
-    $tracker = true;
17
+	$tracker = true;
18 18
 }
19 19
 if (isset($_GET['marine'])) {
20
-    $marine = true;
20
+	$marine = true;
21 21
 }
22 22
 if ($tracker) {
23
-    require_once('require/class.Tracker.php');
24
-    require_once('require/class.TrackerLive.php');
25
-    require_once('require/class.TrackerArchive.php');
23
+	require_once('require/class.Tracker.php');
24
+	require_once('require/class.TrackerLive.php');
25
+	require_once('require/class.TrackerArchive.php');
26 26
 } elseif ($marine) {
27
-    require_once('require/class.Marine.php');
28
-    require_once('require/class.MarineLive.php');
29
-    require_once('require/class.MarineArchive.php');
27
+	require_once('require/class.Marine.php');
28
+	require_once('require/class.MarineLive.php');
29
+	require_once('require/class.MarineArchive.php');
30 30
 } else {
31
-    require_once('require/class.Spotter.php');
32
-    require_once('require/class.SpotterLive.php');
33
-    require_once('require/class.SpotterArchive.php');
31
+	require_once('require/class.Spotter.php');
32
+	require_once('require/class.SpotterLive.php');
33
+	require_once('require/class.SpotterArchive.php');
34 34
 }
35 35
 
36 36
 $begintime = microtime(true);
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 $Common = new Common();
51 51
 
52 52
 if (isset($_GET['download'])) {
53
-    if ($_GET['download'] == "true")
54
-    {
53
+	if ($_GET['download'] == "true")
54
+	{
55 55
 	header('Content-disposition: attachment; filename="flightairmap.json"');
56
-    }
56
+	}
57 57
 }
58 58
 header('Content-Type: text/javascript');
59 59
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	$usecoord = true;
132 132
 	$coord = explode(',',$_GET['coord']);
133 133
 	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
134
-	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
134
+		&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
135 135
 		if ($tracker) {
136 136
 			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
137 137
 		} elseif ($marine) {
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
636 636
 				
637 637
 				if (
638
-				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
639
-				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
638
+					(isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
639
+					|| ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
640 640
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
641 641
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
642
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
643
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
644
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
645
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
646
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
647
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
648
-				    ) {
642
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
643
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
644
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
645
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
646
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
647
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
648
+					) {
649 649
 					if ($tracker) {
650 650
 						if ($from_archive || $globalArchive) {
651 651
 							$spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']);
@@ -653,9 +653,9 @@  discard block
 block discarded – undo
653 653
 							$spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']);
654 654
 						}
655 655
 						if (((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') ||
656
-						    (!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && 
657
-						    isset($_GET['zoom']) && $_GET['zoom'] > 12 && 
658
-						    isset($spotter_item['type']) && (
656
+							(!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && 
657
+							isset($_GET['zoom']) && $_GET['zoom'] > 12 && 
658
+							isset($spotter_item['type']) && (
659 659
 							$spotter_item['type'] == 'Firetruck' ||
660 660
 							$spotter_item['type'] == 'Ambulance' ||
661 661
 							$spotter_item['type'] == 'Truck (18 Wheeler)' ||
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 							$spotter_item['type'] == 'Jeep' ||
668 668
 							$spotter_item['type'] == 'Motorcycle' ||
669 669
 							$spotter_item['type'] == 'Car'
670
-						    )
670
+							)
671 671
 						) {
672 672
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
673 673
 							$MapMatching = new MapMatching();
@@ -770,65 +770,65 @@  discard block
 block discarded – undo
770 770
 				}
771 771
 				
772 772
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
773
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
774
-				     && (isset($spotter_item['departure_airport']) 
775
-				        && $spotter_item['departure_airport'] != 'NA' 
776
-				        && isset($spotter_item['arrival_airport']) 
777
-				        && $spotter_item['arrival_airport'] != 'NA' 
778
-				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
779
-				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
780
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
781
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
782
-				    if (isset($spotter_item['departure_airport_latitude'])) {
773
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
774
+					 && (isset($spotter_item['departure_airport']) 
775
+						&& $spotter_item['departure_airport'] != 'NA' 
776
+						&& isset($spotter_item['arrival_airport']) 
777
+						&& $spotter_item['arrival_airport'] != 'NA' 
778
+						&& ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
779
+							|| (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
780
+					if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
781
+					else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
782
+					if (isset($spotter_item['departure_airport_latitude'])) {
783 783
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
784
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
784
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
785 785
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
786 786
 					if (isset($dairport[0]['latitude'])) {
787
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
787
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
788 788
 					}
789
-				    }
790
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
789
+					}
790
+					if (isset($spotter_item['arrival_airport_latitude'])) {
791 791
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],';
792
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
792
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
793 793
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
794 794
 					if (isset($aairport[0]['latitude'])) {
795
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
795
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
796 796
 					}
797
-				    }
798
-				    $output_air  = substr($output_air, 0, -1);
799
-				    $output_air .= ']}},';
800
-				    $output .= $output_air;
801
-				    unset($output_air);
797
+					}
798
+					$output_air  = substr($output_air, 0, -1);
799
+					$output_air .= ']}},';
800
+					$output .= $output_air;
801
+					unset($output_air);
802 802
 				}
803 803
 
804 804
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
805 805
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
806 806
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
807
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
808
-				     && (isset($spotter_item['arrival_airport']) 
809
-				        && $spotter_item['arrival_airport'] != 'NA' 
810
-				        && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") 
811
-				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
812
-				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
813
-				    $havedata = false;
814
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
816
-				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
807
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
808
+					 && (isset($spotter_item['arrival_airport']) 
809
+						&& $spotter_item['arrival_airport'] != 'NA' 
810
+						&& ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") 
811
+							|| (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
812
+							|| (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
813
+					$havedata = false;
814
+					if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
+					else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
816
+					$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
817 817
 
818
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
818
+					if (isset($spotter_item['arrival_airport_latitude'])) {
819 819
 					$output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
820 820
 					$havedata = true;
821
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
821
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
822 822
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
823 823
 					if (isset($aairport[0]['latitude'])) {
824
-					    $output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
825
-					    $havedata = true;
824
+						$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
825
+						$havedata = true;
826 826
 					}
827
-				    }
828
-				    //$output_dest  = substr($output_dest, 0, -1);
829
-				    $output_dest .= ']}},';
830
-				    if ($havedata) $output .= $output_dest;
831
-				    unset($output_dest);
827
+					}
828
+					//$output_dest  = substr($output_dest, 0, -1);
829
+					$output_dest .= ']}},';
830
+					if ($havedata) $output .= $output_dest;
831
+					unset($output_dest);
832 832
 				}
833 833
 			}
834 834
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
 $min = true;
65 65
 $allhistory = false;
66 66
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
68
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
69
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
71
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
72
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
73
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
74
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
75
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
76
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
77
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
78 78
 
79 79
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
80 80
 	$min = true;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 $spotter_array = array();
84 84
 
85 85
 if (isset($_GET['ident'])) {
86
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
86
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
87 87
 	if ($tracker) {
88 88
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
89 89
 	} elseif ($marine) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 	$allhistory = true;
99 99
 } elseif (isset($_GET['flightaware_id'])) {
100
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
100
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
101 101
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
102 102
 	if (empty($spotter_array)) {
103 103
 		$from_archive = true;
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 	$allhistory = true;
107 107
 } elseif (isset($_GET['famtrack_id'])) {
108
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
108
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
109 109
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
110 110
 	$allhistory = true;
111 111
 } elseif (isset($_GET['fammarine_id'])) {
112
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
112
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
113 113
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
114 114
 	$allhistory = true;
115 115
 /*
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 */
130 130
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) {
131 131
 	$usecoord = true;
132
-	$coord = explode(',',$_GET['coord']);
133
-	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
132
+	$coord = explode(',', $_GET['coord']);
133
+	if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
134 134
 	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
135 135
 		if ($tracker) {
136
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
136
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
137 137
 		} elseif ($marine) {
138
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
138
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
139 139
 		} else {
140
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
140
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
141 141
 		}
142 142
 	} else {
143 143
 		if ($tracker) {
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	$from_archive = true;
153 153
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
154 154
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
155
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
156
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
157
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
158
-	$begindate = date('Y-m-d H:i:s',$begindate);
159
-	$enddate = date('Y-m-d H:i:s',$enddate);
160
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
155
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
156
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
157
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
158
+	$begindate = date('Y-m-d H:i:s', $begindate);
159
+	$enddate = date('Y-m-d H:i:s', $enddate);
160
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
161 161
 } elseif ($min) {
162 162
 	if ($tracker) {
163 163
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
 #	$min = true;
170 170
 } else {
171 171
 	if ($tracker) {
172
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
172
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
173 173
 	} elseif ($marine) {
174
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
174
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
175 175
 	} else {
176
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
176
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
177 177
 	}
178 178
 }
179 179
 
180 180
 if ($usecoord) {
181 181
 	if (isset($_GET['archive'])) {
182
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
182
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
183 183
 	} else {
184 184
 		if ($tracker) {
185 185
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	if ($flightcnt == '') $flightcnt = 0;
193 193
 } else $flightcnt = 0;
194 194
 
195
-$sqltime = round(microtime(true)-$begintime,2);
195
+$sqltime = round(microtime(true) - $begintime, 2);
196 196
 
197
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
197
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
198 198
 if ($currenttime != '') $currenttime = round($currenttime/1000);
199 199
 
200 200
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 		if (!empty($spotter_array) && is_array($spotter_array))
214 214
 		{
215 215
 			$output .= '"features": [';
216
-			foreach($spotter_array as $spotter_item)
216
+			foreach ($spotter_array as $spotter_item)
217 217
 			{
218 218
 				$j++;
219 219
 				unset($idistance);
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 */
271 271
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
272 272
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
273
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
274
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
273
+							if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",';
274
+							else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",';
275 275
 							//"
276 276
 						} else {
277 277
 							if ($compress) $output .= '"c": "NA",';
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
281 281
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
282 282
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
283
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
283
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
284 284
 						} elseif (isset($spotter_item['aircraft_type'])) {
285 285
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
286 286
 						} elseif (!$min) {
@@ -423,15 +423,15 @@  discard block
 block discarded – undo
423 423
 						if (isset($archivespeed) || $usenextlatlon) {
424 424
 							if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
425 425
 								if (isset($spotter_item['arrival_airport_latitude'])) {
426
-									$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
427
-									$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
426
+									$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
427
+									$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
428 428
 									$farr_lat = $spotter_item['arrival_airport_latitude'];
429 429
 									$farr_lon = $spotter_item['arrival_airport_longitude'];
430 430
 								} else {
431 431
 									$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
432 432
 									if (isset($aairport[0]['latitude'])) {
433
-										$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
434
-										$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
433
+										$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
434
+										$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
435 435
 										$farr_lat = $aairport[0]['latitude'];
436 436
 										$farr_lon = $aairport[0]['longitude'];
437 437
 									}
@@ -444,59 +444,59 @@  discard block
 block discarded – undo
444 444
 						if ($currenttime != '') {
445 445
 							if (strtotime($spotter_item['date']) < $currenttime) {
446 446
 								if (isset($archivespeed)) {
447
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
448
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
447
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
448
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
449 449
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
450 450
 									else {
451
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
452
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
451
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
452
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
453 453
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
454 454
 										else {
455
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
455
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
456 456
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
457 457
 										}
458 458
 									}
459 459
 								} elseif ($usenextlatlon) {
460
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
461
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
460
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
461
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
462 462
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
463 463
 									else {
464
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
465
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
464
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
465
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
466 466
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
467 467
 										else {
468
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
468
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
469 469
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
470 470
 										}
471 471
 									}
472 472
 								}
473 473
 							} else {
474 474
 								if (isset($archivespeed)) {
475
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
475
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
476 476
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
477 477
 								} elseif ($usenextlatlon) {
478
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
478
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
479 479
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
480 480
 								}
481 481
 							}
482 482
 						} else {
483 483
 							if (isset($archivespeed)) {
484
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
485
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
484
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
485
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
486 486
 								if (!isset($idistance) || $fdistance < $idistance) {
487 487
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
488 488
 								} else {
489
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed);
489
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed);
490 490
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
491 491
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
492 492
 								}
493 493
 							} elseif ($usenextlatlon) {
494
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
495
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
494
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
495
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
496 496
 								if (!isset($idistance) || $fdistance < $idistance) {
497 497
 										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
498 498
 								} else {
499
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading);
499
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading);
500 500
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
501 501
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
502 502
 								}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 
506 506
 						if (!$min) $output .= '"image": "'.$image.'",';
507 507
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
508
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
508
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
509 509
 						}
510 510
 						if (isset($spotter_item['image_source_website'])) {
511 511
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
528 528
 						}
529 529
 						if (isset($spotter_item['acars'])) {
530
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
530
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
531 531
 						}
532 532
 						// type when not aircraft ?
533 533
 						if (isset($spotter_item['type'])) {
@@ -547,12 +547,12 @@  discard block
 block discarded – undo
547 547
 								if ($currenttime != '') {
548 548
 									if (strtotime($spotter_item['date']) < $currenttime) {
549 549
 										if (!isset($archivespeed)) $archivespeed = 1;
550
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
551
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
550
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
551
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
552 552
 										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
553 553
 										else {
554
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
555
-											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
554
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
555
+											$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
556 556
 											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
557 557
 											else {
558 558
 												$output .= $spotter_item['longitude'].', ';
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
                 
632 632
 			}
633 633
 */
634
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
634
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
635 635
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
636 636
 				
637 637
 				if (
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
640 640
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
641 641
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
642
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
642
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
643 643
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
644
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
644
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
645 645
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
646
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
646
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
647 647
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
648 648
 				    ) {
649 649
 					if ($tracker) {
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
673 673
 							$MapMatching = new MapMatching();
674 674
 							if (isset($spotter_item['date_iso_8601'])) {
675
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601'])))));
675
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date_iso_8601'])))));
676 676
 							} else {
677
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date'])))));
677
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date'])))));
678 678
 							}
679 679
 							$spotter_history_array = $MapMatching->match($spotter_history_array_mm);
680 680
 						}
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
707 707
 							}
708 708
 							$output_history .= '[';
709
-							$output_history .=  $spotter_history['longitude'].', ';
710
-							$output_history .=  $spotter_history['latitude'].', ';
711
-							$output_history .=  $spotter_history['altitude']*30.48;
709
+							$output_history .= $spotter_history['longitude'].', ';
710
+							$output_history .= $spotter_history['latitude'].', ';
711
+							$output_history .= $spotter_history['altitude']*30.48;
712 712
 							$output_history .= '],';
713 713
 							/*
714 714
 							if ($from_archive === false) {
@@ -731,8 +731,8 @@  discard block
 block discarded – undo
731 731
 								$d = true;
732 732
 							}
733 733
 							$output_history .= '[';
734
-							$output_history .=  $spotter_history['longitude'].', ';
735
-							$output_history .=  $spotter_history['latitude'];
734
+							$output_history .= $spotter_history['longitude'].', ';
735
+							$output_history .= $spotter_history['latitude'];
736 736
 							$output_history .= '],';
737 737
 							/*
738 738
 							if ($from_archive === false) {
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
 						//echo $output_history;
749 749
 						if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) {
750 750
 							$output_historyd = '[';
751
-							$output_historyd .=  $spotter_item['longitude'].', ';
752
-							$output_historyd .=  $spotter_item['latitude'];
753
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
751
+							$output_historyd .= $spotter_item['longitude'].', ';
752
+							$output_historyd .= $spotter_item['latitude'];
753
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
754 754
 							$output_historyd .= '],';
755 755
 							//$output_history = $output_historyd.$output_history;
756 756
 							$output_history = $output_history.$output_historyd;
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 							$last = array_pop($spotter_history_array);
759 759
 							$latitude = $last['latitude'];
760 760
 							$longitude = $last['longitude'];
761
-							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output);
761
+							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output);
762 762
 						}
763 763
 						
764 764
 						$output_history  = substr($output_history, 0, -1);
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 					}
770 770
 				}
771 771
 				
772
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
772
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
773 773
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
774 774
 				     && (isset($spotter_item['departure_airport']) 
775 775
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 
804 804
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
805 805
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
806
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
806
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
807 807
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
808 808
 				     && (isset($spotter_item['arrival_airport']) 
809 809
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 			$output  = substr($output, 0, -1);
835 835
 			$output .= ']';
836 836
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
837
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
837
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
838 838
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
839 839
 			$output .= '"fc": "'.$j.'"';
840 840
 		} else {
Please login to merge, or discard this patch.