Completed
Push — master ( 118bb3...d652ce )
by Yannick
29:38
created
footer.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@
 block discarded – undo
2 2
 
3 3
 <footer class="container">
4 4
 	<?php
5
-	    if (isset($sql_time)) {
5
+		if (isset($sql_time)) {
6 6
 	?>
7 7
 	<i><?php echo _("Page generated in").' '.round($sql_time+$page_time,2); ?>s (<?php print round($page_time,2); ?>ms PHP - <?php print round($sql_time,2); ?>ms SQL)</i>
8 8
 	<br />
9 9
 	<?php
10
-	    }
10
+		}
11 11
 	?>
12 12
 	<span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) print $globalURL; ?>/about#source">Source &amp; Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span>
13 13
 </footer>
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,10 @@
 block discarded – undo
9 9
 	<?php
10 10
 	    }
11 11
 	?>
12
-	<span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) print $globalURL; ?>/about#source">Source &amp; Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span>
12
+	<span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) {
13
+	print $globalURL;
14
+}
15
+?>/about#source">Source &amp; Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span>
13 16
 </footer>
14 17
 
15 18
 <div class="notifications bottom-left"></div>
Please login to merge, or discard this patch.
require/class.Tracker.php 3 patches
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	
21 21
 	public function getFilter($filter = array(),$where = false,$and = false) {
22 22
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	/**
83
-	* Executes the SQL statements to get the spotter information
84
-	*
85
-	* @param String $query the SQL query
86
-	* @param Array $params parameter of the query
87
-	* @param String $limitQuery the limit query
88
-	* @return Array the spotter information
89
-	*
90
-	*/
83
+	 * Executes the SQL statements to get the spotter information
84
+	 *
85
+	 * @param String $query the SQL query
86
+	 * @param Array $params parameter of the query
87
+	 * @param String $limitQuery the limit query
88
+	 * @return Array the spotter information
89
+	 *
90
+	 */
91 91
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
92 92
 	{
93 93
 		date_default_timezone_set('UTC');
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 	
201 201
 	
202 202
 	/**
203
-	* Gets all the spotter information based on the latest data entry
204
-	*
205
-	* @return Array the spotter information
206
-	*
207
-	*/
203
+	 * Gets all the spotter information based on the latest data entry
204
+	 *
205
+	 * @return Array the spotter information
206
+	 *
207
+	 */
208 208
 	public function getLatestTrackerData($limit = '', $sort = '', $filter = array())
209 209
 	{
210 210
 		global $global_query;
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	/**
265
-	* Gets all the spotter information based on the callsign
266
-	*
267
-	* @return Array the spotter information
268
-	*
269
-	*/
265
+	 * Gets all the spotter information based on the callsign
266
+	 *
267
+	 * @return Array the spotter information
268
+	 *
269
+	 */
270 270
 	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
271 271
 	{
272 272
 		global $global_query;
@@ -377,12 +377,12 @@  discard block
 block discarded – undo
377 377
 
378 378
 
379 379
 	/**
380
-	* Gets all source name
381
-	*
382
-	* @param String type format of source
383
-	* @return Array list of source name
384
-	*
385
-	*/
380
+	 * Gets all source name
381
+	 *
382
+	 * @param String type format of source
383
+	 * @return Array list of source name
384
+	 *
385
+	 */
386 386
 	public function getAllSourceName($type = '',$filters = array())
387 387
 	{
388 388
 		$filter_query = $this->getFilter($filters,true,true);
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 
413 413
 
414 414
 	/**
415
-	* Gets a list of all idents/callsigns
416
-	*
417
-	* @return Array list of ident/callsign names
418
-	*
419
-	*/
415
+	 * Gets a list of all idents/callsigns
416
+	 *
417
+	 * @return Array list of ident/callsign names
418
+	 *
419
+	 */
420 420
 	public function getAllIdents($filters = array())
421 421
 	{
422 422
 		$filter_query = $this->getFilter($filters,true,true);
@@ -484,18 +484,18 @@  discard block
 block discarded – undo
484 484
 	
485 485
 	
486 486
 	/**
487
-	* Update ident spotter data
488
-	*
489
-	* @param String $flightaware_id the ID from flightaware
490
-	* @param String $ident the flight ident
491
-	* @return String success or false
492
-	*
493
-	*/	
487
+	 * Update ident spotter data
488
+	 *
489
+	 * @param String $flightaware_id the ID from flightaware
490
+	 * @param String $ident the flight ident
491
+	 * @return String success or false
492
+	 *
493
+	 */	
494 494
 	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
495 495
 	{
496 496
 
497 497
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
498
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
498
+				$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
499 499
 
500 500
 		try {
501 501
 			$sth = $this->db->prepare($query);
@@ -508,18 +508,18 @@  discard block
 block discarded – undo
508 508
 
509 509
 	}
510 510
 	/**
511
-	* Update latest spotter data
512
-	*
513
-	* @param String $flightaware_id the ID from flightaware
514
-	* @param String $ident the flight ident
515
-	* @param String $arrival_airport_icao the arrival airport
516
-	* @return String success or false
517
-	*
518
-	*/	
511
+	 * Update latest spotter data
512
+	 *
513
+	 * @param String $flightaware_id the ID from flightaware
514
+	 * @param String $ident the flight ident
515
+	 * @param String $arrival_airport_icao the arrival airport
516
+	 * @return String success or false
517
+	 *
518
+	 */	
519 519
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
520 520
 	{
521 521
 		$query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid';
522
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
522
+				$query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
523 523
 
524 524
 		try {
525 525
 			$sth = $this->db->prepare($query);
@@ -533,32 +533,32 @@  discard block
 block discarded – undo
533 533
 	}
534 534
 
535 535
 	/**
536
-	* Adds a new spotter data
537
-	*
538
-	* @param String $flightaware_id the ID from flightaware
539
-	* @param String $ident the flight ident
540
-	* @param String $aircraft_icao the aircraft type
541
-	* @param String $departure_airport_icao the departure airport
542
-	* @param String $arrival_airport_icao the arrival airport
543
-	* @param String $latitude latitude of flight
544
-	* @param String $longitude latitude of flight
545
-	* @param String $waypoints waypoints of flight
546
-	* @param String $altitude altitude of flight
547
-	* @param String $heading heading of flight
548
-	* @param String $groundspeed speed of flight
549
-	* @param String $date date of flight
550
-	* @param String $departure_airport_time departure time of flight
551
-	* @param String $arrival_airport_time arrival time of flight
552
-	* @param String $squawk squawk code of flight
553
-	* @param String $route_stop route stop of flight
554
-	* @param String $highlight highlight or not
555
-	* @param String $ModeS ModesS code of flight
556
-	* @param String $registration registration code of flight
557
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
558
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
559
-	* @param String $verticalrate vertival rate of flight
560
-	* @return String success or false
561
-	*/
536
+	 * Adds a new spotter data
537
+	 *
538
+	 * @param String $flightaware_id the ID from flightaware
539
+	 * @param String $ident the flight ident
540
+	 * @param String $aircraft_icao the aircraft type
541
+	 * @param String $departure_airport_icao the departure airport
542
+	 * @param String $arrival_airport_icao the arrival airport
543
+	 * @param String $latitude latitude of flight
544
+	 * @param String $longitude latitude of flight
545
+	 * @param String $waypoints waypoints of flight
546
+	 * @param String $altitude altitude of flight
547
+	 * @param String $heading heading of flight
548
+	 * @param String $groundspeed speed of flight
549
+	 * @param String $date date of flight
550
+	 * @param String $departure_airport_time departure time of flight
551
+	 * @param String $arrival_airport_time arrival time of flight
552
+	 * @param String $squawk squawk code of flight
553
+	 * @param String $route_stop route stop of flight
554
+	 * @param String $highlight highlight or not
555
+	 * @param String $ModeS ModesS code of flight
556
+	 * @param String $registration registration code of flight
557
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
558
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
559
+	 * @param String $verticalrate vertival rate of flight
560
+	 * @return String success or false
561
+	 */
562 562
 	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
563 563
 	{
564 564
 		global $globalURL;
@@ -643,16 +643,16 @@  discard block
 block discarded – undo
643 643
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
644 644
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
645 645
 	
646
-                if ($latitude == '' && $longitude == '') {
647
-            		$latitude = 0;
648
-            		$longitude = 0;
649
-            	}
650
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
651
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
652
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
646
+				if ($latitude == '' && $longitude == '') {
647
+					$latitude = 0;
648
+					$longitude = 0;
649
+				}
650
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
651
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
652
+				$query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
653 653
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
654 654
 
655
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
655
+				$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
656 656
 
657 657
 		try {
658 658
 		        
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 			$sth->execute($query_values);
661 661
 			$this->db = null;
662 662
 		} catch (PDOException $e) {
663
-		    return "error : ".$e->getMessage();
663
+			return "error : ".$e->getMessage();
664 664
 		}
665 665
 		
666 666
 		return "success";
@@ -669,11 +669,11 @@  discard block
 block discarded – undo
669 669
 	
670 670
   
671 671
 	/**
672
-	* Gets the aircraft ident within the last hour
673
-	*
674
-	* @return String the ident
675
-	*
676
-	*/
672
+	 * Gets the aircraft ident within the last hour
673
+	 *
674
+	 * @return String the ident
675
+	 *
676
+	 */
677 677
 	public function getIdentFromLastHour($ident)
678 678
 	{
679 679
 		global $globalDBdriver, $globalTimezone;
@@ -689,11 +689,11 @@  discard block
 block discarded – undo
689 689
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
690 690
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
691 691
 			$query_data = array(':ident' => $ident);
692
-    		}
692
+			}
693 693
 		
694 694
 		$sth = $this->db->prepare($query);
695 695
 		$sth->execute($query_data);
696
-    		$ident_result='';
696
+			$ident_result='';
697 697
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
698 698
 		{
699 699
 			$ident_result = $row['ident'];
@@ -704,11 +704,11 @@  discard block
 block discarded – undo
704 704
 	
705 705
 	
706 706
 	/**
707
-	* Gets the aircraft data from the last 20 seconds
708
-	*
709
-	* @return Array the spotter data
710
-	*
711
-	*/
707
+	 * Gets the aircraft data from the last 20 seconds
708
+	 *
709
+	 * @return Array the spotter data
710
+	 *
711
+	 */
712 712
 	public function getRealTimeData($q = '')
713 713
 	{
714 714
 		global $globalDBdriver;
@@ -746,11 +746,11 @@  discard block
 block discarded – undo
746 746
 	
747 747
 
748 748
 	/**
749
-	* Gets all number of flight over countries
750
-	*
751
-	* @return Array the airline country list
752
-	*
753
-	*/
749
+	 * Gets all number of flight over countries
750
+	 *
751
+	 * @return Array the airline country list
752
+	 *
753
+	 */
754 754
 
755 755
 	public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
756 756
 	{
@@ -821,11 +821,11 @@  discard block
 block discarded – undo
821 821
 	}
822 822
 	
823 823
 	/**
824
-	* Gets all callsigns that have flown over
825
-	*
826
-	* @return Array the callsign list
827
-	*
828
-	*/
824
+	 * Gets all callsigns that have flown over
825
+	 *
826
+	 * @return Array the callsign list
827
+	 *
828
+	 */
829 829
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
830 830
 	{
831 831
 		global $globalDBdriver;
@@ -892,11 +892,11 @@  discard block
 block discarded – undo
892 892
 
893 893
 
894 894
 	/**
895
-	* Counts all dates
896
-	*
897
-	* @return Array the date list
898
-	*
899
-	*/
895
+	 * Counts all dates
896
+	 *
897
+	 * @return Array the date list
898
+	 *
899
+	 */
900 900
 	public function countAllDates($filters = array())
901 901
 	{
902 902
 		global $globalTimezone, $globalDBdriver;
@@ -942,11 +942,11 @@  discard block
 block discarded – undo
942 942
 	
943 943
 	
944 944
 	/**
945
-	* Counts all dates during the last 7 days
946
-	*
947
-	* @return Array the date list
948
-	*
949
-	*/
945
+	 * Counts all dates during the last 7 days
946
+	 *
947
+	 * @return Array the date list
948
+	 *
949
+	 */
950 950
 	public function countAllDatesLast7Days($filters = array())
951 951
 	{
952 952
 		global $globalTimezone, $globalDBdriver;
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			$query .= " GROUP BY date_name 
969 969
 								ORDER BY date_name ASC";
970 970
 			$query_data = array(':offset' => $offset);
971
-    		}
971
+			}
972 972
 		
973 973
 		$sth = $this->db->prepare($query);
974 974
 		$sth->execute($query_data);
@@ -988,11 +988,11 @@  discard block
 block discarded – undo
988 988
 	}
989 989
 
990 990
 	/**
991
-	* Counts all dates during the last month
992
-	*
993
-	* @return Array the date list
994
-	*
995
-	*/
991
+	 * Counts all dates during the last month
992
+	 *
993
+	 * @return Array the date list
994
+	 *
995
+	 */
996 996
 	public function countAllDatesLastMonth($filters = array())
997 997
 	{
998 998
 		global $globalTimezone, $globalDBdriver;
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 			$query .= " GROUP BY date_name 
1015 1015
 								ORDER BY date_name ASC";
1016 1016
 			$query_data = array(':offset' => $offset);
1017
-    		}
1017
+			}
1018 1018
 		
1019 1019
 		$sth = $this->db->prepare($query);
1020 1020
 		$sth->execute($query_data);
@@ -1036,11 +1036,11 @@  discard block
 block discarded – undo
1036 1036
 
1037 1037
 
1038 1038
 	/**
1039
-	* Counts all month
1040
-	*
1041
-	* @return Array the month list
1042
-	*
1043
-	*/
1039
+	 * Counts all month
1040
+	 *
1041
+	 * @return Array the month list
1042
+	 *
1043
+	 */
1044 1044
 	public function countAllMonths($filters = array())
1045 1045
 	{
1046 1046
 		global $globalTimezone, $globalDBdriver;
@@ -1085,11 +1085,11 @@  discard block
 block discarded – undo
1085 1085
 	
1086 1086
 
1087 1087
 	/**
1088
-	* Counts all dates during the last year
1089
-	*
1090
-	* @return Array the date list
1091
-	*
1092
-	*/
1088
+	 * Counts all dates during the last year
1089
+	 *
1090
+	 * @return Array the date list
1091
+	 *
1092
+	 */
1093 1093
 	public function countAllMonthsLastYear($filters)
1094 1094
 	{
1095 1095
 		global $globalTimezone, $globalDBdriver;
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 			$query .= " GROUP BY year_name, month_name
1112 1112
 								ORDER BY year_name, month_name ASC";
1113 1113
 			$query_data = array(':offset' => $offset);
1114
-    		}
1114
+			}
1115 1115
 		
1116 1116
 		$sth = $this->db->prepare($query);
1117 1117
 		$sth->execute($query_data);
@@ -1134,11 +1134,11 @@  discard block
 block discarded – undo
1134 1134
 	
1135 1135
 	
1136 1136
 	/**
1137
-	* Counts all hours
1138
-	*
1139
-	* @return Array the hour list
1140
-	*
1141
-	*/
1137
+	 * Counts all hours
1138
+	 *
1139
+	 * @return Array the hour list
1140
+	 *
1141
+	 */
1142 1142
 	public function countAllHours($orderby,$filters = array())
1143 1143
 	{
1144 1144
 		global $globalTimezone, $globalDBdriver;
@@ -1201,11 +1201,11 @@  discard block
 block discarded – undo
1201 1201
 	
1202 1202
 	
1203 1203
 	/**
1204
-	* Counts all hours by date
1205
-	*
1206
-	* @return Array the hour list
1207
-	*
1208
-	*/
1204
+	 * Counts all hours by date
1205
+	 *
1206
+	 * @return Array the hour list
1207
+	 *
1208
+	 */
1209 1209
 	public function countAllHoursByDate($date, $filters = array())
1210 1210
 	{
1211 1211
 		global $globalTimezone, $globalDBdriver;
@@ -1249,11 +1249,11 @@  discard block
 block discarded – undo
1249 1249
 	
1250 1250
 	
1251 1251
 	/**
1252
-	* Counts all hours by a ident/callsign
1253
-	*
1254
-	* @return Array the hour list
1255
-	*
1256
-	*/
1252
+	 * Counts all hours by a ident/callsign
1253
+	 *
1254
+	 * @return Array the hour list
1255
+	 *
1256
+	 */
1257 1257
 	public function countAllHoursByIdent($ident, $filters = array())
1258 1258
 	{
1259 1259
 		global $globalTimezone, $globalDBdriver;
@@ -1298,11 +1298,11 @@  discard block
 block discarded – undo
1298 1298
 	
1299 1299
 	
1300 1300
 	/**
1301
-	* Counts all flights that have flown over
1302
-	*
1303
-	* @return Integer the number of flights
1304
-	*
1305
-	*/
1301
+	 * Counts all flights that have flown over
1302
+	 *
1303
+	 * @return Integer the number of flights
1304
+	 *
1305
+	 */
1306 1306
 	public function countOverallTracker($filters = array(),$year = '',$month = '')
1307 1307
 	{
1308 1308
 		global $globalDBdriver;
@@ -1338,11 +1338,11 @@  discard block
 block discarded – undo
1338 1338
 	
1339 1339
   
1340 1340
 	/**
1341
-	* Counts all hours of today
1342
-	*
1343
-	* @return Array the hour list
1344
-	*
1345
-	*/
1341
+	 * Counts all hours of today
1342
+	 *
1343
+	 * @return Array the hour list
1344
+	 *
1345
+	 */
1346 1346
 	public function countAllHoursFromToday($filters = array())
1347 1347
 	{
1348 1348
 		global $globalTimezone, $globalDBdriver;
@@ -1382,12 +1382,12 @@  discard block
 block discarded – undo
1382 1382
 	}
1383 1383
     
1384 1384
     
1385
-     /**
1386
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1387
-	*
1388
-	* @return Integer the Barrie Spotter ID
1385
+	 /**
1386
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1387
+	  *
1388
+	  * @return Integer the Barrie Spotter ID
1389 1389
 q	*
1390
-	*/
1390
+	  */
1391 1391
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1392 1392
 	{
1393 1393
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -1408,13 +1408,13 @@  discard block
 block discarded – undo
1408 1408
   
1409 1409
  
1410 1410
 	/**
1411
-	* Parses a date string
1412
-	*
1413
-	* @param String $dateString the date string
1414
-	* @param String $timezone the timezone of a user
1415
-	* @return Array the time information
1416
-	*
1417
-	*/
1411
+	 * Parses a date string
1412
+	 *
1413
+	 * @param String $dateString the date string
1414
+	 * @param String $timezone the timezone of a user
1415
+	 * @return Array the time information
1416
+	 *
1417
+	 */
1418 1418
 	public function parseDateString($dateString, $timezone = '')
1419 1419
 	{
1420 1420
 		$time_array = array();
@@ -1447,12 +1447,12 @@  discard block
 block discarded – undo
1447 1447
 	}
1448 1448
 	
1449 1449
 	/**
1450
-	* Parses the direction degrees to working
1451
-	*
1452
-	* @param Float $direction the direction in degrees
1453
-	* @return Array the direction information
1454
-	*
1455
-	*/
1450
+	 * Parses the direction degrees to working
1451
+	 *
1452
+	 * @param Float $direction the direction in degrees
1453
+	 * @return Array the direction information
1454
+	 *
1455
+	 */
1456 1456
 	public function parseDirection($direction = 0)
1457 1457
 	{
1458 1458
 		if ($direction == '') $direction = 0;
@@ -1531,12 +1531,12 @@  discard block
 block discarded – undo
1531 1531
 	
1532 1532
 	
1533 1533
 	/**
1534
-	* Gets Country from latitude/longitude
1535
-	*
1536
-	* @param Float $latitude latitute of the flight
1537
-	* @param Float $longitude longitute of the flight
1538
-	* @return String the countrie
1539
-	*/
1534
+	 * Gets Country from latitude/longitude
1535
+	 *
1536
+	 * @param Float $latitude latitute of the flight
1537
+	 * @param Float $longitude longitute of the flight
1538
+	 * @return String the countrie
1539
+	 */
1540 1540
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1541 1541
 	{
1542 1542
 		global $globalDBdriver, $globalDebug;
@@ -1573,11 +1573,11 @@  discard block
 block discarded – undo
1573 1573
 	}
1574 1574
 
1575 1575
 	/**
1576
-	* Gets Country from iso2
1577
-	*
1578
-	* @param String $iso2 ISO2 country code
1579
-	* @return String the countrie
1580
-	*/
1576
+	 * Gets Country from iso2
1577
+	 *
1578
+	 * @param String $iso2 ISO2 country code
1579
+	 * @return String the countrie
1580
+	 */
1581 1581
 	public function getCountryFromISO2($iso2)
1582 1582
 	{
1583 1583
 		global $globalDBdriver, $globalDebug;
@@ -1606,12 +1606,12 @@  discard block
 block discarded – undo
1606 1606
 
1607 1607
 	
1608 1608
 	/**
1609
-	* Gets the short url from bit.ly
1610
-	*
1611
-	* @param String $url the full url
1612
-	* @return String the bit.ly url
1613
-	*
1614
-	*/
1609
+	 * Gets the short url from bit.ly
1610
+	 *
1611
+	 * @param String $url the full url
1612
+	 * @return String the bit.ly url
1613
+	 *
1614
+	 */
1615 1615
 	public function getBitlyURL($url)
1616 1616
 	{
1617 1617
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT tracker_output.* FROM tracker_output";
6 6
 
7
-class Tracker{
7
+class Tracker {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -18,33 +18,33 @@  discard block
 block discarded – undo
18 18
 	* @return Array the SQL part
19 19
 	*/
20 20
 	
21
-	public function getFilter($filter = array(),$where = false,$and = false) {
21
+	public function getFilter($filter = array(), $where = false, $and = false) {
22 22
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
23 23
 		$filters = array();
24 24
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
25 25
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
26 26
 				$filters = $globalStatsFilters[$globalFilterName];
27 27
 			} else {
28
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
28
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
29 29
 			}
30 30
 		}
31 31
 		if (isset($filter[0]['source'])) {
32
-			$filters = array_merge($filters,$filter);
32
+			$filters = array_merge($filters, $filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
35 35
 		$filter_query_join = '';
36 36
 		$filter_query_where = '';
37
-		foreach($filters as $flt) {
37
+		foreach ($filters as $flt) {
38 38
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
39 39
 				if (isset($flt['source'])) {
40
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
40
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
41 41
 				} else {
42
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
42
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
43 43
 				}
44 44
 			}
45 45
 		}
46 46
 		if (isset($filter['source']) && !empty($filter['source'])) {
47
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
47
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
48 48
 		}
49 49
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
50 50
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74 74
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75 75
 		if ($filter_query_where != '') {
76
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
76
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
77 77
 		}
78 78
 		$filter_query = $filter_query_join.$filter_query_where;
79 79
 		return $filter_query;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	* @return Array the spotter information
89 89
 	*
90 90
 	*/
91
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
91
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
92 92
 	{
93 93
 		date_default_timezone_set('UTC');
94 94
 		if (!is_string($query))
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 			$sth = $this->db->prepare($query.$limitQuery);
109 109
 			$sth->execute($params);
110 110
 		} catch (PDOException $e) {
111
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
111
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
112 112
 			exit();
113 113
 		}
114 114
 		
115 115
 		$num_rows = 0;
116 116
 		$spotter_array = array();
117
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
117
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
118 118
 		{
119 119
 			$num_rows++;
120 120
 			$temp_array = array();
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 				{
171 171
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
172 172
 				} else {
173
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
173
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
174 174
 				}
175 175
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
176
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
177
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
176
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
177
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
178 178
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
179 179
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
180 180
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
181 181
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
182
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
183
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
182
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
183
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
184 184
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
185 185
 					}
186 186
 				}
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 		{
218 218
 			$limit_array = explode(",", $limit);
219 219
 			
220
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
221
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
220
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
221
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
222 222
 			
223 223
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
224 224
 			{
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 			$orderby_query = " ORDER BY tracker_output.date DESC";
236 236
 		}
237 237
 
238
-		$query  = $global_query.$filter_query." ".$orderby_query;
238
+		$query = $global_query.$filter_query." ".$orderby_query;
239 239
 
240
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
240
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
241 241
 
242 242
 		return $spotter_array;
243 243
 	}
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 		if ($id == '') return array();
257 257
 		$additional_query = "tracker_output.famtrackid = :id";
258 258
 		$query_values = array(':id' => $id);
259
-		$query  = $global_query." WHERE ".$additional_query." ";
260
-		$spotter_array = $this->getDataFromDB($query,$query_values);
259
+		$query = $global_query." WHERE ".$additional_query." ";
260
+		$spotter_array = $this->getDataFromDB($query, $query_values);
261 261
 		return $spotter_array;
262 262
 	}
263 263
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 		$query_values = array();
277 277
 		$limit_query = '';
278 278
 		$additional_query = '';
279
-		$filter_query = $this->getFilter($filter,true,true);
279
+		$filter_query = $this->getFilter($filter, true, true);
280 280
 		if ($ident != "")
281 281
 		{
282 282
 			if (!is_string($ident))
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 		{
293 293
 			$limit_array = explode(",", $limit);
294 294
 			
295
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
296
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
295
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
296
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
297 297
 			
298 298
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
299 299
 			{
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		return $spotter_array;
318 318
 	}
319 319
 	
320
-	public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array())
320
+	public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array())
321 321
 	{
322 322
 		global $global_query, $globalTimezone, $globalDBdriver;
323 323
 		
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		$limit_query = '';
326 326
 		$additional_query = '';
327 327
 
328
-		$filter_query = $this->getFilter($filter,true,true);
328
+		$filter_query = $this->getFilter($filter, true, true);
329 329
 		
330 330
 		if ($date != "")
331 331
 		{
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 		{
352 352
 			$limit_array = explode(",", $limit);
353 353
 			
354
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
355
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
354
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
355
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
356 356
 			
357 357
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
358 358
 			{
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
 	* @return Array list of source name
384 384
 	*
385 385
 	*/
386
-	public function getAllSourceName($type = '',$filters = array())
386
+	public function getAllSourceName($type = '', $filters = array())
387 387
 	{
388
-		$filter_query = $this->getFilter($filters,true,true);
388
+		$filter_query = $this->getFilter($filters, true, true);
389 389
 		$query_values = array();
390
-		$query  = "SELECT DISTINCT tracker_output.source_name 
390
+		$query = "SELECT DISTINCT tracker_output.source_name 
391 391
 				FROM tracker_output".$filter_query." tracker_output.source_name <> ''";
392 392
 		if ($type != '') {
393 393
 			$query_values = array(':type' => $type);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 		$source_array = array();
403 403
 		$temp_array = array();
404 404
 		
405
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
405
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
406 406
 		{
407 407
 			$temp_array['source_name'] = $row['source_name'];
408 408
 			$source_array[] = $temp_array;
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 	*/
420 420
 	public function getAllIdents($filters = array())
421 421
 	{
422
-		$filter_query = $this->getFilter($filters,true,true);
423
-		$query  = "SELECT DISTINCT tracker_output.ident
422
+		$filter_query = $this->getFilter($filters, true, true);
423
+		$query = "SELECT DISTINCT tracker_output.ident
424 424
 								FROM tracker_output".$filter_query." tracker_output.ident <> '' 
425 425
 								ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0";
426 426
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 		$ident_array = array();
431 431
 		$temp_array = array();
432 432
 		
433
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
433
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
434 434
 		{
435 435
 			$temp_array['ident'] = $row['ident'];
436 436
 			$ident_array[] = $temp_array;
@@ -455,12 +455,12 @@  discard block
 block discarded – undo
455 455
 		} else $offset = '+00:00';
456 456
 
457 457
 		if ($globalDBdriver == 'mysql') {
458
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
458
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
459 459
 								FROM tracker_output
460 460
 								WHERE tracker_output.date <> '' 
461 461
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
462 462
 		} else {
463
-			$query  = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
463
+			$query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
464 464
 								FROM tracker_output
465 465
 								WHERE tracker_output.date <> '' 
466 466
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 		$date_array = array();
473 473
 		$temp_array = array();
474 474
 		
475
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
475
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
476 476
 		{
477 477
 			$temp_array['date'] = $row['date'];
478 478
 
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 	* @return String success or false
492 492
 	*
493 493
 	*/	
494
-	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
494
+	public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL)
495 495
 	{
496 496
 
497 497
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
498
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
498
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident);
499 499
 
500 500
 		try {
501 501
 			$sth = $this->db->prepare($query);
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
520 520
 	{
521 521
 		$query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid';
522
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
522
+                $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
523 523
 
524 524
 		try {
525 525
 			$sth = $this->db->prepare($query);
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 	* @param String $verticalrate vertival rate of flight
560 560
 	* @return String success or false
561 561
 	*/
562
-	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
562
+	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '')
563 563
 	{
564 564
 		global $globalURL;
565 565
 		
@@ -627,21 +627,21 @@  discard block
 block discarded – undo
627 627
 		}
628 628
 
629 629
     
630
-		if ($date == "" || strtotime($date) < time()-20*60)
630
+		if ($date == "" || strtotime($date) < time() - 20*60)
631 631
 		{
632 632
 			$date = date("Y-m-d H:i:s", time());
633 633
 		}
634 634
 
635
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
636
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
637
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
638
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
639
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
640
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
641
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
642
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
643
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
644
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
635
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
636
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
637
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
638
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
639
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
640
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
641
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
642
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
643
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
644
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
645 645
 	
646 646
                 if ($latitude == '' && $longitude == '') {
647 647
             		$latitude = 0;
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
             	}
650 650
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
651 651
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
652
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
652
+                $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
653 653
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
654 654
 
655
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
655
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type);
656 656
 
657 657
 		try {
658 658
 		        
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 	{
679 679
 		global $globalDBdriver, $globalTimezone;
680 680
 		if ($globalDBdriver == 'mysql') {
681
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
681
+			$query = "SELECT tracker_output.ident FROM tracker_output 
682 682
 								WHERE tracker_output.ident = :ident 
683 683
 								AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
684 684
 								AND tracker_output.date < UTC_TIMESTAMP()";
685 685
 			$query_data = array(':ident' => $ident);
686 686
 		} else {
687
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
687
+			$query = "SELECT tracker_output.ident FROM tracker_output 
688 688
 								WHERE tracker_output.ident = :ident 
689 689
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
690 690
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 		
694 694
 		$sth = $this->db->prepare($query);
695 695
 		$sth->execute($query_data);
696
-    		$ident_result='';
697
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
696
+    		$ident_result = '';
697
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
698 698
 		{
699 699
 			$ident_result = $row['ident'];
700 700
 		}
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
 				return false;
721 721
 			} else {
722 722
 				$q_array = explode(" ", $q);
723
-				foreach ($q_array as $q_item){
724
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
723
+				foreach ($q_array as $q_item) {
724
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
725 725
 					$additional_query .= " AND (";
726 726
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%')";
727 727
 					$additional_query .= ")";
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
 			}
730 730
 		}
731 731
 		if ($globalDBdriver == 'mysql') {
732
-			$query  = "SELECT tracker_output.* FROM tracker_output 
732
+			$query = "SELECT tracker_output.* FROM tracker_output 
733 733
 				WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
734 734
 				AND tracker_output.date < UTC_TIMESTAMP()";
735 735
 		} else {
736
-			$query  = "SELECT tracker_output.* FROM tracker_output 
736
+			$query = "SELECT tracker_output.* FROM tracker_output 
737 737
 				WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
738 738
 				AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
739 739
 		}
@@ -752,16 +752,16 @@  discard block
 block discarded – undo
752 752
 	*
753 753
 	*/
754 754
 
755
-	public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
755
+	public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
756 756
 	{
757 757
 		global $globalDBdriver, $globalArchive;
758 758
 		//$filter_query = $this->getFilter($filters,true,true);
759
-		$Connection= new Connection($this->db);
759
+		$Connection = new Connection($this->db);
760 760
 		if (!$Connection->tableExists('countries')) return array();
761 761
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
762 762
 			require_once('class.TrackerLive.php');
763 763
 			$TrackerLive = new TrackerLive();
764
-			$filter_query = $TrackerLive->getFilter($filters,true,true);
764
+			$filter_query = $TrackerLive->getFilter($filters, true, true);
765 765
 			$filter_query .= ' over_country IS NOT NULL';
766 766
 			if ($olderthanmonths > 0) {
767 767
 				if ($globalDBdriver == 'mysql') {
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 		} else {
782 782
 			require_once('class.TrackerArchive.php');
783 783
 			$TrackerArchive = new TrackerArchive();
784
-			$filter_query = $TrackerArchive->getFilter($filters,true,true);
784
+			$filter_query = $TrackerArchive->getFilter($filters, true, true);
785 785
 			$filter_query .= ' over_country IS NOT NULL';
786 786
 			if ($olderthanmonths > 0) {
787 787
 				if ($globalDBdriver == 'mysql') {
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		$flight_array = array();
810 810
 		$temp_array = array();
811 811
         
812
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
812
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
813 813
 		{
814 814
 			$temp_array['flight_count'] = $row['nb'];
815 815
 			$temp_array['flight_country'] = $row['name'];
@@ -826,11 +826,11 @@  discard block
 block discarded – undo
826 826
 	* @return Array the callsign list
827 827
 	*
828 828
 	*/
829
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
829
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
830 830
 	{
831 831
 		global $globalDBdriver;
832
-		$filter_query = $this->getFilter($filters,true,true);
833
-		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
832
+		$filter_query = $this->getFilter($filters, true, true);
833
+		$query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
834 834
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
835 835
 		 if ($olderthanmonths > 0) {
836 836
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -844,28 +844,28 @@  discard block
 block discarded – undo
844 844
 		if ($year != '') {
845 845
 			if ($globalDBdriver == 'mysql') {
846 846
 				$query .= " AND YEAR(tracker_output.date) = :year";
847
-				$query_values = array_merge($query_values,array(':year' => $year));
847
+				$query_values = array_merge($query_values, array(':year' => $year));
848 848
 			} else {
849 849
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
850
-				$query_values = array_merge($query_values,array(':year' => $year));
850
+				$query_values = array_merge($query_values, array(':year' => $year));
851 851
 			}
852 852
 		}
853 853
 		if ($month != '') {
854 854
 			if ($globalDBdriver == 'mysql') {
855 855
 				$query .= " AND MONTH(tracker_output.date) = :month";
856
-				$query_values = array_merge($query_values,array(':month' => $month));
856
+				$query_values = array_merge($query_values, array(':month' => $month));
857 857
 			} else {
858 858
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
859
-				$query_values = array_merge($query_values,array(':month' => $month));
859
+				$query_values = array_merge($query_values, array(':month' => $month));
860 860
 			}
861 861
 		}
862 862
 		if ($day != '') {
863 863
 			if ($globalDBdriver == 'mysql') {
864 864
 				$query .= " AND DAY(tracker_output.date) = :day";
865
-				$query_values = array_merge($query_values,array(':day' => $day));
865
+				$query_values = array_merge($query_values, array(':day' => $day));
866 866
 			} else {
867 867
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
868
-				$query_values = array_merge($query_values,array(':day' => $day));
868
+				$query_values = array_merge($query_values, array(':day' => $day));
869 869
 			}
870 870
 		}
871 871
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 		$callsign_array = array();
878 878
 		$temp_array = array();
879 879
         
880
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
880
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
881 881
 		{
882 882
 			$temp_array['callsign_icao'] = $row['ident'];
883 883
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 		$date_array = array();
930 930
 		$temp_array = array();
931 931
         
932
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
932
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
933 933
 		{
934 934
 			$temp_array['date_name'] = $row['date_name'];
935 935
 			$temp_array['date_count'] = $row['date_count'];
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 			$datetime = new DateTime();
956 956
 			$offset = $datetime->format('P');
957 957
 		} else $offset = '+00:00';
958
-		$filter_query = $this->getFilter($filters,true,true);
958
+		$filter_query = $this->getFilter($filters, true, true);
959 959
 		if ($globalDBdriver == 'mysql') {
960 960
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
961 961
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
 		$date_array = array();
977 977
 		$temp_array = array();
978 978
         
979
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
979
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
980 980
 		{
981 981
 			$temp_array['date_name'] = $row['date_name'];
982 982
 			$temp_array['date_count'] = $row['date_count'];
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 			$datetime = new DateTime();
1002 1002
 			$offset = $datetime->format('P');
1003 1003
 		} else $offset = '+00:00';
1004
-		$filter_query = $this->getFilter($filters,true,true);
1004
+		$filter_query = $this->getFilter($filters, true, true);
1005 1005
 		if ($globalDBdriver == 'mysql') {
1006 1006
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1007 1007
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 		$date_array = array();
1023 1023
 		$temp_array = array();
1024 1024
         
1025
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1025
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1026 1026
 		{
1027 1027
 			$temp_array['date_name'] = $row['date_name'];
1028 1028
 			$temp_array['date_count'] = $row['date_count'];
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 		$date_array = array();
1070 1070
 		$temp_array = array();
1071 1071
         
1072
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1072
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1073 1073
 		{
1074 1074
 			$temp_array['month_name'] = $row['month_name'];
1075 1075
 			$temp_array['year_name'] = $row['year_name'];
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 			$datetime = new DateTime();
1099 1099
 			$offset = $datetime->format('P');
1100 1100
 		} else $offset = '+00:00';
1101
-		$filter_query = $this->getFilter($filters,true,true);
1101
+		$filter_query = $this->getFilter($filters, true, true);
1102 1102
 		if ($globalDBdriver == 'mysql') {
1103 1103
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1104 1104
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 		$date_array = array();
1120 1120
 		$temp_array = array();
1121 1121
         
1122
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1122
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1123 1123
 		{
1124 1124
 			$temp_array['year_name'] = $row['year_name'];
1125 1125
 			$temp_array['month_name'] = $row['month_name'];
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 	* @return Array the hour list
1140 1140
 	*
1141 1141
 	*/
1142
-	public function countAllHours($orderby,$filters = array())
1142
+	public function countAllHours($orderby, $filters = array())
1143 1143
 	{
1144 1144
 		global $globalTimezone, $globalDBdriver;
1145 1145
 		if ($globalTimezone != '') {
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 		$hour_array = array();
1188 1188
 		$temp_array = array();
1189 1189
         
1190
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1190
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1191 1191
 		{
1192 1192
 			$temp_array['hour_name'] = $row['hour_name'];
1193 1193
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1209,8 +1209,8 @@  discard block
 block discarded – undo
1209 1209
 	public function countAllHoursByDate($date, $filters = array())
1210 1210
 	{
1211 1211
 		global $globalTimezone, $globalDBdriver;
1212
-		$filter_query = $this->getFilter($filters,true,true);
1213
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1212
+		$filter_query = $this->getFilter($filters, true, true);
1213
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1214 1214
 		if ($globalTimezone != '') {
1215 1215
 			date_default_timezone_set($globalTimezone);
1216 1216
 			$datetime = new DateTime($date);
@@ -1218,12 +1218,12 @@  discard block
 block discarded – undo
1218 1218
 		} else $offset = '+00:00';
1219 1219
 
1220 1220
 		if ($globalDBdriver == 'mysql') {
1221
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1221
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1222 1222
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date
1223 1223
 								GROUP BY hour_name 
1224 1224
 								ORDER BY hour_name ASC";
1225 1225
 		} else {
1226
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1226
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1227 1227
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1228 1228
 								GROUP BY hour_name 
1229 1229
 								ORDER BY hour_name ASC";
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 		$hour_array = array();
1236 1236
 		$temp_array = array();
1237 1237
         
1238
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1238
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1239 1239
 		{
1240 1240
 			$temp_array['hour_name'] = $row['hour_name'];
1241 1241
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1257,8 +1257,8 @@  discard block
 block discarded – undo
1257 1257
 	public function countAllHoursByIdent($ident, $filters = array())
1258 1258
 	{
1259 1259
 		global $globalTimezone, $globalDBdriver;
1260
-		$filter_query = $this->getFilter($filters,true,true);
1261
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1260
+		$filter_query = $this->getFilter($filters, true, true);
1261
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1262 1262
 		if ($globalTimezone != '') {
1263 1263
 			date_default_timezone_set($globalTimezone);
1264 1264
 			$datetime = new DateTime();
@@ -1266,12 +1266,12 @@  discard block
 block discarded – undo
1266 1266
 		} else $offset = '+00:00';
1267 1267
 
1268 1268
 		if ($globalDBdriver == 'mysql') {
1269
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1269
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1270 1270
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1271 1271
 								GROUP BY hour_name 
1272 1272
 								ORDER BY hour_name ASC";
1273 1273
 		} else {
1274
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1274
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1275 1275
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1276 1276
 								GROUP BY hour_name 
1277 1277
 								ORDER BY hour_name ASC";
@@ -1279,12 +1279,12 @@  discard block
 block discarded – undo
1279 1279
       
1280 1280
 		
1281 1281
 		$sth = $this->db->prepare($query);
1282
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1282
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1283 1283
       
1284 1284
 		$hour_array = array();
1285 1285
 		$temp_array = array();
1286 1286
         
1287
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1287
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1288 1288
 		{
1289 1289
 			$temp_array['hour_name'] = $row['hour_name'];
1290 1290
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1303,33 +1303,33 @@  discard block
 block discarded – undo
1303 1303
 	* @return Integer the number of flights
1304 1304
 	*
1305 1305
 	*/
1306
-	public function countOverallTracker($filters = array(),$year = '',$month = '')
1306
+	public function countOverallTracker($filters = array(), $year = '', $month = '')
1307 1307
 	{
1308 1308
 		global $globalDBdriver;
1309 1309
 		//$queryi  = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1310
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.ident) AS flight_count FROM tracker_output";
1310
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS flight_count FROM tracker_output";
1311 1311
 		$query_values = array();
1312 1312
 		$query = '';
1313 1313
 		if ($year != '') {
1314 1314
 			if ($globalDBdriver == 'mysql') {
1315 1315
 				$query .= " AND YEAR(tracker_output.date) = :year";
1316
-				$query_values = array_merge($query_values,array(':year' => $year));
1316
+				$query_values = array_merge($query_values, array(':year' => $year));
1317 1317
 			} else {
1318 1318
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1319
-				$query_values = array_merge($query_values,array(':year' => $year));
1319
+				$query_values = array_merge($query_values, array(':year' => $year));
1320 1320
 			}
1321 1321
 		}
1322 1322
 		if ($month != '') {
1323 1323
 			if ($globalDBdriver == 'mysql') {
1324 1324
 				$query .= " AND MONTH(tracker_output.date) = :month";
1325
-				$query_values = array_merge($query_values,array(':month' => $month));
1325
+				$query_values = array_merge($query_values, array(':month' => $month));
1326 1326
 			} else {
1327 1327
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1328
-				$query_values = array_merge($query_values,array(':month' => $month));
1328
+				$query_values = array_merge($query_values, array(':month' => $month));
1329 1329
 			}
1330 1330
 		}
1331 1331
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1332
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1332
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1333 1333
 		
1334 1334
 		$sth = $this->db->prepare($queryi);
1335 1335
 		$sth->execute($query_values);
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
 	public function countAllHoursFromToday($filters = array())
1347 1347
 	{
1348 1348
 		global $globalTimezone, $globalDBdriver;
1349
-		$filter_query = $this->getFilter($filters,true,true);
1349
+		$filter_query = $this->getFilter($filters, true, true);
1350 1350
 		if ($globalTimezone != '') {
1351 1351
 			date_default_timezone_set($globalTimezone);
1352 1352
 			$datetime = new DateTime();
@@ -1354,12 +1354,12 @@  discard block
 block discarded – undo
1354 1354
 		} else $offset = '+00:00';
1355 1355
 
1356 1356
 		if ($globalDBdriver == 'mysql') {
1357
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1357
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1358 1358
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE()
1359 1359
 								GROUP BY hour_name 
1360 1360
 								ORDER BY hour_name ASC";
1361 1361
 		} else {
1362
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1362
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1363 1363
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1364 1364
 								GROUP BY hour_name 
1365 1365
 								ORDER BY hour_name ASC";
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
 		$hour_array = array();
1372 1372
 		$temp_array = array();
1373 1373
         
1374
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1374
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1375 1375
 		{
1376 1376
 			$temp_array['hour_name'] = $row['hour_name'];
1377 1377
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1390,9 +1390,9 @@  discard block
 block discarded – undo
1390 1390
 	*/
1391 1391
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1392 1392
 	{
1393
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
1393
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
1394 1394
 
1395
-		$query  = "SELECT tracker_output.tracker_id
1395
+		$query = "SELECT tracker_output.tracker_id
1396 1396
 				FROM tracker_output 
1397 1397
 				WHERE tracker_output.famtrackid = '".$famtrackid."'";
1398 1398
         
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 		$sth = $this->db->prepare($query);
1401 1401
 		$sth->execute();
1402 1402
 
1403
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1403
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1404 1404
 		{
1405 1405
 			return $row['tracker_id'];
1406 1406
 		}
@@ -1425,23 +1425,23 @@  discard block
 block discarded – undo
1425 1425
 		}
1426 1426
 		
1427 1427
 		$current_date = date("Y-m-d H:i:s");
1428
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1428
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1429 1429
 		
1430 1430
 		$diff = abs(strtotime($current_date) - strtotime($date));
1431 1431
 
1432
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1432
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1433 1433
 		$years = $time_array['years'];
1434 1434
 		
1435
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1435
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1436 1436
 		$months = $time_array['months'];
1437 1437
 		
1438
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1438
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1439 1439
 		$days = $time_array['days'];
1440
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1440
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1441 1441
 		$hours = $time_array['hours'];
1442
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1442
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1443 1443
 		$minutes = $time_array['minutes'];
1444
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1444
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1445 1445
 		
1446 1446
 		return $time_array;
1447 1447
 	}
@@ -1464,63 +1464,63 @@  discard block
 block discarded – undo
1464 1464
 			$temp_array['direction_degree'] = $direction;
1465 1465
 			$temp_array['direction_shortname'] = "N";
1466 1466
 			$temp_array['direction_fullname'] = "North";
1467
-		} elseif ($direction >= 22.5 && $direction < 45){
1467
+		} elseif ($direction >= 22.5 && $direction < 45) {
1468 1468
 			$temp_array['direction_degree'] = $direction;
1469 1469
 			$temp_array['direction_shortname'] = "NNE";
1470 1470
 			$temp_array['direction_fullname'] = "North-Northeast";
1471
-		} elseif ($direction >= 45 && $direction < 67.5){
1471
+		} elseif ($direction >= 45 && $direction < 67.5) {
1472 1472
 			$temp_array['direction_degree'] = $direction;
1473 1473
 			$temp_array['direction_shortname'] = "NE";
1474 1474
 			$temp_array['direction_fullname'] = "Northeast";
1475
-		} elseif ($direction >= 67.5 && $direction < 90){
1475
+		} elseif ($direction >= 67.5 && $direction < 90) {
1476 1476
 			$temp_array['direction_degree'] = $direction;
1477 1477
 			$temp_array['direction_shortname'] = "ENE";
1478 1478
 			$temp_array['direction_fullname'] = "East-Northeast";
1479
-		} elseif ($direction >= 90 && $direction < 112.5){
1479
+		} elseif ($direction >= 90 && $direction < 112.5) {
1480 1480
 			$temp_array['direction_degree'] = $direction;
1481 1481
 			$temp_array['direction_shortname'] = "E";
1482 1482
 			$temp_array['direction_fullname'] = "East";
1483
-		} elseif ($direction >= 112.5 && $direction < 135){
1483
+		} elseif ($direction >= 112.5 && $direction < 135) {
1484 1484
 			$temp_array['direction_degree'] = $direction;
1485 1485
 			$temp_array['direction_shortname'] = "ESE";
1486 1486
 			$temp_array['direction_fullname'] = "East-Southeast";
1487
-		} elseif ($direction >= 135 && $direction < 157.5){
1487
+		} elseif ($direction >= 135 && $direction < 157.5) {
1488 1488
 			$temp_array['direction_degree'] = $direction;
1489 1489
 			$temp_array['direction_shortname'] = "SE";
1490 1490
 			$temp_array['direction_fullname'] = "Southeast";
1491
-		} elseif ($direction >= 157.5 && $direction < 180){
1491
+		} elseif ($direction >= 157.5 && $direction < 180) {
1492 1492
 			$temp_array['direction_degree'] = $direction;
1493 1493
 			$temp_array['direction_shortname'] = "SSE";
1494 1494
 			$temp_array['direction_fullname'] = "South-Southeast";
1495
-		} elseif ($direction >= 180 && $direction < 202.5){
1495
+		} elseif ($direction >= 180 && $direction < 202.5) {
1496 1496
 			$temp_array['direction_degree'] = $direction;
1497 1497
 			$temp_array['direction_shortname'] = "S";
1498 1498
 			$temp_array['direction_fullname'] = "South";
1499
-		} elseif ($direction >= 202.5 && $direction < 225){
1499
+		} elseif ($direction >= 202.5 && $direction < 225) {
1500 1500
 			$temp_array['direction_degree'] = $direction;
1501 1501
 			$temp_array['direction_shortname'] = "SSW";
1502 1502
 			$temp_array['direction_fullname'] = "South-Southwest";
1503
-		} elseif ($direction >= 225 && $direction < 247.5){
1503
+		} elseif ($direction >= 225 && $direction < 247.5) {
1504 1504
 			$temp_array['direction_degree'] = $direction;
1505 1505
 			$temp_array['direction_shortname'] = "SW";
1506 1506
 			$temp_array['direction_fullname'] = "Southwest";
1507
-		} elseif ($direction >= 247.5 && $direction < 270){
1507
+		} elseif ($direction >= 247.5 && $direction < 270) {
1508 1508
 			$temp_array['direction_degree'] = $direction;
1509 1509
 			$temp_array['direction_shortname'] = "WSW";
1510 1510
 			$temp_array['direction_fullname'] = "West-Southwest";
1511
-		} elseif ($direction >= 270 && $direction < 292.5){
1511
+		} elseif ($direction >= 270 && $direction < 292.5) {
1512 1512
 			$temp_array['direction_degree'] = $direction;
1513 1513
 			$temp_array['direction_shortname'] = "W";
1514 1514
 			$temp_array['direction_fullname'] = "West";
1515
-		} elseif ($direction >= 292.5 && $direction < 315){
1515
+		} elseif ($direction >= 292.5 && $direction < 315) {
1516 1516
 			$temp_array['direction_degree'] = $direction;
1517 1517
 			$temp_array['direction_shortname'] = "WNW";
1518 1518
 			$temp_array['direction_fullname'] = "West-Northwest";
1519
-		} elseif ($direction >= 315 && $direction < 337.5){
1519
+		} elseif ($direction >= 315 && $direction < 337.5) {
1520 1520
 			$temp_array['direction_degree'] = $direction;
1521 1521
 			$temp_array['direction_shortname'] = "NW";
1522 1522
 			$temp_array['direction_fullname'] = "Northwest";
1523
-		} elseif ($direction >= 337.5 && $direction < 360){
1523
+		} elseif ($direction >= 337.5 && $direction < 360) {
1524 1524
 			$temp_array['direction_degree'] = $direction;
1525 1525
 			$temp_array['direction_shortname'] = "NNW";
1526 1526
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1537,11 +1537,11 @@  discard block
 block discarded – undo
1537 1537
 	* @param Float $longitude longitute of the flight
1538 1538
 	* @return String the countrie
1539 1539
 	*/
1540
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1540
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1541 1541
 	{
1542 1542
 		global $globalDBdriver, $globalDebug;
1543
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1544
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1543
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1544
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1545 1545
 	
1546 1546
 		$Connection = new Connection($this->db);
1547 1547
 		if (!$Connection->tableExists('countries')) return '';
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
 	public function getCountryFromISO2($iso2)
1582 1582
 	{
1583 1583
 		global $globalDBdriver, $globalDebug;
1584
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1584
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1585 1585
 	
1586 1586
 		$Connection = new Connection($this->db);
1587 1587
 		if (!$Connection->tableExists('countries')) return '';
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 		
1630 1630
 		$bitly_data = json_decode($bitly_data);
1631 1631
 		$bitly_url = '';
1632
-		if ($bitly_data->status_txt = "OK"){
1632
+		if ($bitly_data->status_txt = "OK") {
1633 1633
 			$bitly_url = $bitly_data->data->url;
1634 1634
 		}
1635 1635
 
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
 
1640 1640
 	public function getOrderBy()
1641 1641
 	{
1642
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1642
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1643 1643
 		
1644 1644
 		return $orderby;
1645 1645
 		
Please login to merge, or discard this patch.
Braces   +149 added lines, -53 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 		if (isset($filter[0]['source'])) {
32 32
 			$filters = array_merge($filters,$filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) {
35
+			$filter = array_merge($filter,$globalFilter);
36
+		}
35 37
 		$filter_query_join = '';
36 38
 		$filter_query_where = '';
37 39
 		foreach($filters as $flt) {
@@ -70,8 +72,11 @@  discard block
 block discarded – undo
70 72
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
71 73
 			}
72 74
 		}
73
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75
+		if ($filter_query_where == '' && $where) {
76
+			$filter_query_where = ' WHERE';
77
+		} elseif ($filter_query_where != '' && $and) {
78
+			$filter_query_where .= ' AND';
79
+		}
75 80
 		if ($filter_query_where != '') {
76 81
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
77 82
 		}
@@ -125,26 +130,43 @@  discard block
 block discarded – undo
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
126 131
 			} elseif (isset($row['spotter_archive_output_id'])) {
127 132
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
128
-			*/} 
129
-			elseif (isset($row['trackerid'])) {
133
+			*/} elseif (isset($row['trackerid'])) {
130 134
 				$temp_array['trackerid'] = $row['trackerid'];
131 135
 			} else {
132 136
 				$temp_array['trackerid'] = '';
133 137
 			}
134
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
135
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
136
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
138
+			if (isset($row['famtrackid'])) {
139
+				$temp_array['famtrackid'] = $row['famtrackid'];
140
+			}
141
+			if (isset($row['type'])) {
142
+				$temp_array['type'] = $row['type'];
143
+			}
144
+			if (isset($row['comment'])) {
145
+				$temp_array['comment'] = $row['comment'];
146
+			}
137 147
 			$temp_array['ident'] = $row['ident'];
138
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
139
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
140
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
141
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
148
+			if (isset($row['latitude'])) {
149
+				$temp_array['latitude'] = $row['latitude'];
150
+			}
151
+			if (isset($row['longitude'])) {
152
+				$temp_array['longitude'] = $row['longitude'];
153
+			}
154
+			if (isset($row['format_source'])) {
155
+				$temp_array['format_source'] = $row['format_source'];
156
+			}
157
+			if (isset($row['altitude'])) {
158
+				$temp_array['altitude'] = $row['altitude'];
159
+			}
142 160
 			if (isset($row['heading'])) {
143 161
 				$temp_array['heading'] = $row['heading'];
144 162
 				$heading_direction = $this->parseDirection($row['heading']);
145
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
163
+				if (isset($heading_direction[0]['direction_fullname'])) {
164
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
165
+				}
166
+			}
167
+			if (isset($row['ground_speed'])) {
168
+				$temp_array['ground_speed'] = $row['ground_speed'];
146 169
 			}
147
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
148 170
 			
149 171
 			if (isset($row['date'])) {
150 172
 				$dateArray = $this->parseDateString($row['date']);
@@ -187,13 +209,21 @@  discard block
 block discarded – undo
187 209
 			}
188 210
 			
189 211
 			$fromsource = NULL;
190
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
191
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
192
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
212
+			if (isset($row['source_name']) && $row['source_name'] != '') {
213
+				$temp_array['source_name'] = $row['source_name'];
214
+			}
215
+			if (isset($row['over_country']) && $row['over_country'] != '') {
216
+				$temp_array['over_country'] = $row['over_country'];
217
+			}
218
+			if (isset($row['distance']) && $row['distance'] != '') {
219
+				$temp_array['distance'] = $row['distance'];
220
+			}
193 221
 			$temp_array['query_number_rows'] = $num_rows;
194 222
 			$spotter_array[] = $temp_array;
195 223
 		}
196
-		if ($num_rows == 0) return array();
224
+		if ($num_rows == 0) {
225
+			return array();
226
+		}
197 227
 		$spotter_array[0]['query_number_rows'] = $num_rows;
198 228
 		return $spotter_array;
199 229
 	}	
@@ -224,8 +254,12 @@  discard block
 block discarded – undo
224 254
 			{
225 255
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
226 256
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
227
-			} else $limit_query = "";
228
-		} else $limit_query = "";
257
+			} else {
258
+				$limit_query = "";
259
+			}
260
+		} else {
261
+			$limit_query = "";
262
+		}
229 263
 		
230 264
 		if ($sort != "")
231 265
 		{
@@ -253,7 +287,9 @@  discard block
 block discarded – undo
253 287
 		global $global_query;
254 288
 		
255 289
 		date_default_timezone_set('UTC');
256
-		if ($id == '') return array();
290
+		if ($id == '') {
291
+			return array();
292
+		}
257 293
 		$additional_query = "tracker_output.famtrackid = :id";
258 294
 		$query_values = array(':id' => $id);
259 295
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -396,8 +432,11 @@  discard block
 block discarded – undo
396 432
 		$query .= " ORDER BY tracker_output.source_name ASC";
397 433
 
398 434
 		$sth = $this->db->prepare($query);
399
-		if (!empty($query_values)) $sth->execute($query_values);
400
-		else $sth->execute();
435
+		if (!empty($query_values)) {
436
+			$sth->execute($query_values);
437
+		} else {
438
+			$sth->execute();
439
+		}
401 440
 
402 441
 		$source_array = array();
403 442
 		$temp_array = array();
@@ -452,7 +491,9 @@  discard block
 block discarded – undo
452 491
 			date_default_timezone_set($globalTimezone);
453 492
 			$datetime = new DateTime();
454 493
 			$offset = $datetime->format('P');
455
-		} else $offset = '+00:00';
494
+		} else {
495
+			$offset = '+00:00';
496
+		}
456 497
 
457 498
 		if ($globalDBdriver == 'mysql') {
458 499
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -608,7 +649,9 @@  discard block
 block discarded – undo
608 649
 			{
609 650
 				return false;
610 651
 			}
611
-		} else $altitude = 0;
652
+		} else {
653
+			$altitude = 0;
654
+		}
612 655
 		
613 656
 		if ($heading != "")
614 657
 		{
@@ -647,8 +690,12 @@  discard block
 block discarded – undo
647 690
             		$latitude = 0;
648 691
             		$longitude = 0;
649 692
             	}
650
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
651
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
693
+                if ($heading == '' || $Common->isInteger($heading) === false) {
694
+                	$heading = 0;
695
+                }
696
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
697
+                	$groundspeed = 0;
698
+                }
652 699
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
653 700
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
654 701
 
@@ -757,7 +804,9 @@  discard block
 block discarded – undo
757 804
 		global $globalDBdriver, $globalArchive;
758 805
 		//$filter_query = $this->getFilter($filters,true,true);
759 806
 		$Connection= new Connection($this->db);
760
-		if (!$Connection->tableExists('countries')) return array();
807
+		if (!$Connection->tableExists('countries')) {
808
+			return array();
809
+		}
761 810
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
762 811
 			require_once('class.TrackerLive.php');
763 812
 			$TrackerLive = new TrackerLive();
@@ -800,7 +849,9 @@  discard block
 block discarded – undo
800 849
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country ";
801 850
 		}
802 851
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
803
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
852
+		if ($limit) {
853
+			$query .= " LIMIT 10 OFFSET 0";
854
+		}
804 855
       
805 856
 		
806 857
 		$sth = $this->db->prepare($query);
@@ -833,12 +884,18 @@  discard block
 block discarded – undo
833 884
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
834 885
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
835 886
 		 if ($olderthanmonths > 0) {
836
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
837
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
887
+			if ($globalDBdriver == 'mysql') {
888
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
889
+			} else {
890
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
891
+			}
838 892
 		}
839 893
 		if ($sincedate != '') {
840
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
841
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
894
+			if ($globalDBdriver == 'mysql') {
895
+				$query .= " AND tracker_output.date > '".$sincedate."'";
896
+			} else {
897
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
898
+			}
842 899
 		}
843 900
 		$query_values = array();
844 901
 		if ($year != '') {
@@ -869,7 +926,9 @@  discard block
 block discarded – undo
869 926
 			}
870 927
 		}
871 928
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
872
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
929
+		if ($limit) {
930
+			$query .= " LIMIT 10 OFFSET 0";
931
+		}
873 932
       		
874 933
 		$sth = $this->db->prepare($query);
875 934
 		$sth->execute($query_values);
@@ -904,7 +963,9 @@  discard block
 block discarded – undo
904 963
 			date_default_timezone_set($globalTimezone);
905 964
 			$datetime = new DateTime();
906 965
 			$offset = $datetime->format('P');
907
-		} else $offset = '+00:00';
966
+		} else {
967
+			$offset = '+00:00';
968
+		}
908 969
 
909 970
 		if ($globalDBdriver == 'mysql') {
910 971
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -954,7 +1015,9 @@  discard block
 block discarded – undo
954 1015
 			date_default_timezone_set($globalTimezone);
955 1016
 			$datetime = new DateTime();
956 1017
 			$offset = $datetime->format('P');
957
-		} else $offset = '+00:00';
1018
+		} else {
1019
+			$offset = '+00:00';
1020
+		}
958 1021
 		$filter_query = $this->getFilter($filters,true,true);
959 1022
 		if ($globalDBdriver == 'mysql') {
960 1023
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1000,7 +1063,9 @@  discard block
 block discarded – undo
1000 1063
 			date_default_timezone_set($globalTimezone);
1001 1064
 			$datetime = new DateTime();
1002 1065
 			$offset = $datetime->format('P');
1003
-		} else $offset = '+00:00';
1066
+		} else {
1067
+			$offset = '+00:00';
1068
+		}
1004 1069
 		$filter_query = $this->getFilter($filters,true,true);
1005 1070
 		if ($globalDBdriver == 'mysql') {
1006 1071
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1048,7 +1113,9 @@  discard block
 block discarded – undo
1048 1113
 			date_default_timezone_set($globalTimezone);
1049 1114
 			$datetime = new DateTime();
1050 1115
 			$offset = $datetime->format('P');
1051
-		} else $offset = '+00:00';
1116
+		} else {
1117
+			$offset = '+00:00';
1118
+		}
1052 1119
 
1053 1120
 		if ($globalDBdriver == 'mysql') {
1054 1121
 			$query  = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1097,7 +1164,9 @@  discard block
 block discarded – undo
1097 1164
 			date_default_timezone_set($globalTimezone);
1098 1165
 			$datetime = new DateTime();
1099 1166
 			$offset = $datetime->format('P');
1100
-		} else $offset = '+00:00';
1167
+		} else {
1168
+			$offset = '+00:00';
1169
+		}
1101 1170
 		$filter_query = $this->getFilter($filters,true,true);
1102 1171
 		if ($globalDBdriver == 'mysql') {
1103 1172
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1146,7 +1215,9 @@  discard block
 block discarded – undo
1146 1215
 			date_default_timezone_set($globalTimezone);
1147 1216
 			$datetime = new DateTime();
1148 1217
 			$offset = $datetime->format('P');
1149
-		} else $offset = '+00:00';
1218
+		} else {
1219
+			$offset = '+00:00';
1220
+		}
1150 1221
 
1151 1222
 		$orderby_sql = '';
1152 1223
 		if ($orderby == "hour")
@@ -1215,7 +1286,9 @@  discard block
 block discarded – undo
1215 1286
 			date_default_timezone_set($globalTimezone);
1216 1287
 			$datetime = new DateTime($date);
1217 1288
 			$offset = $datetime->format('P');
1218
-		} else $offset = '+00:00';
1289
+		} else {
1290
+			$offset = '+00:00';
1291
+		}
1219 1292
 
1220 1293
 		if ($globalDBdriver == 'mysql') {
1221 1294
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1263,7 +1336,9 @@  discard block
 block discarded – undo
1263 1336
 			date_default_timezone_set($globalTimezone);
1264 1337
 			$datetime = new DateTime();
1265 1338
 			$offset = $datetime->format('P');
1266
-		} else $offset = '+00:00';
1339
+		} else {
1340
+			$offset = '+00:00';
1341
+		}
1267 1342
 
1268 1343
 		if ($globalDBdriver == 'mysql') {
1269 1344
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1328,8 +1403,11 @@  discard block
 block discarded – undo
1328 1403
 				$query_values = array_merge($query_values,array(':month' => $month));
1329 1404
 			}
1330 1405
 		}
1331
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1332
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1406
+		if (empty($query_values)) {
1407
+			$queryi .= $this->getFilter($filters);
1408
+		} else {
1409
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1410
+		}
1333 1411
 		
1334 1412
 		$sth = $this->db->prepare($queryi);
1335 1413
 		$sth->execute($query_values);
@@ -1351,7 +1429,9 @@  discard block
 block discarded – undo
1351 1429
 			date_default_timezone_set($globalTimezone);
1352 1430
 			$datetime = new DateTime();
1353 1431
 			$offset = $datetime->format('P');
1354
-		} else $offset = '+00:00';
1432
+		} else {
1433
+			$offset = '+00:00';
1434
+		}
1355 1435
 
1356 1436
 		if ($globalDBdriver == 'mysql') {
1357 1437
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1455,7 +1535,9 @@  discard block
 block discarded – undo
1455 1535
 	*/
1456 1536
 	public function parseDirection($direction = 0)
1457 1537
 	{
1458
-		if ($direction == '') $direction = 0;
1538
+		if ($direction == '') {
1539
+			$direction = 0;
1540
+		}
1459 1541
 		$direction_array = array();
1460 1542
 		$temp_array = array();
1461 1543
 
@@ -1544,7 +1626,9 @@  discard block
 block discarded – undo
1544 1626
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1545 1627
 	
1546 1628
 		$Connection = new Connection($this->db);
1547
-		if (!$Connection->tableExists('countries')) return '';
1629
+		if (!$Connection->tableExists('countries')) {
1630
+			return '';
1631
+		}
1548 1632
 	
1549 1633
 		try {
1550 1634
 			/*
@@ -1564,9 +1648,13 @@  discard block
 block discarded – undo
1564 1648
 			$sth->closeCursor();
1565 1649
 			if (count($row) > 0) {
1566 1650
 				return $row;
1567
-			} else return '';
1651
+			} else {
1652
+				return '';
1653
+			}
1568 1654
 		} catch (PDOException $e) {
1569
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1655
+			if (isset($globalDebug) && $globalDebug) {
1656
+				echo 'Error : '.$e->getMessage()."\n";
1657
+			}
1570 1658
 			return '';
1571 1659
 		}
1572 1660
 	
@@ -1584,7 +1672,9 @@  discard block
 block discarded – undo
1584 1672
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1585 1673
 	
1586 1674
 		$Connection = new Connection($this->db);
1587
-		if (!$Connection->tableExists('countries')) return '';
1675
+		if (!$Connection->tableExists('countries')) {
1676
+			return '';
1677
+		}
1588 1678
 	
1589 1679
 		try {
1590 1680
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1596,9 +1686,13 @@  discard block
 block discarded – undo
1596 1686
 			$sth->closeCursor();
1597 1687
 			if (count($row) > 0) {
1598 1688
 				return $row;
1599
-			} else return '';
1689
+			} else {
1690
+				return '';
1691
+			}
1600 1692
 		} catch (PDOException $e) {
1601
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1693
+			if (isset($globalDebug) && $globalDebug) {
1694
+				echo 'Error : '.$e->getMessage()."\n";
1695
+			}
1602 1696
 			return '';
1603 1697
 		}
1604 1698
 	
@@ -1616,7 +1710,9 @@  discard block
 block discarded – undo
1616 1710
 	{
1617 1711
 		global $globalBitlyAccessToken;
1618 1712
 		
1619
-		if ($globalBitlyAccessToken == '') return $url;
1713
+		if ($globalBitlyAccessToken == '') {
1714
+			return $url;
1715
+		}
1620 1716
         
1621 1717
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1622 1718
 		
Please login to merge, or discard this patch.
require/class.TrackerImport.php 3 patches
Indentation   +140 added lines, -140 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, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
87 87
 	date_default_timezone_set('UTC');
@@ -90,8 +90,8 @@  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
@@ -107,29 +107,29 @@  discard block
 block discarded – undo
107 107
 		*/
108 108
 		
109 109
 		$Common = new Common();
110
-	        if (!isset($line['id'])) $id = trim($line['ident']);
111
-	        else $id = trim($line['id']);
110
+			if (!isset($line['id'])) $id = trim($line['ident']);
111
+			else $id = trim($line['id']);
112 112
 		
113 113
 		if (!isset($this->all_tracked[$id])) {
114
-		    $this->all_tracked[$id] = array();
115
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
116
-		    $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' => ''));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
118
-		    if (!isset($line['id'])) {
114
+			$this->all_tracked[$id] = array();
115
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
116
+			$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' => ''));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
118
+			if (!isset($line['id'])) {
119 119
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
120 120
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
121
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
122
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
121
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
122
+			if ($globalAllTracked !== FALSE) $dataFound = true;
123 123
 		}
124 124
 		
125 125
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
126
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127 127
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
-		    } else {
128
+			} else {
129 129
 				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";
130 130
 				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";
131 131
 				return '';
132
-		    }
132
+			}
133 133
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134 134
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
135 135
 			return '';
@@ -146,38 +146,38 @@  discard block
 block discarded – undo
146 146
 		
147 147
 		//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'])) {
148 148
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
149
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
149
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
151 151
 			$timeelapsed = microtime(true);
152
-            		$Tracker = new Tracker($this->db);
153
-            		$fromsource = NULL;
154
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
152
+					$Tracker = new Tracker($this->db);
153
+					$fromsource = NULL;
154
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155 155
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
156 156
 			$Tracker->db = null;
157 157
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
-		    }
159
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
158
+			}
159
+			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 160
 		}
161 161
 
162 162
 		if (isset($line['speed']) && $line['speed'] != '') {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
165 165
 		} 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'])) {
166
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
-		    if ($distance > 100 && $distance < 10000) {
166
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+			if ($distance > 100 && $distance < 10000) {
168 168
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
169 169
 			$speed = $speed*3.6;
170 170
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171 171
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
172
-		    }
172
+			}
173 173
 		}
174 174
 
175
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
176
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
-	    	    else unset($timediff);
178
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && 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')))) {
175
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
176
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+				else unset($timediff);
178
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && 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 179
 			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'])) {
180
-			    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'])) {
180
+				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'])) {
181 181
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
182 182
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
183 183
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -191,120 +191,120 @@  discard block
 block discarded – undo
191 191
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192 192
 				$this->tmd = 0;
193 193
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
194
-			    }
194
+				}
195 195
 			}
196 196
 
197 197
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
198 198
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
199 199
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
201
-				    $dataFound = true;
202
-				    $this->all_tracked[$id]['time_last_coord'] = time();
200
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
201
+					$dataFound = true;
202
+					$this->all_tracked[$id]['time_last_coord'] = time();
203 203
 				}
204 204
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205 205
 			}
206 206
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
207
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
207
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208 208
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
209 209
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
211
-				    $dataFound = true;
212
-				    $this->all_tracked[$id]['time_last_coord'] = time();
210
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
211
+					$dataFound = true;
212
+					$this->all_tracked[$id]['time_last_coord'] = time();
213 213
 				}
214 214
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215 215
 			}
216 216
 
217
-		    } else if ($globalDebug && $timediff > 20) {
217
+			} else if ($globalDebug && $timediff > 20) {
218 218
 			$this->tmd = $this->tmd + 1;
219 219
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
220 220
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
221 221
 			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 222
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
223
-		    }
223
+			}
224 224
 		}
225 225
 		if (isset($line['last_update']) && $line['last_update'] != '') {
226
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
227
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
226
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
227
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
228 228
 		}
229 229
 		if (isset($line['format_source']) && $line['format_source'] != '') {
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
231 231
 		}
232 232
 		if (isset($line['source_name']) && $line['source_name'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
234 234
 		}
235 235
 		if (isset($line['comment']) && $line['comment'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
237
-		    //$dataFound = true;
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
237
+			//$dataFound = true;
238 238
 		}
239 239
 		if (isset($line['type']) && $line['type'] != '') {
240
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
241
-		    //$dataFound = true;
240
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
241
+			//$dataFound = true;
242 242
 		}
243 243
 
244 244
 		if (isset($line['altitude']) && $line['altitude'] != '') {
245
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
245
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
246 246
 			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;
247 247
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
248 248
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249 249
 			//$dataFound = true;
250
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
250
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
251 251
   		}
252 252
 
253 253
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
254
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
254
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
255 255
 		}
256 256
 		
257 257
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
-		    //$dataFound = true;
258
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+			//$dataFound = true;
262 262
   		} 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']) {
263
-  		    $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']);
264
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
263
+  			$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']);
264
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
267 267
   		}
268 268
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
269 269
 
270 270
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
271
-		    $this->all_tracked[$id]['lastupdate'] = time();
272
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
273
-		        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'])) {
274
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
271
+			$this->all_tracked[$id]['lastupdate'] = time();
272
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
273
+				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'])) {
274
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
275 275
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
276 276
 				$timeelapsed = microtime(true);
277 277
 				$TrackerLive = new TrackerLive($this->db);
278 278
 				if (isset($line['id'])) {
279
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
280
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
279
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
280
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
281 281
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
282
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} else $recent_ident = '';
285 285
 				$TrackerLive->db=null;
286 286
 
287 287
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
288 288
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
289
-			    } else {
289
+				} else {
290 290
 				$recent_ident = '';
291 291
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
292
-			    }
293
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
294
-			    if($recent_ident == "")
295
-			    {
292
+				}
293
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
294
+				if($recent_ident == "")
295
+				{
296 296
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
297 297
 				//adds the spotter data for the archive
298
-				    $highlight = '';
299
-				    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')));
300
-				    $timeelapsed = microtime(true);
301
-				    $Tracker = new Tracker($this->db);
302
-				    $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']);
303
-				    $Tracker->db = null;
304
-				    if ($globalDebug && isset($result)) echo $result."\n";
305
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
298
+					$highlight = '';
299
+					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')));
300
+					$timeelapsed = microtime(true);
301
+					$Tracker = new Tracker($this->db);
302
+					$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']);
303
+					$Tracker->db = null;
304
+					if ($globalDebug && isset($result)) echo $result."\n";
305
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
306 306
 				    
307
-				    /*
307
+					/*
308 308
 				    // Add source stat in DB
309 309
 				    $Stats = new Stats($this->db);
310 310
 				    if (!empty($this->stats)) {
@@ -331,20 +331,20 @@  discard block
 block discarded – undo
331 331
 				    }
332 332
 				    $Stats->db = null;
333 333
 				    */
334
-				    $this->del();
334
+					$this->del();
335 335
 				//$ignoreImport = false;
336 336
 				$this->all_tracked[$id]['addedTracker'] = 1;
337 337
 				//print_r($this->all_tracked[$id]);
338 338
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
339
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
340
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
341
-				    $TrackerLive = new TrackerLive($this->db);
342
-				    $TrackerLive->deleteLiveTrackerData();
343
-				    $TrackerLive->db=null;
344
-				    if ($globalDebug) echo " Done\n";
345
-				    $this->last_delete = time();
339
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
340
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
341
+					$TrackerLive = new TrackerLive($this->db);
342
+					$TrackerLive->deleteLiveTrackerData();
343
+					$TrackerLive->db=null;
344
+					if ($globalDebug) echo " Done\n";
345
+					$this->last_delete = time();
346 346
 				}
347
-			    } else {
347
+				} else {
348 348
 				$this->all_tracked[$id]['id'] = $recent_ident;
349 349
 				$this->all_tracked[$id]['addedTracker'] = 1;
350 350
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -353,16 +353,16 @@  discard block
 block discarded – undo
353 353
 					$Tracker->db = null;
354 354
 				}
355 355
 				
356
-			    }
356
+				}
357
+			}
357 358
 			}
358
-		    }
359
-		    //adds the spotter LIVE data
360
-		    if ($globalDebug) {
359
+			//adds the spotter LIVE data
360
+			if ($globalDebug) {
361 361
 			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";
362
-		    }
363
-		    $ignoreImport = false;
362
+			}
363
+			$ignoreImport = false;
364 364
 
365
-		    if (!$ignoreImport) {
365
+			if (!$ignoreImport) {
366 366
 			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'])) {
367 367
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
368 368
 				$timeelapsed = microtime(true);
@@ -434,22 +434,22 @@  discard block
 block discarded – undo
434 434
 			
435 435
 			
436 436
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
437
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
438
-			    $TrackerLive = new TrackerLive($this->db);
439
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
440
-			    $TrackerLive->db = null;
441
-			    //TrackerLive->deleteLiveTrackerData();
442
-			    if ($globalDebug) echo " Done\n";
443
-			    $this->last_delete_hourly = time();
437
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
438
+				$TrackerLive = new TrackerLive($this->db);
439
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
440
+				$TrackerLive->db = null;
441
+				//TrackerLive->deleteLiveTrackerData();
442
+				if ($globalDebug) echo " Done\n";
443
+				$this->last_delete_hourly = time();
444 444
 			}
445 445
 			
446
-		    }
447
-		    //$ignoreImport = false;
446
+			}
447
+			//$ignoreImport = false;
448 448
 		}
449 449
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
450 450
 		if ($send) return $this->all_tracked[$id];
451
-	    }
451
+		}
452
+	}
452 453
 	}
453
-    }
454 454
 }
455 455
 ?>
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 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
 
@@ -112,33 +112,33 @@  discard block
 block discarded – undo
112 112
 		
113 113
 		if (!isset($this->all_tracked[$id])) {
114 114
 		    $this->all_tracked[$id] = array();
115
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
116
-		    $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' => ''));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
115
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
116
+		    $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' => ''));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
118 118
 		    if (!isset($line['id'])) {
119 119
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
120
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
121
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
120
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
121
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
122 122
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
123 123
 		}
124 124
 		
125
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
125
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
126 126
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
127
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
128 128
 		    } else {
129 129
 				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";
130 130
 				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";
131 131
 				return '';
132 132
 		    }
133
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
133
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
134 134
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
135 135
 			return '';
136
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
136
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
137 137
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
138 138
 			return '';
139 139
 		} elseif (!isset($line['datetime'])) {
140 140
 			date_default_timezone_set('UTC');
141
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
141
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
142 142
 		} else {
143 143
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
144 144
 			return '';
@@ -146,38 +146,38 @@  discard block
 block discarded – undo
146 146
 		
147 147
 		//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'])) {
148 148
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
149
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
149
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
150 150
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
151 151
 			$timeelapsed = microtime(true);
152 152
             		$Tracker = new Tracker($this->db);
153 153
             		$fromsource = NULL;
154
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
154
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
155 155
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
156 156
 			$Tracker->db = null;
157
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
157
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
158 158
 		    }
159
-		    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
+		    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 160
 		}
161 161
 
162 162
 		if (isset($line['speed']) && $line['speed'] != '') {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
165 165
 		} 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'])) {
166
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
166
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
167 167
 		    if ($distance > 100 && $distance < 10000) {
168 168
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
169 169
 			$speed = $speed*3.6;
170
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
170
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
171 171
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
172 172
 		    }
173 173
 		}
174 174
 
175 175
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
176
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
176
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
177 177
 	    	    else unset($timediff);
178
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && 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')))) {
178
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && 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 179
 			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'])) {
180
-			    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'])) {
180
+			    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'])) {
181 181
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
182 182
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
183 183
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
186 186
 				$timeelapsed = microtime(true);
187 187
 				$Tracker = new Tracker($this->db);
188
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
188
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
189 189
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
190 190
 				$Tracker->db = null;
191
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
191
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
192 192
 				$this->tmd = 0;
193 193
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
194 194
 			    }
@@ -196,73 +196,73 @@  discard block
 block discarded – undo
196 196
 
197 197
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
198 198
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
199
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
199
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
200 200
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
201 201
 				    $dataFound = true;
202 202
 				    $this->all_tracked[$id]['time_last_coord'] = time();
203 203
 				}
204
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
204
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
205 205
 			}
206 206
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
207 207
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208 208
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
209
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
209
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
210 210
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
211 211
 				    $dataFound = true;
212 212
 				    $this->all_tracked[$id]['time_last_coord'] = time();
213 213
 				}
214
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
214
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
215 215
 			}
216 216
 
217 217
 		    } else if ($globalDebug && $timediff > 20) {
218 218
 			$this->tmd = $this->tmd + 1;
219 219
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
220
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
221
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
220
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
221
+			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 222
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
223 223
 		    }
224 224
 		}
225 225
 		if (isset($line['last_update']) && $line['last_update'] != '') {
226 226
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
227
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
227
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
228 228
 		}
229 229
 		if (isset($line['format_source']) && $line['format_source'] != '') {
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
231 231
 		}
232 232
 		if (isset($line['source_name']) && $line['source_name'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
234 234
 		}
235 235
 		if (isset($line['comment']) && $line['comment'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
237 237
 		    //$dataFound = true;
238 238
 		}
239 239
 		if (isset($line['type']) && $line['type'] != '') {
240
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
240
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
241 241
 		    //$dataFound = true;
242 242
 		}
243 243
 
244 244
 		if (isset($line['altitude']) && $line['altitude'] != '') {
245 245
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
246
-			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;
247
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
248
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
246
+			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;
247
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => round($line['altitude']/100)));
248
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
249 249
 			//$dataFound = true;
250 250
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
251 251
   		}
252 252
 
253 253
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
254
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
254
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
255 255
 		}
256 256
 		
257 257
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
258
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
260
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
261 261
 		    //$dataFound = true;
262 262
   		} 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']) {
263
-  		    $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']);
264
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
263
+  		    $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']);
264
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
265
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266 266
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
267 267
   		}
268 268
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -270,39 +270,39 @@  discard block
 block discarded – undo
270 270
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
271 271
 		    $this->all_tracked[$id]['lastupdate'] = time();
272 272
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
273
-		        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'])) {
273
+		        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'])) {
274 274
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
275 275
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
276 276
 				$timeelapsed = microtime(true);
277 277
 				$TrackerLive = new TrackerLive($this->db);
278 278
 				if (isset($line['id'])) {
279 279
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
280
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
280
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
281 281
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
282 282
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} else $recent_ident = '';
285
-				$TrackerLive->db=null;
285
+				$TrackerLive->db = null;
286 286
 
287 287
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
288 288
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
289 289
 			    } else {
290 290
 				$recent_ident = '';
291
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
291
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
292 292
 			    }
293 293
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
294
-			    if($recent_ident == "")
294
+			    if ($recent_ident == "")
295 295
 			    {
296 296
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
297 297
 				//adds the spotter data for the archive
298 298
 				    $highlight = '';
299
-				    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')));
299
+				    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')));
300 300
 				    $timeelapsed = microtime(true);
301 301
 				    $Tracker = new Tracker($this->db);
302
-				    $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']);
302
+				    $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']);
303 303
 				    $Tracker->db = null;
304 304
 				    if ($globalDebug && isset($result)) echo $result."\n";
305
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
305
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
306 306
 				    
307 307
 				    /*
308 308
 				    // Add source stat in DB
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
341 341
 				    $TrackerLive = new TrackerLive($this->db);
342 342
 				    $TrackerLive->deleteLiveTrackerData();
343
-				    $TrackerLive->db=null;
343
+				    $TrackerLive->db = null;
344 344
 				    if ($globalDebug) echo " Done\n";
345 345
 				    $this->last_delete = time();
346 346
 				}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 				$this->all_tracked[$id]['addedTracker'] = 1;
350 350
 				if (isset($globalDaemon) && !$globalDaemon) {
351 351
 					$Tracker = new Tracker($this->db);
352
-					$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']);
352
+					$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']);
353 353
 					$Tracker->db = null;
354 354
 				}
355 355
 				
@@ -363,14 +363,14 @@  discard block
 block discarded – undo
363 363
 		    $ignoreImport = false;
364 364
 
365 365
 		    if (!$ignoreImport) {
366
-			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'])) {
366
+			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'])) {
367 367
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
368 368
 				$timeelapsed = microtime(true);
369 369
 				$TrackerLive = new TrackerLive($this->db);
370
-				$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']);
370
+				$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']);
371 371
 				$TrackerLive->db = null;
372 372
 				$this->all_tracked[$id]['putinarchive'] = false;
373
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
373
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
374 374
 
375 375
 				// Put statistics in $this->stats variable
376 376
 				/*
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				$this->all_tracked[$id]['lastupdate'] = time();
430 430
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
431 431
 				if ($globalDebug) echo $result."\n";
432
-			} 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";
432
+			} 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";
433 433
 			//$this->del();
434 434
 			
435 435
 			
Please login to merge, or discard this patch.
Braces   +158 added lines, -54 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, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
94
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
95
+		$globalCoordMinChange = '0.02';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -107,8 +117,11 @@  discard block
 block discarded – undo
107 117
 		*/
108 118
 		
109 119
 		$Common = new Common();
110
-	        if (!isset($line['id'])) $id = trim($line['ident']);
111
-	        else $id = trim($line['id']);
120
+	        if (!isset($line['id'])) {
121
+	        	$id = trim($line['ident']);
122
+	        } else {
123
+	        	$id = trim($line['id']);
124
+	        }
112 125
 		
113 126
 		if (!isset($this->all_tracked[$id])) {
114 127
 		    $this->all_tracked[$id] = array();
@@ -116,31 +129,46 @@  discard block
 block discarded – undo
116 129
 		    $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' => ''));
117 130
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
118 131
 		    if (!isset($line['id'])) {
119
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
132
+			if (!isset($globalDaemon)) {
133
+				$globalDaemon = TRUE;
134
+			}
120 135
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
121
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
122
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
136
+		     } else {
137
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
138
+		     }
139
+		    if ($globalAllTracked !== FALSE) {
140
+		    	$dataFound = true;
141
+		    }
123 142
 		}
124 143
 		
125 144
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126 145
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127 146
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128 147
 		    } else {
129
-				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";
130
-				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";
148
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
149
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
150
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
151
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
152
+				}
131 153
 				return '';
132 154
 		    }
133 155
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
156
+			if ($globalDebug) {
157
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
158
+			}
135 159
 			return '';
136 160
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
161
+			if ($globalDebug) {
162
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
163
+			}
138 164
 			return '';
139 165
 		} elseif (!isset($line['datetime'])) {
140 166
 			date_default_timezone_set('UTC');
141 167
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142 168
 		} else {
143
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
169
+			if ($globalDebug) {
170
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
171
+			}
144 172
 			return '';
145 173
 		}
146 174
 		
@@ -152,11 +180,17 @@  discard block
 block discarded – undo
152 180
             		$Tracker = new Tracker($this->db);
153 181
             		$fromsource = NULL;
154 182
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
183
+			if ($globalDebug && $result != 'success') {
184
+				echo '!!! ERROR : '.$result."\n";
185
+			}
156 186
 			$Tracker->db = null;
157
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
187
+			if ($globalDebugTimeElapsed) {
188
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
189
+			}
190
+		    }
191
+		    if (!isset($this->all_tracked[$id]['id'])) {
192
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
158 193
 		    }
159
-		    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 194
 		}
161 195
 
162 196
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -167,14 +201,21 @@  discard block
 block discarded – undo
167 201
 		    if ($distance > 100 && $distance < 10000) {
168 202
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
169 203
 			$speed = $speed*3.6;
170
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
204
+			if ($speed < 1000) {
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
206
+			}
207
+  			if ($globalDebug) {
208
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
209
+  			}
172 210
 		    }
173 211
 		}
174 212
 
175 213
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
176
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
-	    	    else unset($timediff);
214
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
215
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
216
+	    	    } else {
217
+	    	    	unset($timediff);
218
+	    	    }
178 219
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && 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 220
 			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'])) {
180 221
 			    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'])) {
@@ -182,20 +223,30 @@  discard block
 block discarded – undo
182 223
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
183 224
 				$this->all_tracked[$id]['putinarchive'] = true;
184 225
 				
185
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
226
+				if ($globalDebug) {
227
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
228
+				}
186 229
 				$timeelapsed = microtime(true);
187 230
 				$Tracker = new Tracker($this->db);
188 231
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
232
+				if (!empty($all_country)) {
233
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
234
+				}
190 235
 				$Tracker->db = null;
191
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
236
+				if ($globalDebugTimeElapsed) {
237
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
238
+				}
192 239
 				$this->tmd = 0;
193
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
240
+				if ($globalDebug) {
241
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
242
+				}
194 243
 			    }
195 244
 			}
196 245
 
197 246
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
198
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
247
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
248
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
249
+				}
199 250
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
200 251
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
201 252
 				    $dataFound = true;
@@ -204,8 +255,12 @@  discard block
 block discarded – undo
204 255
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205 256
 			}
206 257
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
207
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
258
+			    if ($line['longitude'] > 180) {
259
+			    	$line['longitude'] = $line['longitude'] - 360;
260
+			    }
261
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
262
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
263
+				}
209 264
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
210 265
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
211 266
 				    $dataFound = true;
@@ -223,7 +278,9 @@  discard block
 block discarded – undo
223 278
 		    }
224 279
 		}
225 280
 		if (isset($line['last_update']) && $line['last_update'] != '') {
226
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
281
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
282
+		    	$dataFound = true;
283
+		    }
227 284
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
228 285
 		}
229 286
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -243,7 +300,9 @@  discard block
 block discarded – undo
243 300
 
244 301
 		if (isset($line['altitude']) && $line['altitude'] != '') {
245 302
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
246
-			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;
303
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
304
+				$this->all_tracked[$id]['putinarchive'] = true;
305
+			}
247 306
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
248 307
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249 308
 			//$dataFound = true;
@@ -255,15 +314,21 @@  discard block
 block discarded – undo
255 314
 		}
256 315
 		
257 316
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
317
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
318
+		    	$this->all_tracked[$id]['putinarchive'] = true;
319
+		    }
259 320
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260 321
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261 322
 		    //$dataFound = true;
262 323
   		} 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']) {
263 324
   		    $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']);
264 325
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
326
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
327
+		    	$this->all_tracked[$id]['putinarchive'] = true;
328
+		    }
329
+  		    if ($globalDebug) {
330
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
331
+  		    }
267 332
   		}
268 333
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
269 334
 
@@ -272,20 +337,31 @@  discard block
 block discarded – undo
272 337
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
273 338
 		        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'])) {
274 339
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
275
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
340
+				if ($globalDebug) {
341
+					echo "Check if aircraft is already in DB...";
342
+				}
276 343
 				$timeelapsed = microtime(true);
277 344
 				$TrackerLive = new TrackerLive($this->db);
278 345
 				if (isset($line['id'])) {
279 346
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
280
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
347
+				    if ($globalDebugTimeElapsed) {
348
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
349
+				    }
281 350
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
282 351
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284
-				} else $recent_ident = '';
352
+				    if ($globalDebugTimeElapsed) {
353
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
354
+				    }
355
+				} else {
356
+					$recent_ident = '';
357
+				}
285 358
 				$TrackerLive->db=null;
286 359
 
287
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
288
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
360
+				if ($globalDebug && $recent_ident == '') {
361
+					echo " Not in DB.\n";
362
+				} elseif ($globalDebug && $recent_ident != '') {
363
+					echo " Already in DB.\n";
364
+				}
289 365
 			    } else {
290 366
 				$recent_ident = '';
291 367
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -293,16 +369,24 @@  discard block
 block discarded – undo
293 369
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
294 370
 			    if($recent_ident == "")
295 371
 			    {
296
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
372
+				if ($globalDebug) {
373
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
374
+				}
297 375
 				//adds the spotter data for the archive
298 376
 				    $highlight = '';
299
-				    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')));
377
+				    if (!isset($this->all_tracked[$id]['id'])) {
378
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
379
+				    }
300 380
 				    $timeelapsed = microtime(true);
301 381
 				    $Tracker = new Tracker($this->db);
302 382
 				    $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']);
303 383
 				    $Tracker->db = null;
304
-				    if ($globalDebug && isset($result)) echo $result."\n";
305
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
384
+				    if ($globalDebug && isset($result)) {
385
+				    	echo $result."\n";
386
+				    }
387
+				    if ($globalDebugTimeElapsed) {
388
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
389
+				    }
306 390
 				    
307 391
 				    /*
308 392
 				    // Add source stat in DB
@@ -336,12 +420,16 @@  discard block
 block discarded – undo
336 420
 				$this->all_tracked[$id]['addedTracker'] = 1;
337 421
 				//print_r($this->all_tracked[$id]);
338 422
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
339
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
423
+				    if ($globalDebug) {
424
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
425
+				    }
340 426
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
341 427
 				    $TrackerLive = new TrackerLive($this->db);
342 428
 				    $TrackerLive->deleteLiveTrackerData();
343 429
 				    $TrackerLive->db=null;
344
-				    if ($globalDebug) echo " Done\n";
430
+				    if ($globalDebug) {
431
+				    	echo " Done\n";
432
+				    }
345 433
 				    $this->last_delete = time();
346 434
 				}
347 435
 			    } else {
@@ -364,13 +452,17 @@  discard block
 block discarded – undo
364 452
 
365 453
 		    if (!$ignoreImport) {
366 454
 			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'])) {
367
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
455
+				if ($globalDebug) {
456
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
457
+				}
368 458
 				$timeelapsed = microtime(true);
369 459
 				$TrackerLive = new TrackerLive($this->db);
370 460
 				$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']);
371 461
 				$TrackerLive->db = null;
372 462
 				$this->all_tracked[$id]['putinarchive'] = false;
373
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
463
+				if ($globalDebugTimeElapsed) {
464
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
465
+				}
374 466
 
375 467
 				// Put statistics in $this->stats variable
376 468
 				/*
@@ -427,19 +519,29 @@  discard block
 block discarded – undo
427 519
 				*/
428 520
 
429 521
 				$this->all_tracked[$id]['lastupdate'] = time();
430
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
431
-				if ($globalDebug) echo $result."\n";
432
-			} 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";
522
+				if ($this->all_tracked[$id]['putinarchive']) {
523
+					$send = true;
524
+				}
525
+				if ($globalDebug) {
526
+					echo $result."\n";
527
+				}
528
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
529
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
530
+			}
433 531
 			//$this->del();
434 532
 			
435 533
 			
436 534
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
437
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
535
+			    if ($globalDebug) {
536
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
537
+			    }
438 538
 			    $TrackerLive = new TrackerLive($this->db);
439 539
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
440 540
 			    $TrackerLive->db = null;
441 541
 			    //TrackerLive->deleteLiveTrackerData();
442
-			    if ($globalDebug) echo " Done\n";
542
+			    if ($globalDebug) {
543
+			    	echo " Done\n";
544
+			    }
443 545
 			    $this->last_delete_hourly = time();
444 546
 			}
445 547
 			
@@ -447,7 +549,9 @@  discard block
 block discarded – undo
447 549
 		    //$ignoreImport = false;
448 550
 		}
449 551
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
450
-		if ($send) return $this->all_tracked[$id];
552
+		if ($send) {
553
+			return $this->all_tracked[$id];
554
+		}
451 555
 	    }
452 556
 	}
453 557
     }
Please login to merge, or discard this patch.
require/class.APRS.php 3 patches
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 require_once(dirname(__FILE__).'/class.Common.php');
4 4
 class aprs {
5
-    private $socket;
6
-    private $connected = false;
5
+	private $socket;
6
+	private $connected = false;
7 7
 
8
-    protected $symbols = array('!' => 'Police',
8
+	protected $symbols = array('!' => 'Police',
9 9
 	'#' => 'DIGI',
10 10
 	'$' => 'Phone',
11 11
 	'%' => 'DX Cluster',
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	'y' => 'Yagi At QTH');
90 90
 	
91 91
 
92
-    private function urshift($n, $s) {
92
+	private function urshift($n, $s) {
93 93
 	return ($n >= 0) ? ($n >> $s) :
94
-	    (($n & 0x7fffffff) >> $s) | 
94
+		(($n & 0x7fffffff) >> $s) | 
95 95
 		(0x40000000 >> ($s - 1));
96
-    }
96
+	}
97 97
 
98
-    public function parse($input) {
98
+	public function parse($input) {
99 99
 	global $globalDebug;
100 100
 	$debug = false;
101 101
 	$result = array();
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	/* Check that end was found and body has at least one byte. */
109 109
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
110
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
111
-	    return false;
110
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
111
+		return false;
112 112
 	}
113 113
 	
114 114
 	if ($debug) echo 'input : '.$input."\n";
@@ -122,31 +122,31 @@  discard block
 block discarded – undo
122 122
 	/* Parse source, target and path. */
123 123
 	//FLRDF0A52>APRS,qAS,LSTB
124 124
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
125
-	    $ident = $matches[1];
126
-	    $all_elements = $matches[2];
127
-	    if ($ident == 'AIRCRAFT') {
125
+		$ident = $matches[1];
126
+		$all_elements = $matches[2];
127
+		if ($ident == 'AIRCRAFT') {
128 128
 		$result['format_source'] = 'famaprs';
129 129
 		$result['source_type'] = 'modes';
130
-	    } elseif ($ident == 'MARINE') {
130
+		} elseif ($ident == 'MARINE') {
131 131
 		$result['format_source'] = 'famaprs';
132 132
 		$result['source_type'] = 'ais';
133
-	    } else {
133
+		} else {
134 134
 		if ($debug) echo 'ident : '.$ident."\n";
135 135
 		$result['ident'] = $ident;
136
-	    }
136
+		}
137 137
 	} else return false;
138 138
 	$elements = explode(',',$all_elements);
139 139
 	$source = end($elements);
140 140
 	$result['source'] = $source;
141 141
 	foreach ($elements as $element) {
142
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
143
-	        //echo "ok";
144
-	        //if ($element == 'TCPIP*') return false;
145
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
142
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
143
+			//echo "ok";
144
+			//if ($element == 'TCPIP*') return false;
145
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
146 146
 		if ($debug) echo 'element : '.$element."\n";
147 147
 		return false;
148
-	    }
149
-	    /*
148
+		}
149
+		/*
150 150
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
151 151
 		//echo "ok";
152 152
 	    } else {
@@ -173,49 +173,49 @@  discard block
 block discarded – undo
173 173
 	$body_parse = substr($body,1);
174 174
 	//echo 'Body : '.$body."\n";
175 175
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
176
-	    $body_parse = substr($body_parse,10);
177
-	    $find = true;
178
-	    //echo $body_parse."\n";
176
+		$body_parse = substr($body_parse,10);
177
+		$find = true;
178
+		//echo $body_parse."\n";
179 179
 	}
180 180
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
181
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
182
-	    $find = true;
183
-	    //echo $body_parse."\n";
181
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
182
+		$find = true;
183
+		//echo $body_parse."\n";
184 184
 	}
185 185
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
186
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
187
-	    $find = true;
188
-	    //echo $body_parse."\n";
186
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
187
+		$find = true;
188
+		//echo $body_parse."\n";
189 189
 	}
190 190
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
191
-	    $find = true;
192
-	    //print_r($matches);
193
-	    $timestamp = $matches[0];
194
-	    if ($matches[4] == 'h') {
191
+		$find = true;
192
+		//print_r($matches);
193
+		$timestamp = $matches[0];
194
+		if ($matches[4] == 'h') {
195 195
 		$timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]);
196 196
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
197 197
 		/*
198 198
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
199 199
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
200 200
 		*/
201
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
201
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
202 202
 		// This work or not ?
203 203
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
204
-	    }
205
-	    $body_parse = substr($body_parse,7);
206
-	    $result['timestamp'] = $timestamp;
207
-	    //echo date('Ymd H:i:s',$timestamp);
204
+		}
205
+		$body_parse = substr($body_parse,7);
206
+		$result['timestamp'] = $timestamp;
207
+		//echo date('Ymd H:i:s',$timestamp);
208 208
 	}
209 209
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
210
-	    $find = true;
211
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
212
-	    $body_parse = substr($body_parse,8);
213
-	    $result['timestamp'] = $timestamp;
214
-	    //echo date('Ymd H:i:s',$timestamp);
210
+		$find = true;
211
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
212
+		$body_parse = substr($body_parse,8);
213
+		$result['timestamp'] = $timestamp;
214
+		//echo date('Ymd H:i:s',$timestamp);
215 215
 	}
216 216
 	//if (strlen($body_parse) > 19) {
217
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
218
-	    $find = true;
217
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
218
+		$find = true;
219 219
 		// 4658.70N/00707.78Ez
220 220
 		//print_r(str_split($body_parse));
221 221
 		
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		$lon = intval($lon_deg);
233 233
 		if ($lat > 89 || $lon > 179) return false;
234 234
 	    
235
-	    /*
235
+		/*
236 236
 	    $tmp_5b = str_replace('.','',$lat_min);
237 237
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
238 238
 	        print_r($matches);
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 		$result['longitude'] = $longitude;
247 247
 		$body_parse = substr($body_parse,18);
248 248
 		$body_parse_len = strlen($body_parse);
249
-	    }
250
-	    $body_parse_len = strlen($body_parse);
251
-	    if ($body_parse_len > 0) {
249
+		}
250
+		$body_parse_len = strlen($body_parse);
251
+		if ($body_parse_len > 0) {
252 252
 		/*
253 253
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
254 254
 			$body_split = str_split($body);
@@ -278,95 +278,95 @@  discard block
 block discarded – undo
278 278
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
279 279
 			if ($symbol_code != '_') {
280 280
 			}
281
-		    //$body_parse = substr($body_parse,1);
282
-		    //$body_parse = trim($body_parse);
283
-		    //$body_parse_len = strlen($body_parse);
284
-		    if ($body_parse_len >= 7) {
281
+			//$body_parse = substr($body_parse,1);
282
+			//$body_parse = trim($body_parse);
283
+			//$body_parse_len = strlen($body_parse);
284
+			if ($body_parse_len >= 7) {
285 285
 			
286
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
287
-		    	    $course = substr($body_parse,0,3);
288
-		    	    $tmp_s = intval($course);
289
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
290
-		    	    $speed = substr($body_parse,4,3);
291
-		    	    if ($speed != '...') {
292
-		    		//$result['speed'] = round($speed*1.852);
293
-		    		$result['speed'] = intval($speed);
294
-		    	    }
295
-		    	    $body_parse = substr($body_parse,7);
296
-		        }
297
-		        // Check PHGR, PHG, RNG
298
-		    } 
299
-		    /*
286
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
287
+					$course = substr($body_parse,0,3);
288
+					$tmp_s = intval($course);
289
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
290
+					$speed = substr($body_parse,4,3);
291
+					if ($speed != '...') {
292
+					//$result['speed'] = round($speed*1.852);
293
+					$result['speed'] = intval($speed);
294
+					}
295
+					$body_parse = substr($body_parse,7);
296
+				}
297
+				// Check PHGR, PHG, RNG
298
+			} 
299
+			/*
300 300
 		    else if ($body_parse_len > 0) {
301 301
 			$rest = $body_parse;
302 302
 		    }
303 303
 		    */
304
-		    if (strlen($body_parse) > 0) {
305
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
306
-		            $altitude = intval($matches[1]);
307
-		            //$result['altitude'] = round($altitude*0.3048);
308
-		            $result['altitude'] = $altitude;
309
-		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
310
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
311
-		        }
312
-		    }
304
+			if (strlen($body_parse) > 0) {
305
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
306
+					$altitude = intval($matches[1]);
307
+					//$result['altitude'] = round($altitude*0.3048);
308
+					$result['altitude'] = $altitude;
309
+					//$body_parse = trim(substr($body_parse,strlen($matches[0])));
310
+					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
311
+				}
312
+			}
313 313
 		    
314
-		    // Telemetry
315
-		    /*
314
+			// Telemetry
315
+			/*
316 316
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
317 317
 		        // Nothing yet...
318 318
 		    }
319 319
 		    */
320
-		    // DAO
320
+			// DAO
321 321
 		    
322
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
322
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
323 323
 			    
324
-			    $dao = $matches[1];
325
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
324
+				$dao = $matches[1];
325
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
326 326
 				$dao_split = str_split($dao);
327
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
328
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
327
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
328
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
329 329
 			    
330 330
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
331 331
 				else $result['latitude'] += $lat_off;
332 332
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
333 333
 				else $result['longitude'] += $lon_off;
334
-			    }
334
+				}
335 335
 			    
336
-		            $body_parse = substr($body_parse,6);
337
-		    }
336
+					$body_parse = substr($body_parse,6);
337
+			}
338 338
 		    
339
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
339
+			if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
340 340
 			$result['ident'] = str_replace('_',' ',$matches[1]);
341
-		    }
342
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
341
+			}
342
+			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
343 343
 			$result['squawk'] = $matches[1];
344
-		    }
345
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
344
+			}
345
+			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
346 346
 			$result['aircraft_icao'] = $matches[1];
347
-		    }
348
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
347
+			}
348
+			if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
349 349
 			$result['verticalrate'] = $matches[1];
350
-		    }
351
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
350
+			}
351
+			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
352 352
 			$result['typeid'] = $matches[1];
353
-		    }
354
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
353
+			}
354
+			if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
355 355
 			$result['statusid'] = $matches[1];
356
-		    }
357
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
356
+			}
357
+			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
358 358
 			$result['imo'] = $matches[1];
359
-		    }
360
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
359
+			}
360
+			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
361 361
 			$result['arrival_date'] = $matches[1];
362
-		    }
363
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
362
+			}
363
+			if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
364 364
 			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
365
-		    }
366
-		    // OGN comment
365
+			}
366
+			// OGN comment
367 367
 		   // echo "Before OGN : ".$body_parse."\n";
368
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
369
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
368
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
369
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
370 370
 			$id = $matches[1];
371 371
 			//$mode = substr($id,0,2);
372 372
 			$address = substr($id,2);
@@ -396,53 +396,53 @@  discard block
 block discarded – undo
396 396
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
397 397
 			$result['stealth'] = $stealth;
398 398
 			$result['address'] = $address;
399
-		    }
399
+			}
400 400
 		    
401
-		    //Comment
402
-		    $result['comment'] = trim($body_parse);
401
+			//Comment
402
+			$result['comment'] = trim($body_parse);
403 403
 		} else {
404
-		    // parse weather
405
-		    //$body_parse = substr($body_parse,1);
406
-		    //$body_parse_len = strlen($body_parse);
404
+			// parse weather
405
+			//$body_parse = substr($body_parse,1);
406
+			//$body_parse_len = strlen($body_parse);
407 407
 
408
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
409
-			    $result['wind_dir'] = intval($matches[1]);
410
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
411
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
412
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
413
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
414
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
408
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
409
+				$result['wind_dir'] = intval($matches[1]);
410
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
411
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
412
+				$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
413
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
414
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
415 415
 			$result['wind_dir'] = intval($matches[1]);
416 416
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
417 417
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
418 418
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
419
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
420
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
419
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
420
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
421 421
 			$result['wind_dir'] = intval($matches[1]);
422 422
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
423 423
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
424
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
425
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
424
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
425
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
426 426
 			$result['wind_dir'] = intval($matches[1]);
427 427
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
428 428
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
429
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
430
-		    }
431
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
429
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
430
+			}
431
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
432 432
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
433
-		    }
433
+			}
434 434
 		}
435 435
 		} else $result['comment'] = trim($body_parse);
436 436
 
437
-	    }
437
+		}
438 438
 	//}
439 439
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
440 440
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
441 441
 	if ($debug) print_r($result);
442 442
 	return $result;
443
-    }
443
+	}
444 444
     
445
-    public function connect() {
445
+	public function connect() {
446 446
 	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
447 447
 	$aprs_connect = 0;
448 448
 	$aprs_keep = 120;
@@ -465,32 +465,32 @@  discard block
 block discarded – undo
465 465
 		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
466 466
 		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
467 467
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
468
-			    echo 'APRS user verified !'."\n";
469
-			    $this->connected = true;
470
-			    return true;
471
-			    break;
468
+				echo 'APRS user verified !'."\n";
469
+				$this->connected = true;
470
+				return true;
471
+				break;
472 472
 			}
473 473
 			if (time()-$authstart > 5) {
474
-			    echo 'APRS timeout'."\n";
475
-			    break;
474
+				echo 'APRS timeout'."\n";
475
+				break;
476 476
 			}
477 477
 		}
478 478
 		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE);
479 479
 	}
480
-    }
480
+	}
481 481
 
482
-    public function disconnect() {
482
+	public function disconnect() {
483 483
 	socket_close($this->socket);
484
-    }
484
+	}
485 485
     
486
-    public function send($data) {
486
+	public function send($data) {
487 487
 	if ($this->connected === false) $this->connect();
488 488
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
489 489
 	if ($send === FALSE) {
490 490
 		socket_close($this->socket);
491 491
 		$this->connect();
492 492
 	}
493
-    }
493
+	}
494 494
 }
495 495
 
496 496
 class APRSSpotter extends APRS {
Please login to merge, or discard this patch.
Spacing   +103 added lines, -104 removed lines patch added patch discarded remove patch
@@ -90,8 +90,7 @@  discard block
 block discarded – undo
90 90
 	
91 91
 
92 92
     private function urshift($n, $s) {
93
-	return ($n >= 0) ? ($n >> $s) :
94
-	    (($n & 0x7fffffff) >> $s) | 
93
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
95 94
 		(0x40000000 >> ($s - 1));
96 95
     }
97 96
 
@@ -103,7 +102,7 @@  discard block
 block discarded – undo
103 102
 	//$split_input = str_split($input);
104 103
 
105 104
 	/* Find the end of header checking for NULL bytes while doing it. */
106
-	$splitpos = strpos($input,':');
105
+	$splitpos = strpos($input, ':');
107 106
 	
108 107
 	/* Check that end was found and body has at least one byte. */
109 108
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -113,15 +112,15 @@  discard block
 block discarded – undo
113 112
 	
114 113
 	if ($debug) echo 'input : '.$input."\n";
115 114
 	/* Save header and body. */
116
-	$body = substr($input,$splitpos+1,$input_len);
115
+	$body = substr($input, $splitpos + 1, $input_len);
117 116
 	$body_len = strlen($body);
118
-	$header = substr($input,0,$splitpos);
117
+	$header = substr($input, 0, $splitpos);
119 118
 	//$header_len = strlen($header);
120 119
 	if ($debug) echo 'header : '.$header."\n";
121 120
 	
122 121
 	/* Parse source, target and path. */
123 122
 	//FLRDF0A52>APRS,qAS,LSTB
124
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
123
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
125 124
 	    $ident = $matches[1];
126 125
 	    $all_elements = $matches[2];
127 126
 	    if ($ident == 'AIRCRAFT') {
@@ -135,14 +134,14 @@  discard block
 block discarded – undo
135 134
 		$result['ident'] = $ident;
136 135
 	    }
137 136
 	} else return false;
138
-	$elements = explode(',',$all_elements);
137
+	$elements = explode(',', $all_elements);
139 138
 	$source = end($elements);
140 139
 	$result['source'] = $source;
141 140
 	foreach ($elements as $element) {
142
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
141
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
143 142
 	        //echo "ok";
144 143
 	        //if ($element == 'TCPIP*') return false;
145
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
144
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
146 145
 		if ($debug) echo 'element : '.$element."\n";
147 146
 		return false;
148 147
 	    }
@@ -155,14 +154,14 @@  discard block
 block discarded – undo
155 154
 	    */
156 155
 	}
157 156
 	
158
-	$type = substr($body,0,1);
157
+	$type = substr($body, 0, 1);
159 158
 	if ($debug) echo 'type : '.$type."\n";
160 159
 	if ($type == ';') {
161 160
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
162
-			$result['address'] = trim(substr($body,1,9));
161
+			$result['address'] = trim(substr($body, 1, 9));
163 162
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
164
-			$result['mmsi'] = trim(substr($body,1,9));
165
-		} else $result['ident'] = trim(substr($body,1,9));
163
+			$result['mmsi'] = trim(substr($body, 1, 9));
164
+		} else $result['ident'] = trim(substr($body, 1, 9));
166 165
 	} elseif ($type == ',') {
167 166
 		// Invalid data or test data
168 167
 		return false;
@@ -170,24 +169,24 @@  discard block
 block discarded – undo
170 169
 	
171 170
 	// Check for Timestamp
172 171
 	$find = false;
173
-	$body_parse = substr($body,1);
172
+	$body_parse = substr($body, 1);
174 173
 	//echo 'Body : '.$body."\n";
175
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
176
-	    $body_parse = substr($body_parse,10);
174
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
175
+	    $body_parse = substr($body_parse, 10);
177 176
 	    $find = true;
178 177
 	    //echo $body_parse."\n";
179 178
 	}
180
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
181
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
179
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
180
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
182 181
 	    $find = true;
183 182
 	    //echo $body_parse."\n";
184 183
 	}
185
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
186
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
184
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
185
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
187 186
 	    $find = true;
188 187
 	    //echo $body_parse."\n";
189 188
 	}
190
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
189
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
191 190
 	    $find = true;
192 191
 	    //print_r($matches);
193 192
 	    $timestamp = $matches[0];
@@ -202,19 +201,19 @@  discard block
 block discarded – undo
202 201
 		// This work or not ?
203 202
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
204 203
 	    }
205
-	    $body_parse = substr($body_parse,7);
204
+	    $body_parse = substr($body_parse, 7);
206 205
 	    $result['timestamp'] = $timestamp;
207 206
 	    //echo date('Ymd H:i:s',$timestamp);
208 207
 	}
209
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
208
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
210 209
 	    $find = true;
211 210
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
212
-	    $body_parse = substr($body_parse,8);
211
+	    $body_parse = substr($body_parse, 8);
213 212
 	    $result['timestamp'] = $timestamp;
214 213
 	    //echo date('Ymd H:i:s',$timestamp);
215 214
 	}
216 215
 	//if (strlen($body_parse) > 19) {
217
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
216
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
218 217
 	    $find = true;
219 218
 		// 4658.70N/00707.78Ez
220 219
 		//print_r(str_split($body_parse));
@@ -240,11 +239,11 @@  discard block
 block discarded – undo
240 239
 	    */
241 240
 		$latitude = $lat + floatval($lat_min)/60;
242 241
 		$longitude = $lon + floatval($lon_min)/60;
243
-		if ($sind == 'S') $latitude = 0-$latitude;
244
-		if ($wind == 'W') $longitude = 0-$longitude;
242
+		if ($sind == 'S') $latitude = 0 - $latitude;
243
+		if ($wind == 'W') $longitude = 0 - $longitude;
245 244
 		$result['latitude'] = $latitude;
246 245
 		$result['longitude'] = $longitude;
247
-		$body_parse = substr($body_parse,18);
246
+		$body_parse = substr($body_parse, 18);
248 247
 		$body_parse_len = strlen($body_parse);
249 248
 	    }
250 249
 	    $body_parse_len = strlen($body_parse);
@@ -272,7 +271,7 @@  discard block
 block discarded – undo
272 271
 		//echo $body_parse;
273 272
 			//if ($type != ';' && $type != '>') {
274 273
 			if ($type != '') {
275
-			$body_parse = substr($body_parse,1);
274
+			$body_parse = substr($body_parse, 1);
276 275
 			$body_parse_len = strlen($body_parse);
277 276
 			$result['symbol_code'] = $symbol_code;
278 277
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -283,16 +282,16 @@  discard block
 block discarded – undo
283 282
 		    //$body_parse_len = strlen($body_parse);
284 283
 		    if ($body_parse_len >= 7) {
285 284
 			
286
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
287
-		    	    $course = substr($body_parse,0,3);
285
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
286
+		    	    $course = substr($body_parse, 0, 3);
288 287
 		    	    $tmp_s = intval($course);
289 288
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
290
-		    	    $speed = substr($body_parse,4,3);
289
+		    	    $speed = substr($body_parse, 4, 3);
291 290
 		    	    if ($speed != '...') {
292 291
 		    		//$result['speed'] = round($speed*1.852);
293 292
 		    		$result['speed'] = intval($speed);
294 293
 		    	    }
295
-		    	    $body_parse = substr($body_parse,7);
294
+		    	    $body_parse = substr($body_parse, 7);
296 295
 		        }
297 296
 		        // Check PHGR, PHG, RNG
298 297
 		    } 
@@ -302,12 +301,12 @@  discard block
 block discarded – undo
302 301
 		    }
303 302
 		    */
304 303
 		    if (strlen($body_parse) > 0) {
305
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
304
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
306 305
 		            $altitude = intval($matches[1]);
307 306
 		            //$result['altitude'] = round($altitude*0.3048);
308 307
 		            $result['altitude'] = $altitude;
309 308
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
310
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
309
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
311 310
 		        }
312 311
 		    }
313 312
 		    
@@ -319,13 +318,13 @@  discard block
 block discarded – undo
319 318
 		    */
320 319
 		    // DAO
321 320
 		    
322
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
321
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
323 322
 			    
324 323
 			    $dao = $matches[1];
325
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
324
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
326 325
 				$dao_split = str_split($dao);
327
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
328
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
326
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
327
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
329 328
 			    
330 329
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
331 330
 				else $result['latitude'] += $lat_off;
@@ -333,50 +332,50 @@  discard block
 block discarded – undo
333 332
 				else $result['longitude'] += $lon_off;
334 333
 			    }
335 334
 			    
336
-		            $body_parse = substr($body_parse,6);
335
+		            $body_parse = substr($body_parse, 6);
337 336
 		    }
338 337
 		    
339
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
340
-			$result['ident'] = str_replace('_',' ',$matches[1]);
338
+		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
339
+			$result['ident'] = str_replace('_', ' ', $matches[1]);
341 340
 		    }
342
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
341
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
343 342
 			$result['squawk'] = $matches[1];
344 343
 		    }
345
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
344
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
346 345
 			$result['aircraft_icao'] = $matches[1];
347 346
 		    }
348
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
347
+		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
349 348
 			$result['verticalrate'] = $matches[1];
350 349
 		    }
351
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
350
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
352 351
 			$result['typeid'] = $matches[1];
353 352
 		    }
354
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
353
+		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
355 354
 			$result['statusid'] = $matches[1];
356 355
 		    }
357
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
356
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
358 357
 			$result['imo'] = $matches[1];
359 358
 		    }
360
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
359
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
361 360
 			$result['arrival_date'] = $matches[1];
362 361
 		    }
363
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
364
-			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
362
+		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
363
+			$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
365 364
 		    }
366 365
 		    // OGN comment
367 366
 		   // echo "Before OGN : ".$body_parse."\n";
368 367
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
369
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
368
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
370 369
 			$id = $matches[1];
371 370
 			//$mode = substr($id,0,2);
372
-			$address = substr($id,2);
371
+			$address = substr($id, 2);
373 372
 			//print_r($matches);
374
-			$addressType = (intval(substr($id,0,2),16))&3;
373
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
375 374
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
376 375
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
377 376
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
378 377
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
379
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
378
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
380 379
 			$result['aircrafttype_code'] = $aircraftType;
381 380
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
382 381
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -393,7 +392,7 @@  discard block
 block discarded – undo
393 392
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
394 393
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
395 394
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
396
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
395
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
397 396
 			$result['stealth'] = $stealth;
398 397
 			$result['address'] = $address;
399 398
 		    }
@@ -405,77 +404,77 @@  discard block
 block discarded – undo
405 404
 		    //$body_parse = substr($body_parse,1);
406 405
 		    //$body_parse_len = strlen($body_parse);
407 406
 
408
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
407
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
409 408
 			    $result['wind_dir'] = intval($matches[1]);
410
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
411
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
412
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
413
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
414
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
409
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
410
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
411
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
412
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
413
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
415 414
 			$result['wind_dir'] = intval($matches[1]);
416
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
417
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
418
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
419
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
420
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
415
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
416
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
417
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
418
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
419
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
421 420
 			$result['wind_dir'] = intval($matches[1]);
422
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
423
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
424
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
425
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
421
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
422
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
423
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
424
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
426 425
 			$result['wind_dir'] = intval($matches[1]);
427
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
428
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
429
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
426
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
427
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
428
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
430 429
 		    }
431
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
432
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
430
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
431
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
433 432
 		    }
434 433
 		}
435 434
 		} else $result['comment'] = trim($body_parse);
436 435
 
437 436
 	    }
438 437
 	//}
439
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
440
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
438
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
439
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
441 440
 	if ($debug) print_r($result);
442 441
 	return $result;
443 442
     }
444 443
     
445 444
     public function connect() {
446
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
445
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
447 446
 	$aprs_connect = 0;
448 447
 	$aprs_keep = 120;
449 448
 	$aprs_last_tx = time();
450 449
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
451
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
450
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
452 451
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
453
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
452
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
454 453
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
455 454
 	else $aprs_pass = '-1';
456 455
 	
457
-	$aprs_filter  = '';
456
+	$aprs_filter = '';
458 457
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
459 458
 	$Common = new Common();
460
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
459
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
461 460
 	if ($s !== false) {
462 461
 		echo 'Connected to APRS server! '."\n";
463 462
 		$authstart = time();
464 463
 		$this->socket = $s;
465
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
466
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
464
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
465
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
467 466
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
468 467
 			    echo 'APRS user verified !'."\n";
469 468
 			    $this->connected = true;
470 469
 			    return true;
471 470
 			    break;
472 471
 			}
473
-			if (time()-$authstart > 5) {
472
+			if (time() - $authstart > 5) {
474 473
 			    echo 'APRS timeout'."\n";
475 474
 			    break;
476 475
 			}
477 476
 		}
478
-		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE);
477
+		socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE);
479 478
 	}
480 479
     }
481 480
 
@@ -485,7 +484,7 @@  discard block
 block discarded – undo
485 484
     
486 485
     public function send($data) {
487 486
 	if ($this->connected === false) $this->connect();
488
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
487
+	$send = socket_send($this->socket, $data, strlen($data), 0);
489 488
 	if ($send === FALSE) {
490 489
 		socket_close($this->socket);
491 490
 		$this->connect();
@@ -494,14 +493,14 @@  discard block
 block discarded – undo
494 493
 }
495 494
 
496 495
 class APRSSpotter extends APRS {
497
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
496
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
498 497
 		$Common = new Common();
499 498
 		if ($latitude != '' && $longitude != '') {
500
-			$latitude = $Common->convertDM($latitude,'latitude');
501
-			$longitude = $Common->convertDM($longitude,'longitude');
502
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
503
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
504
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
499
+			$latitude = $Common->convertDM($latitude, 'latitude');
500
+			$longitude = $Common->convertDM($longitude, 'longitude');
501
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
502
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
503
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
505 504
 			$w = $w1.$w2;
506 505
 			//$w = '00';
507 506
 			$custom = '';
@@ -522,25 +521,25 @@  discard block
 block discarded – undo
522 521
 				$custom .= 'AI='.$aircraft_icao;
523 522
 			}
524 523
 			if ($custom != '') $custom = ' '.$custom;
525
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
524
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
526 525
 		}
527 526
 	}
528 527
 }
529 528
 class APRSMarine extends APRS {
530
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
529
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
531 530
 		$Common = new Common();
532 531
 		if ($latitude != '' && $longitude != '') {
533
-			$latitude = $Common->convertDM($latitude,'latitude');
534
-			$longitude = $Common->convertDM($longitude,'longitude');
535
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
536
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
537
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
532
+			$latitude = $Common->convertDM($latitude, 'latitude');
533
+			$longitude = $Common->convertDM($longitude, 'longitude');
534
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
535
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
536
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
538 537
 			$w = $w1.$w2;
539 538
 			//$w = '00';
540 539
 			$custom = '';
541 540
 			if ($ident != '') {
542 541
 				if ($custom != '') $custom .= '/';
543
-				$custom .= 'CS='.str_replace(' ','_',$ident);
542
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
544 543
 			}
545 544
 			if ($typeid != '') {
546 545
 				if ($custom != '') $custom .= '/';
@@ -560,11 +559,11 @@  discard block
 block discarded – undo
560 559
 			}
561 560
 			if ($arrival_code != '') {
562 561
 				if ($custom != '') $custom .= '/';
563
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
562
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
564 563
 			}
565 564
 			if ($custom != '') $custom = ' '.$custom;
566 565
 			$altitude = 0;
567
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
566
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
568 567
 		}
569 568
 	}
570 569
 }
Please login to merge, or discard this patch.
Braces   +155 added lines, -59 removed lines patch added patch discarded remove patch
@@ -107,17 +107,23 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	/* Check that end was found and body has at least one byte. */
109 109
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
110
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
110
+	    if ($globalDebug) {
111
+	    	echo '!!! APRS invalid : '.$input."\n";
112
+	    }
111 113
 	    return false;
112 114
 	}
113 115
 	
114
-	if ($debug) echo 'input : '.$input."\n";
116
+	if ($debug) {
117
+		echo 'input : '.$input."\n";
118
+	}
115 119
 	/* Save header and body. */
116 120
 	$body = substr($input,$splitpos+1,$input_len);
117 121
 	$body_len = strlen($body);
118 122
 	$header = substr($input,0,$splitpos);
119 123
 	//$header_len = strlen($header);
120
-	if ($debug) echo 'header : '.$header."\n";
124
+	if ($debug) {
125
+		echo 'header : '.$header."\n";
126
+	}
121 127
 	
122 128
 	/* Parse source, target and path. */
123 129
 	//FLRDF0A52>APRS,qAS,LSTB
@@ -131,10 +137,14 @@  discard block
 block discarded – undo
131 137
 		$result['format_source'] = 'famaprs';
132 138
 		$result['source_type'] = 'ais';
133 139
 	    } else {
134
-		if ($debug) echo 'ident : '.$ident."\n";
140
+		if ($debug) {
141
+			echo 'ident : '.$ident."\n";
142
+		}
135 143
 		$result['ident'] = $ident;
136 144
 	    }
137
-	} else return false;
145
+	} else {
146
+		return false;
147
+	}
138 148
 	$elements = explode(',',$all_elements);
139 149
 	$source = end($elements);
140 150
 	$result['source'] = $source;
@@ -143,7 +153,9 @@  discard block
 block discarded – undo
143 153
 	        //echo "ok";
144 154
 	        //if ($element == 'TCPIP*') return false;
145 155
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
146
-		if ($debug) echo 'element : '.$element."\n";
156
+		if ($debug) {
157
+			echo 'element : '.$element."\n";
158
+		}
147 159
 		return false;
148 160
 	    }
149 161
 	    /*
@@ -156,13 +168,17 @@  discard block
 block discarded – undo
156 168
 	}
157 169
 	
158 170
 	$type = substr($body,0,1);
159
-	if ($debug) echo 'type : '.$type."\n";
171
+	if ($debug) {
172
+		echo 'type : '.$type."\n";
173
+	}
160 174
 	if ($type == ';') {
161 175
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
162 176
 			$result['address'] = trim(substr($body,1,9));
163 177
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
164 178
 			$result['mmsi'] = trim(substr($body,1,9));
165
-		} else $result['ident'] = trim(substr($body,1,9));
179
+		} else {
180
+			$result['ident'] = trim(substr($body,1,9));
181
+		}
166 182
 	} elseif ($type == ',') {
167 183
 		// Invalid data or test data
168 184
 		return false;
@@ -230,7 +246,9 @@  discard block
 block discarded – undo
230 246
 		//$symbol_table = $matches[4];
231 247
 		$lat = intval($lat_deg);
232 248
 		$lon = intval($lon_deg);
233
-		if ($lat > 89 || $lon > 179) return false;
249
+		if ($lat > 89 || $lon > 179) {
250
+			return false;
251
+		}
234 252
 	    
235 253
 	    /*
236 254
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -240,8 +258,12 @@  discard block
 block discarded – undo
240 258
 	    */
241 259
 		$latitude = $lat + floatval($lat_min)/60;
242 260
 		$longitude = $lon + floatval($lon_min)/60;
243
-		if ($sind == 'S') $latitude = 0-$latitude;
244
-		if ($wind == 'W') $longitude = 0-$longitude;
261
+		if ($sind == 'S') {
262
+			$latitude = 0-$latitude;
263
+		}
264
+		if ($wind == 'W') {
265
+			$longitude = 0-$longitude;
266
+		}
245 267
 		$result['latitude'] = $latitude;
246 268
 		$result['longitude'] = $longitude;
247 269
 		$body_parse = substr($body_parse,18);
@@ -275,7 +297,9 @@  discard block
 block discarded – undo
275 297
 			$body_parse = substr($body_parse,1);
276 298
 			$body_parse_len = strlen($body_parse);
277 299
 			$result['symbol_code'] = $symbol_code;
278
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
300
+			if (isset($this->symbols[$symbol_code])) {
301
+				$result['symbol'] = $this->symbols[$symbol_code];
302
+			}
279 303
 			if ($symbol_code != '_') {
280 304
 			}
281 305
 		    //$body_parse = substr($body_parse,1);
@@ -286,7 +310,9 @@  discard block
 block discarded – undo
286 310
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
287 311
 		    	    $course = substr($body_parse,0,3);
288 312
 		    	    $tmp_s = intval($course);
289
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
313
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
314
+		    	    	$result['heading'] = intval($course);
315
+		    	    }
290 316
 		    	    $speed = substr($body_parse,4,3);
291 317
 		    	    if ($speed != '...') {
292 318
 		    		//$result['speed'] = round($speed*1.852);
@@ -327,10 +353,16 @@  discard block
 block discarded – undo
327 353
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
328 354
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
329 355
 			    
330
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
331
-				else $result['latitude'] += $lat_off;
332
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
333
-				else $result['longitude'] += $lon_off;
356
+				if ($result['latitude'] < 0) {
357
+					$result['latitude'] -= $lat_off;
358
+				} else {
359
+					$result['latitude'] += $lat_off;
360
+				}
361
+				if ($result['longitude'] < 0) {
362
+					$result['longitude'] -= $lon_off;
363
+				} else {
364
+					$result['longitude'] += $lon_off;
365
+				}
334 366
 			    }
335 367
 			    
336 368
 		            $body_parse = substr($body_parse,6);
@@ -372,27 +404,48 @@  discard block
 block discarded – undo
372 404
 			$address = substr($id,2);
373 405
 			//print_r($matches);
374 406
 			$addressType = (intval(substr($id,0,2),16))&3;
375
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
376
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
377
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
378
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
407
+			if ($addressType == 0) {
408
+				$result['addresstype'] = "RANDOM";
409
+			} elseif ($addressType == 1) {
410
+				$result['addresstype'] = "ICAO";
411
+			} elseif ($addressType == 2) {
412
+				$result['addresstype'] = "FLARM";
413
+			} elseif ($addressType == 3) {
414
+				$result['addresstype'] = "OGN";
415
+			}
379 416
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
380 417
 			$result['aircrafttype_code'] = $aircraftType;
381
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
382
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
383
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
384
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
385
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
386
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
387
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
388
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
389
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
390
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
391
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
392
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
393
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
394
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
395
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
418
+			if ($aircraftType == 0) {
419
+				$result['aircrafttype'] = "UNKNOWN";
420
+			} elseif ($aircraftType == 1) {
421
+				$result['aircrafttype'] = "GLIDER";
422
+			} elseif ($aircraftType == 2) {
423
+				$result['aircrafttype'] = "TOW_PLANE";
424
+			} elseif ($aircraftType == 3) {
425
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
426
+			} elseif ($aircraftType == 4) {
427
+				$result['aircrafttype'] = "PARACHUTE";
428
+			} elseif ($aircraftType == 5) {
429
+				$result['aircrafttype'] = "DROP_PLANE";
430
+			} elseif ($aircraftType == 6) {
431
+				$result['aircrafttype'] = "HANG_GLIDER";
432
+			} elseif ($aircraftType == 7) {
433
+				$result['aircrafttype'] = "PARA_GLIDER";
434
+			} elseif ($aircraftType == 8) {
435
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
436
+			} elseif ($aircraftType == 9) {
437
+				$result['aircrafttype'] = "JET_AIRCRAFT";
438
+			} elseif ($aircraftType == 10) {
439
+				$result['aircrafttype'] = "UFO";
440
+			} elseif ($aircraftType == 11) {
441
+				$result['aircrafttype'] = "BALLOON";
442
+			} elseif ($aircraftType == 12) {
443
+				$result['aircrafttype'] = "AIRSHIP";
444
+			} elseif ($aircraftType == 13) {
445
+				$result['aircrafttype'] = "UAV";
446
+			} elseif ($aircraftType == 15) {
447
+				$result['aircrafttype'] = "STATIC_OBJECT";
448
+			}
396 449
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
397 450
 			$result['stealth'] = $stealth;
398 451
 			$result['address'] = $address;
@@ -432,13 +485,21 @@  discard block
 block discarded – undo
432 485
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
433 486
 		    }
434 487
 		}
435
-		} else $result['comment'] = trim($body_parse);
488
+		} else {
489
+			$result['comment'] = trim($body_parse);
490
+		}
436 491
 
437 492
 	    }
438 493
 	//}
439
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
440
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
441
-	if ($debug) print_r($result);
494
+	if (isset($result['latitude'])) {
495
+		$result['latitude'] = round($result['latitude'],4);
496
+	}
497
+	if (isset($result['longitude'])) {
498
+		$result['longitude'] = round($result['longitude'],4);
499
+	}
500
+	if ($debug) {
501
+		print_r($result);
502
+	}
442 503
 	return $result;
443 504
     }
444 505
     
@@ -447,12 +508,21 @@  discard block
 block discarded – undo
447 508
 	$aprs_connect = 0;
448 509
 	$aprs_keep = 120;
449 510
 	$aprs_last_tx = time();
450
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
451
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
452
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
453
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
454
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
455
-	else $aprs_pass = '-1';
511
+	if (isset($globalAPRSversion)) {
512
+		$aprs_version = $globalAPRSversion;
513
+	} else {
514
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
515
+	}
516
+	if (isset($globalServerAPRSssid)) {
517
+		$aprs_ssid = $globalServerAPRSssid;
518
+	} else {
519
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
520
+	}
521
+	if (isset($globalServerAPRSpass)) {
522
+		$aprs_pass = $globalServerAPRSpass;
523
+	} else {
524
+		$aprs_pass = '-1';
525
+	}
456 526
 	
457 527
 	$aprs_filter  = '';
458 528
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -484,7 +554,9 @@  discard block
 block discarded – undo
484 554
     }
485 555
     
486 556
     public function send($data) {
487
-	if ($this->connected === false) $this->connect();
557
+	if ($this->connected === false) {
558
+		$this->connect();
559
+	}
488 560
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
489 561
 	if ($send === FALSE) {
490 562
 		socket_close($this->socket);
@@ -506,22 +578,32 @@  discard block
 block discarded – undo
506 578
 			//$w = '00';
507 579
 			$custom = '';
508 580
 			if ($ident != '') {
509
-				if ($custom != '') $custom .= '/';
581
+				if ($custom != '') {
582
+					$custom .= '/';
583
+				}
510 584
 				$custom .= 'CS='.$ident;
511 585
 			}
512 586
 			if ($squawk != '') {
513
-				if ($custom != '') $custom .= '/';
587
+				if ($custom != '') {
588
+					$custom .= '/';
589
+				}
514 590
 				$custom .= 'SQ='.$squawk;
515 591
 			}
516 592
 			if ($verticalrate != '') {
517
-				if ($custom != '') $custom .= '/';
593
+				if ($custom != '') {
594
+					$custom .= '/';
595
+				}
518 596
 				$custom .= 'VR='.$verticalrate;
519 597
 			}
520 598
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
521
-				if ($custom != '') $custom .= '/';
599
+				if ($custom != '') {
600
+					$custom .= '/';
601
+				}
522 602
 				$custom .= 'AI='.$aircraft_icao;
523 603
 			}
524
-			if ($custom != '') $custom = ' '.$custom;
604
+			if ($custom != '') {
605
+				$custom = ' '.$custom;
606
+			}
525 607
 			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
526 608
 		}
527 609
 	}
@@ -539,30 +621,44 @@  discard block
 block discarded – undo
539 621
 			//$w = '00';
540 622
 			$custom = '';
541 623
 			if ($ident != '') {
542
-				if ($custom != '') $custom .= '/';
624
+				if ($custom != '') {
625
+					$custom .= '/';
626
+				}
543 627
 				$custom .= 'CS='.str_replace(' ','_',$ident);
544 628
 			}
545 629
 			if ($typeid != '') {
546
-				if ($custom != '') $custom .= '/';
630
+				if ($custom != '') {
631
+					$custom .= '/';
632
+				}
547 633
 				$custom .= 'TI='.$typeid;
548 634
 			}
549 635
 			if ($statusid != '') {
550
-				if ($custom != '') $custom .= '/';
636
+				if ($custom != '') {
637
+					$custom .= '/';
638
+				}
551 639
 				$custom .= 'SI='.$statusid;
552 640
 			}
553 641
 			if ($imo != '') {
554
-				if ($custom != '') $custom .= '/';
642
+				if ($custom != '') {
643
+					$custom .= '/';
644
+				}
555 645
 				$custom .= 'IMO='.$imo;
556 646
 			}
557 647
 			if ($arrival_date != '') {
558
-				if ($custom != '') $custom .= '/';
648
+				if ($custom != '') {
649
+					$custom .= '/';
650
+				}
559 651
 				$custom .= 'AD='.strtotime($arrival_date);
560 652
 			}
561 653
 			if ($arrival_code != '') {
562
-				if ($custom != '') $custom .= '/';
654
+				if ($custom != '') {
655
+					$custom .= '/';
656
+				}
563 657
 				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
564 658
 			}
565
-			if ($custom != '') $custom = ' '.$custom;
659
+			if ($custom != '') {
660
+				$custom = ' '.$custom;
661
+			}
566 662
 			$altitude = 0;
567 663
 			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
568 664
 		}
Please login to merge, or discard this patch.
require/class.SBS.php 3 patches
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class SBS {
3
-    static $latlon = array();
3
+	static $latlon = array();
4 4
     
5
-    public function parse($buffer) {
5
+	public function parse($buffer) {
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8 8
 	$data = array();
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
 	$bin = gmp_strval( gmp_init($hex,16), 2);
14 14
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
15 15
 	if (strlen($hex) == 28) {
16
-	    $df = intval(substr($bin,0,5),2);
17
-	    //$ca = intval(substr($bin,5,3),2);
18
-	    // Only support DF17 for now
19
-	    //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
20
-	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
16
+		$df = intval(substr($bin,0,5),2);
17
+		//$ca = intval(substr($bin,5,3),2);
18
+		// Only support DF17 for now
19
+		//if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
20
+		if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
21 21
 		$icao = substr($hex,2,6);
22 22
 		$data['hex'] = $icao;
23 23
 		$tc = intval(substr($bin,32,5),2);
24 24
 		if ($tc >= 1 && $tc <= 4) {
25
-		    //callsign
26
-		    $csbin = substr($bin,40,56);
27
-		    $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
28
-		    $cs = '';
29
-		    $cs .= $charset[intval(substr($csbin,0,6),2)];
30
-		    $cs .= $charset[intval(substr($csbin,6,6),2)];
31
-		    $cs .= $charset[intval(substr($csbin,12,6),2)];
32
-		    $cs .= $charset[intval(substr($csbin,18,6),2)];
33
-		    $cs .= $charset[intval(substr($csbin,24,6),2)];
34
-		    $cs .= $charset[intval(substr($csbin,30,6),2)];
35
-		    $cs .= $charset[intval(substr($csbin,36,6),2)];
36
-		    $cs .= $charset[intval(substr($csbin,42,6),2)];
37
-		    $cs = str_replace('_','',$cs);
38
-		    $cs = str_replace('#','',$cs);
39
-		    $callsign = $cs;
40
-		    $data['ident'] = $callsign;
25
+			//callsign
26
+			$csbin = substr($bin,40,56);
27
+			$charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
28
+			$cs = '';
29
+			$cs .= $charset[intval(substr($csbin,0,6),2)];
30
+			$cs .= $charset[intval(substr($csbin,6,6),2)];
31
+			$cs .= $charset[intval(substr($csbin,12,6),2)];
32
+			$cs .= $charset[intval(substr($csbin,18,6),2)];
33
+			$cs .= $charset[intval(substr($csbin,24,6),2)];
34
+			$cs .= $charset[intval(substr($csbin,30,6),2)];
35
+			$cs .= $charset[intval(substr($csbin,36,6),2)];
36
+			$cs .= $charset[intval(substr($csbin,42,6),2)];
37
+			$cs = str_replace('_','',$cs);
38
+			$cs = str_replace('#','',$cs);
39
+			$callsign = $cs;
40
+			$data['ident'] = $callsign;
41 41
 		} elseif ($tc >= 9 && $tc <= 18) {
42
-		    // Check Q-bit
43
-		    $q = substr($bin,47,1);
44
-		    if ($q) {
42
+			// Check Q-bit
43
+			$q = substr($bin,47,1);
44
+			if ($q) {
45 45
 			$n = intval(substr($bin,40,7).substr($bin,48,4),2);
46 46
 			$alt = $n*25-1000;
47 47
 			$data['altitude'] = $alt;
48
-		    }
49
-		    // Check odd/even flag
50
-		    $oe = substr($bin,53,1);
51
-		    //if ($oe) => odd else even
52
-		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53
-		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
54
-		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
55
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
56
-		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
48
+			}
49
+			// Check odd/even flag
50
+			$oe = substr($bin,53,1);
51
+			//if ($oe) => odd else even
52
+			//  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53
+			$cprlat = intval(substr($bin,54,17),2)/131072.0;
54
+			$cprlon = intval(substr($bin,71,17),2)/131072.0;
55
+			if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
56
+			elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
57 57
 			$cprlat_odd = $cprlat;
58 58
 			$cprlon_odd = $cprlon;
59 59
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -66,53 +66,53 @@  discard block
 block discarded – undo
66 66
 			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
67 67
 			// check latitude zone
68 68
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
69
-			    if ($this::$latlon[$icao]['created'] > time()) {
69
+				if ($this::$latlon[$icao]['created'] > time()) {
70 70
 				$ni = $this->cprN($lat_even,0);
71 71
 				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
72 72
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
73 73
 				$lat = $lat_even;
74 74
 				if ($lon > 180) $lon = $lon -360;
75 75
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
76
-				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77
-				    $data['latitude'] = $lat;
78
-				    $data['longitude'] = $lon;
76
+					//if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77
+					$data['latitude'] = $lat;
78
+					$data['longitude'] = $lon;
79 79
 				}
80
-			    } else {
80
+				} else {
81 81
 				$ni = $this->cprN($lat_odd,1);
82 82
 				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
83 83
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
84 84
 				$lat = $lat_odd;
85 85
 				if ($lon > 180) $lon = $lon -360;
86 86
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87
-				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88
-				    $data['latitude'] = $lat;
89
-				    $data['longitude'] = $lon;
87
+					//if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88
+					$data['latitude'] = $lat;
89
+					$data['longitude'] = $lon;
90
+				}
90 91
 				}
91
-			    }
92 92
 			} else echo "Not cprNL";
93 93
 			unset($this::$latlon[$icao]);
94
-		    }
94
+			}
95 95
 		} elseif ($tc == 19) {
96
-		    // speed & heading
97
-		    $v_ew_dir = intval(substr($bin,45,1));
98
-		    $v_ew = intval(substr($bin,46,10),2);
99
-		    $v_ns_dir = intval(substr($bin,56,1));
100
-		    $v_ns = intval(substr($bin,57,10),2);
101
-		    if ($v_ew_dir) $v_ew = -1*$v_ew;
102
-		    if ($v_ns_dir) $v_ns = -1*$v_ns;
103
-		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104
-		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
-		    if ($heading <0) $heading = $heading+360;
106
-		    $data['speed'] = $speed;
107
-		    $data['heading'] = $heading;
96
+			// speed & heading
97
+			$v_ew_dir = intval(substr($bin,45,1));
98
+			$v_ew = intval(substr($bin,46,10),2);
99
+			$v_ns_dir = intval(substr($bin,56,1));
100
+			$v_ns = intval(substr($bin,57,10),2);
101
+			if ($v_ew_dir) $v_ew = -1*$v_ew;
102
+			if ($v_ns_dir) $v_ns = -1*$v_ns;
103
+			$speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104
+			$heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
+			if ($heading <0) $heading = $heading+360;
106
+			$data['speed'] = $speed;
107
+			$data['heading'] = $heading;
108
+		}
108 109
 		}
109
-	    }
110
-	    if (isset($data)) {
110
+		if (isset($data)) {
111 111
 		//print_r($data);
112 112
 		return $data;
113
-	    }
114
-        }
115
-    }
113
+		}
114
+		}
115
+	}
116 116
 
117 117
 
118 118
 	public function cprNL($lat) {
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
 	if ($lat < 86.53536998) return 3;
178 178
 	if ($lat < 87.00000000) return 2;
179 179
 	return 1;
180
-    }
180
+	}
181 181
     
182
-    public function cprN($lat,$isodd) {
182
+	public function cprN($lat,$isodd) {
183 183
 	$nl = $this->cprNL($lat) - $isodd;
184 184
 	if ($nl > 1) return $nl;
185 185
 	else return 1;
186
-    }
186
+	}
187 187
 
188 188
 
189
-    function parityCheck($msg, $bin) {
189
+	function parityCheck($msg, $bin) {
190 190
 $modes_checksum_table = array(
191 191
 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
192 192
 0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14,
@@ -208,75 +208,75 @@  discard block
 block discarded – undo
208 208
 	$checksum = intval(substr($msg,22,6),16);
209 209
 
210 210
 	for ($j = 0; $j < strlen($bin); $j++) {
211
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
211
+		if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
212 212
 	}
213 213
 	if ($crc == $checksum) return true;
214 214
 	else {
215
-	    //echo "**** CRC ERROR ****\n";
216
-	    return false;
215
+		//echo "**** CRC ERROR ****\n";
216
+		return false;
217
+	}
217 218
 	}
218
-    }
219 219
     
220
-    public function famaprs_to_basestation($data) {
220
+	public function famaprs_to_basestation($data) {
221 221
 	$result = array();
222
-        if (isset($data['ident']) && $data['ident'] != '') {
223
-	    $msg = array();
224
-	    $msg['msg_type'] = 'MSG';
225
-	    $msg['transmission_type'] = 1;
226
-	    $msg['session_id'] = 5;
227
-	    $msg['aircraftid'] = hexdec($data['address']);
228
-	    $msg['hex'] = $data['address'];
229
-	    $msg['flightid'] = hexdec($data['address']);
230
-	    $msg['date_gen'] = date('Y/m/d',$data['timestamp']);
231
-	    $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
232
-	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
233
-	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
234
-	    $msg['callsign'] = $data['ident'];
235
-	    $msg['altitude'] = '';
236
-	    $msg['speed'] = '';
237
-	    $msg['track'] = '';
238
-	    $msg['latitude'] = '';
239
-	    $msg['longitude'] = '';
240
-	    $msg['verticalrate'] = '';
241
-	    $msg['squawk'] = '';
242
-	    $msg['alert'] = '';
243
-	    $msg['emergency'] = '';
244
-	    $msg['SPI'] = '';
245
-	    $msg['ground'] = '';
246
-    	    $result[] = implode(',',$msg);
247
-    	}
248
-    	if (isset($data['latitude']) && $data['latitude'] != 0) {
249
-	    $msg = array();
250
-	    $msg['msg_type'] = 'MSG';
251
-	    $msg['transmission_type'] = 2;
252
-	    $msg['session_id'] = 5;
253
-	    $msg['aircraftid'] = hexdec($data['address']);
254
-	    $msg['hex'] = $data['address'];
255
-	    $msg['flightid'] = hexdec($data['address']);
256
-	    $msg['date_gen'] = date('Y/m/d',$data['timestamp']);
257
-	    $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
258
-	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
259
-	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
260
-	    $msg['callsign'] = '';
261
-	    if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
262
-	    else $msg['altitude'] = '';
263
-	    $msg['speed'] = $data['speed'];
264
-	    if (isset($data['heading'])) $msg['track'] = $data['heading'];
265
-	    else $msg['track'] = '';
266
-	    $msg['latitude'] = $data['latitude'];
267
-	    $msg['longitude'] = $data['longitude'];
268
-	    if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate'];
269
-	    else $msg['verticalrate'] = '';
270
-	    if (isset($data['squawk'])) $msg['squawk'] = $data['squawk'];
271
-	    else $msg['squawk'] = 0;
272
-	    $msg['alert'] = 0;
273
-	    $msg['emergency'] = 0;
274
-	    $msg['SPI'] = 0;
275
-	    if (isset($data['ground'])) $msg['ground'] = 1;
276
-	    else $msg['ground'] = 0;
277
-    	    $result[] = implode(',',$msg);
278
-        }
279
-        return $result;
280
-    }
222
+		if (isset($data['ident']) && $data['ident'] != '') {
223
+		$msg = array();
224
+		$msg['msg_type'] = 'MSG';
225
+		$msg['transmission_type'] = 1;
226
+		$msg['session_id'] = 5;
227
+		$msg['aircraftid'] = hexdec($data['address']);
228
+		$msg['hex'] = $data['address'];
229
+		$msg['flightid'] = hexdec($data['address']);
230
+		$msg['date_gen'] = date('Y/m/d',$data['timestamp']);
231
+		$msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
232
+		$msg['date_log'] = date('Y/m/d',$data['timestamp']);
233
+		$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
234
+		$msg['callsign'] = $data['ident'];
235
+		$msg['altitude'] = '';
236
+		$msg['speed'] = '';
237
+		$msg['track'] = '';
238
+		$msg['latitude'] = '';
239
+		$msg['longitude'] = '';
240
+		$msg['verticalrate'] = '';
241
+		$msg['squawk'] = '';
242
+		$msg['alert'] = '';
243
+		$msg['emergency'] = '';
244
+		$msg['SPI'] = '';
245
+		$msg['ground'] = '';
246
+			$result[] = implode(',',$msg);
247
+		}
248
+		if (isset($data['latitude']) && $data['latitude'] != 0) {
249
+		$msg = array();
250
+		$msg['msg_type'] = 'MSG';
251
+		$msg['transmission_type'] = 2;
252
+		$msg['session_id'] = 5;
253
+		$msg['aircraftid'] = hexdec($data['address']);
254
+		$msg['hex'] = $data['address'];
255
+		$msg['flightid'] = hexdec($data['address']);
256
+		$msg['date_gen'] = date('Y/m/d',$data['timestamp']);
257
+		$msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
258
+		$msg['date_log'] = date('Y/m/d',$data['timestamp']);
259
+		$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
260
+		$msg['callsign'] = '';
261
+		if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
262
+		else $msg['altitude'] = '';
263
+		$msg['speed'] = $data['speed'];
264
+		if (isset($data['heading'])) $msg['track'] = $data['heading'];
265
+		else $msg['track'] = '';
266
+		$msg['latitude'] = $data['latitude'];
267
+		$msg['longitude'] = $data['longitude'];
268
+		if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate'];
269
+		else $msg['verticalrate'] = '';
270
+		if (isset($data['squawk'])) $msg['squawk'] = $data['squawk'];
271
+		else $msg['squawk'] = 0;
272
+		$msg['alert'] = 0;
273
+		$msg['emergency'] = 0;
274
+		$msg['SPI'] = 0;
275
+		if (isset($data['ground'])) $msg['ground'] = 1;
276
+		else $msg['ground'] = 0;
277
+			$result[] = implode(',',$msg);
278
+		}
279
+		return $result;
280
+	}
281 281
 }
282 282
 ?>
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -6,83 +6,83 @@  discard block
 block discarded – undo
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8 8
 	$data = array();
9
-	$typehex = substr($buffer,0,1);
10
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
11
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
12
-	else $hex = substr($buffer,1,-1);
13
-	$bin = gmp_strval( gmp_init($hex,16), 2);
9
+	$typehex = substr($buffer, 0, 1);
10
+	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1);
11
+	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13);
12
+	else $hex = substr($buffer, 1, -1);
13
+	$bin = gmp_strval(gmp_init($hex, 16), 2);
14 14
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
15 15
 	if (strlen($hex) == 28) {
16
-	    $df = intval(substr($bin,0,5),2);
16
+	    $df = intval(substr($bin, 0, 5), 2);
17 17
 	    //$ca = intval(substr($bin,5,3),2);
18 18
 	    // Only support DF17 for now
19 19
 	    //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
20
-	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
21
-		$icao = substr($hex,2,6);
20
+	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) {
21
+		$icao = substr($hex, 2, 6);
22 22
 		$data['hex'] = $icao;
23
-		$tc = intval(substr($bin,32,5),2);
23
+		$tc = intval(substr($bin, 32, 5), 2);
24 24
 		if ($tc >= 1 && $tc <= 4) {
25 25
 		    //callsign
26
-		    $csbin = substr($bin,40,56);
26
+		    $csbin = substr($bin, 40, 56);
27 27
 		    $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
28 28
 		    $cs = '';
29
-		    $cs .= $charset[intval(substr($csbin,0,6),2)];
30
-		    $cs .= $charset[intval(substr($csbin,6,6),2)];
31
-		    $cs .= $charset[intval(substr($csbin,12,6),2)];
32
-		    $cs .= $charset[intval(substr($csbin,18,6),2)];
33
-		    $cs .= $charset[intval(substr($csbin,24,6),2)];
34
-		    $cs .= $charset[intval(substr($csbin,30,6),2)];
35
-		    $cs .= $charset[intval(substr($csbin,36,6),2)];
36
-		    $cs .= $charset[intval(substr($csbin,42,6),2)];
37
-		    $cs = str_replace('_','',$cs);
38
-		    $cs = str_replace('#','',$cs);
29
+		    $cs .= $charset[intval(substr($csbin, 0, 6), 2)];
30
+		    $cs .= $charset[intval(substr($csbin, 6, 6), 2)];
31
+		    $cs .= $charset[intval(substr($csbin, 12, 6), 2)];
32
+		    $cs .= $charset[intval(substr($csbin, 18, 6), 2)];
33
+		    $cs .= $charset[intval(substr($csbin, 24, 6), 2)];
34
+		    $cs .= $charset[intval(substr($csbin, 30, 6), 2)];
35
+		    $cs .= $charset[intval(substr($csbin, 36, 6), 2)];
36
+		    $cs .= $charset[intval(substr($csbin, 42, 6), 2)];
37
+		    $cs = str_replace('_', '', $cs);
38
+		    $cs = str_replace('#', '', $cs);
39 39
 		    $callsign = $cs;
40 40
 		    $data['ident'] = $callsign;
41 41
 		} elseif ($tc >= 9 && $tc <= 18) {
42 42
 		    // Check Q-bit
43
-		    $q = substr($bin,47,1);
43
+		    $q = substr($bin, 47, 1);
44 44
 		    if ($q) {
45
-			$n = intval(substr($bin,40,7).substr($bin,48,4),2);
46
-			$alt = $n*25-1000;
45
+			$n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2);
46
+			$alt = $n*25 - 1000;
47 47
 			$data['altitude'] = $alt;
48 48
 		    }
49 49
 		    // Check odd/even flag
50
-		    $oe = substr($bin,53,1);
50
+		    $oe = substr($bin, 53, 1);
51 51
 		    //if ($oe) => odd else even
52 52
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53
-		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
54
-		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
55
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
53
+		    $cprlat = intval(substr($bin, 54, 17), 2)/131072.0;
54
+		    $cprlon = intval(substr($bin, 71, 17), 2)/131072.0;
55
+		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time());
56 56
 		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
57 57
 			$cprlat_odd = $cprlat;
58 58
 			$cprlon_odd = $cprlon;
59 59
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
60 60
 			$cprlon_even = $this::$latlon[$icao]['longitude'];
61 61
 		    
62
-			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
63
-			$lat_even = (360.0/60)*($j%60+$cprlat_even);
64
-			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
62
+			$j = 59*$cprlat_even - 60*$cprlat_odd + 0.5;
63
+			$lat_even = (360.0/60)*($j%60 + $cprlat_even);
64
+			$lat_odd = (360.0/59)*($j%59 + $cprlat_odd);
65 65
 			if ($lat_even >= 270) $lat_even = $lat_even - 360;
66 66
 			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
67 67
 			// check latitude zone
68 68
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
69 69
 			    if ($this::$latlon[$icao]['created'] > time()) {
70
-				$ni = $this->cprN($lat_even,0);
71
-				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
72
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
70
+				$ni = $this->cprN($lat_even, 0);
71
+				$m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5);
72
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_even);
73 73
 				$lat = $lat_even;
74
-				if ($lon > 180) $lon = $lon -360;
74
+				if ($lon > 180) $lon = $lon - 360;
75 75
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
76 76
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77 77
 				    $data['latitude'] = $lat;
78 78
 				    $data['longitude'] = $lon;
79 79
 				}
80 80
 			    } else {
81
-				$ni = $this->cprN($lat_odd,1);
82
-				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
83
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
81
+				$ni = $this->cprN($lat_odd, 1);
82
+				$m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5);
83
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_odd);
84 84
 				$lat = $lat_odd;
85
-				if ($lon > 180) $lon = $lon -360;
85
+				if ($lon > 180) $lon = $lon - 360;
86 86
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 87
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88 88
 				    $data['latitude'] = $lat;
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 		    }
95 95
 		} elseif ($tc == 19) {
96 96
 		    // speed & heading
97
-		    $v_ew_dir = intval(substr($bin,45,1));
98
-		    $v_ew = intval(substr($bin,46,10),2);
99
-		    $v_ns_dir = intval(substr($bin,56,1));
100
-		    $v_ns = intval(substr($bin,57,10),2);
97
+		    $v_ew_dir = intval(substr($bin, 45, 1));
98
+		    $v_ew = intval(substr($bin, 46, 10), 2);
99
+		    $v_ns_dir = intval(substr($bin, 56, 1));
100
+		    $v_ns = intval(substr($bin, 57, 10), 2);
101 101
 		    if ($v_ew_dir) $v_ew = -1*$v_ew;
102 102
 		    if ($v_ns_dir) $v_ns = -1*$v_ns;
103
-		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104
-		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
-		    if ($heading <0) $heading = $heading+360;
103
+		    $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew);
104
+		    $heading = atan2($v_ew, $v_ns)*360.0/(2*pi());
105
+		    if ($heading < 0) $heading = $heading + 360;
106 106
 		    $data['speed'] = $speed;
107 107
 		    $data['heading'] = $heading;
108 108
 		}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 	public function cprNL($lat) {
119 119
 	//Lookup table to convert the latitude to index.
120
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
120
+	if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator.
121 121
 	if ($lat < 10.47047130) return 59;
122 122
 	if ($lat < 14.82817437) return 58;
123 123
 	if ($lat < 18.18626357) return 57;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	return 1;
180 180
     }
181 181
     
182
-    public function cprN($lat,$isodd) {
182
+    public function cprN($lat, $isodd) {
183 183
 	$nl = $this->cprNL($lat) - $isodd;
184 184
 	if ($nl > 1) return $nl;
185 185
 	else return 1;
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 );
206 206
 
207 207
 	$crc = 0;
208
-	$checksum = intval(substr($msg,22,6),16);
208
+	$checksum = intval(substr($msg, 22, 6), 16);
209 209
 
210 210
 	for ($j = 0; $j < strlen($bin); $j++) {
211
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
211
+	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0);
212 212
 	}
213 213
 	if ($crc == $checksum) return true;
214 214
 	else {
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 	    $msg['aircraftid'] = hexdec($data['address']);
228 228
 	    $msg['hex'] = $data['address'];
229 229
 	    $msg['flightid'] = hexdec($data['address']);
230
-	    $msg['date_gen'] = date('Y/m/d',$data['timestamp']);
231
-	    $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
232
-	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
233
-	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
230
+	    $msg['date_gen'] = date('Y/m/d', $data['timestamp']);
231
+	    $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180';
232
+	    $msg['date_log'] = date('Y/m/d', $data['timestamp']);
233
+	    $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180';
234 234
 	    $msg['callsign'] = $data['ident'];
235 235
 	    $msg['altitude'] = '';
236 236
 	    $msg['speed'] = '';
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	    $msg['emergency'] = '';
244 244
 	    $msg['SPI'] = '';
245 245
 	    $msg['ground'] = '';
246
-    	    $result[] = implode(',',$msg);
246
+    	    $result[] = implode(',', $msg);
247 247
     	}
248 248
     	if (isset($data['latitude']) && $data['latitude'] != 0) {
249 249
 	    $msg = array();
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	    $msg['aircraftid'] = hexdec($data['address']);
254 254
 	    $msg['hex'] = $data['address'];
255 255
 	    $msg['flightid'] = hexdec($data['address']);
256
-	    $msg['date_gen'] = date('Y/m/d',$data['timestamp']);
257
-	    $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
258
-	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
259
-	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
256
+	    $msg['date_gen'] = date('Y/m/d', $data['timestamp']);
257
+	    $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180';
258
+	    $msg['date_log'] = date('Y/m/d', $data['timestamp']);
259
+	    $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180';
260 260
 	    $msg['callsign'] = '';
261 261
 	    if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
262 262
 	    else $msg['altitude'] = '';
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	    $msg['SPI'] = 0;
275 275
 	    if (isset($data['ground'])) $msg['ground'] = 1;
276 276
 	    else $msg['ground'] = 0;
277
-    	    $result[] = implode(',',$msg);
277
+    	    $result[] = implode(',', $msg);
278 278
         }
279 279
         return $result;
280 280
     }
Please login to merge, or discard this patch.
Braces   +248 added lines, -87 removed lines patch added patch discarded remove patch
@@ -7,9 +7,13 @@  discard block
 block discarded – undo
7 7
 	//echo $buffer."\n";
8 8
 	$data = array();
9 9
 	$typehex = substr($buffer,0,1);
10
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
11
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
12
-	else $hex = substr($buffer,1,-1);
10
+	if ($typehex == '*' || $typehex == ':') {
11
+		$hex = substr($buffer,1,-1);
12
+	} elseif ($typehex == '@' || $typehex == '%') {
13
+		$hex = substr($buffer,13,-13);
14
+	} else {
15
+		$hex = substr($buffer,1,-1);
16
+	}
13 17
 	$bin = gmp_strval( gmp_init($hex,16), 2);
14 18
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
15 19
 	if (strlen($hex) == 28) {
@@ -52,8 +56,9 @@  discard block
 block discarded – undo
52 56
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53 57
 		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
54 58
 		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
55
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
56
-		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
59
+		    if ($oe == 0) {
60
+		    	$this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
61
+		    } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
57 62
 			$cprlat_odd = $cprlat;
58 63
 			$cprlon_odd = $cprlon;
59 64
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -62,8 +67,12 @@  discard block
 block discarded – undo
62 67
 			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
63 68
 			$lat_even = (360.0/60)*($j%60+$cprlat_even);
64 69
 			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
65
-			if ($lat_even >= 270) $lat_even = $lat_even - 360;
66
-			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
70
+			if ($lat_even >= 270) {
71
+				$lat_even = $lat_even - 360;
72
+			}
73
+			if ($lat_odd >= 270) {
74
+				$lat_odd = $lat_odd - 360;
75
+			}
67 76
 			// check latitude zone
68 77
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
69 78
 			    if ($this::$latlon[$icao]['created'] > time()) {
@@ -71,7 +80,9 @@  discard block
 block discarded – undo
71 80
 				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
72 81
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
73 82
 				$lat = $lat_even;
74
-				if ($lon > 180) $lon = $lon -360;
83
+				if ($lon > 180) {
84
+					$lon = $lon -360;
85
+				}
75 86
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
76 87
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77 88
 				    $data['latitude'] = $lat;
@@ -82,14 +93,18 @@  discard block
 block discarded – undo
82 93
 				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
83 94
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
84 95
 				$lat = $lat_odd;
85
-				if ($lon > 180) $lon = $lon -360;
96
+				if ($lon > 180) {
97
+					$lon = $lon -360;
98
+				}
86 99
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 100
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88 101
 				    $data['latitude'] = $lat;
89 102
 				    $data['longitude'] = $lon;
90 103
 				}
91 104
 			    }
92
-			} else echo "Not cprNL";
105
+			} else {
106
+				echo "Not cprNL";
107
+			}
93 108
 			unset($this::$latlon[$icao]);
94 109
 		    }
95 110
 		} elseif ($tc == 19) {
@@ -98,11 +113,17 @@  discard block
 block discarded – undo
98 113
 		    $v_ew = intval(substr($bin,46,10),2);
99 114
 		    $v_ns_dir = intval(substr($bin,56,1));
100 115
 		    $v_ns = intval(substr($bin,57,10),2);
101
-		    if ($v_ew_dir) $v_ew = -1*$v_ew;
102
-		    if ($v_ns_dir) $v_ns = -1*$v_ns;
116
+		    if ($v_ew_dir) {
117
+		    	$v_ew = -1*$v_ew;
118
+		    }
119
+		    if ($v_ns_dir) {
120
+		    	$v_ns = -1*$v_ns;
121
+		    }
103 122
 		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104 123
 		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
-		    if ($heading <0) $heading = $heading+360;
124
+		    if ($heading <0) {
125
+		    	$heading = $heading+360;
126
+		    }
106 127
 		    $data['speed'] = $speed;
107 128
 		    $data['heading'] = $heading;
108 129
 		}
@@ -117,72 +138,194 @@  discard block
 block discarded – undo
117 138
 
118 139
 	public function cprNL($lat) {
119 140
 	//Lookup table to convert the latitude to index.
120
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
121
-	if ($lat < 10.47047130) return 59;
122
-	if ($lat < 14.82817437) return 58;
123
-	if ($lat < 18.18626357) return 57;
124
-	if ($lat < 21.02939493) return 56;
125
-	if ($lat < 23.54504487) return 55;
126
-	if ($lat < 25.82924707) return 54;
127
-	if ($lat < 27.93898710) return 53;
128
-	if ($lat < 29.91135686) return 52;
129
-	if ($lat < 31.77209708) return 51;
130
-	if ($lat < 33.53993436) return 50;
131
-	if ($lat < 35.22899598) return 49;
132
-	if ($lat < 36.85025108) return 48;
133
-	if ($lat < 38.41241892) return 47;
134
-	if ($lat < 39.92256684) return 46;
135
-	if ($lat < 41.38651832) return 45;
136
-	if ($lat < 42.80914012) return 44;
137
-	if ($lat < 44.19454951) return 43;
138
-	if ($lat < 45.54626723) return 42;
139
-	if ($lat < 46.86733252) return 41;
140
-	if ($lat < 48.16039128) return 40;
141
-	if ($lat < 49.42776439) return 39;
142
-	if ($lat < 50.67150166) return 38;
143
-	if ($lat < 51.89342469) return 37;
144
-	if ($lat < 53.09516153) return 36;
145
-	if ($lat < 54.27817472) return 35;
146
-	if ($lat < 55.44378444) return 34;
147
-	if ($lat < 56.59318756) return 33;
148
-	if ($lat < 57.72747354) return 32;
149
-	if ($lat < 58.84763776) return 31;
150
-	if ($lat < 59.95459277) return 30;
151
-	if ($lat < 61.04917774) return 29;
152
-	if ($lat < 62.13216659) return 28;
153
-	if ($lat < 63.20427479) return 27;
154
-	if ($lat < 64.26616523) return 26;
155
-	if ($lat < 65.31845310) return 25;
156
-	if ($lat < 66.36171008) return 24;
157
-	if ($lat < 67.39646774) return 23;
158
-	if ($lat < 68.42322022) return 22;
159
-	if ($lat < 69.44242631) return 21;
160
-	if ($lat < 70.45451075) return 20;
161
-	if ($lat < 71.45986473) return 19;
162
-	if ($lat < 72.45884545) return 18;
163
-	if ($lat < 73.45177442) return 17;
164
-	if ($lat < 74.43893416) return 16;
165
-	if ($lat < 75.42056257) return 15;
166
-	if ($lat < 76.39684391) return 14;
167
-	if ($lat < 77.36789461) return 13;
168
-	if ($lat < 78.33374083) return 12;
169
-	if ($lat < 79.29428225) return 11;
170
-	if ($lat < 80.24923213) return 10;
171
-	if ($lat < 81.19801349) return 9;
172
-	if ($lat < 82.13956981) return 8;
173
-	if ($lat < 83.07199445) return 7;
174
-	if ($lat < 83.99173563) return 6;
175
-	if ($lat < 84.89166191) return 5;
176
-	if ($lat < 85.75541621) return 4;
177
-	if ($lat < 86.53536998) return 3;
178
-	if ($lat < 87.00000000) return 2;
141
+	if ($lat < 0) {
142
+		$lat = -$lat;
143
+	}
144
+	// Table is simmetric about the equator.
145
+	if ($lat < 10.47047130) {
146
+		return 59;
147
+	}
148
+	if ($lat < 14.82817437) {
149
+		return 58;
150
+	}
151
+	if ($lat < 18.18626357) {
152
+		return 57;
153
+	}
154
+	if ($lat < 21.02939493) {
155
+		return 56;
156
+	}
157
+	if ($lat < 23.54504487) {
158
+		return 55;
159
+	}
160
+	if ($lat < 25.82924707) {
161
+		return 54;
162
+	}
163
+	if ($lat < 27.93898710) {
164
+		return 53;
165
+	}
166
+	if ($lat < 29.91135686) {
167
+		return 52;
168
+	}
169
+	if ($lat < 31.77209708) {
170
+		return 51;
171
+	}
172
+	if ($lat < 33.53993436) {
173
+		return 50;
174
+	}
175
+	if ($lat < 35.22899598) {
176
+		return 49;
177
+	}
178
+	if ($lat < 36.85025108) {
179
+		return 48;
180
+	}
181
+	if ($lat < 38.41241892) {
182
+		return 47;
183
+	}
184
+	if ($lat < 39.92256684) {
185
+		return 46;
186
+	}
187
+	if ($lat < 41.38651832) {
188
+		return 45;
189
+	}
190
+	if ($lat < 42.80914012) {
191
+		return 44;
192
+	}
193
+	if ($lat < 44.19454951) {
194
+		return 43;
195
+	}
196
+	if ($lat < 45.54626723) {
197
+		return 42;
198
+	}
199
+	if ($lat < 46.86733252) {
200
+		return 41;
201
+	}
202
+	if ($lat < 48.16039128) {
203
+		return 40;
204
+	}
205
+	if ($lat < 49.42776439) {
206
+		return 39;
207
+	}
208
+	if ($lat < 50.67150166) {
209
+		return 38;
210
+	}
211
+	if ($lat < 51.89342469) {
212
+		return 37;
213
+	}
214
+	if ($lat < 53.09516153) {
215
+		return 36;
216
+	}
217
+	if ($lat < 54.27817472) {
218
+		return 35;
219
+	}
220
+	if ($lat < 55.44378444) {
221
+		return 34;
222
+	}
223
+	if ($lat < 56.59318756) {
224
+		return 33;
225
+	}
226
+	if ($lat < 57.72747354) {
227
+		return 32;
228
+	}
229
+	if ($lat < 58.84763776) {
230
+		return 31;
231
+	}
232
+	if ($lat < 59.95459277) {
233
+		return 30;
234
+	}
235
+	if ($lat < 61.04917774) {
236
+		return 29;
237
+	}
238
+	if ($lat < 62.13216659) {
239
+		return 28;
240
+	}
241
+	if ($lat < 63.20427479) {
242
+		return 27;
243
+	}
244
+	if ($lat < 64.26616523) {
245
+		return 26;
246
+	}
247
+	if ($lat < 65.31845310) {
248
+		return 25;
249
+	}
250
+	if ($lat < 66.36171008) {
251
+		return 24;
252
+	}
253
+	if ($lat < 67.39646774) {
254
+		return 23;
255
+	}
256
+	if ($lat < 68.42322022) {
257
+		return 22;
258
+	}
259
+	if ($lat < 69.44242631) {
260
+		return 21;
261
+	}
262
+	if ($lat < 70.45451075) {
263
+		return 20;
264
+	}
265
+	if ($lat < 71.45986473) {
266
+		return 19;
267
+	}
268
+	if ($lat < 72.45884545) {
269
+		return 18;
270
+	}
271
+	if ($lat < 73.45177442) {
272
+		return 17;
273
+	}
274
+	if ($lat < 74.43893416) {
275
+		return 16;
276
+	}
277
+	if ($lat < 75.42056257) {
278
+		return 15;
279
+	}
280
+	if ($lat < 76.39684391) {
281
+		return 14;
282
+	}
283
+	if ($lat < 77.36789461) {
284
+		return 13;
285
+	}
286
+	if ($lat < 78.33374083) {
287
+		return 12;
288
+	}
289
+	if ($lat < 79.29428225) {
290
+		return 11;
291
+	}
292
+	if ($lat < 80.24923213) {
293
+		return 10;
294
+	}
295
+	if ($lat < 81.19801349) {
296
+		return 9;
297
+	}
298
+	if ($lat < 82.13956981) {
299
+		return 8;
300
+	}
301
+	if ($lat < 83.07199445) {
302
+		return 7;
303
+	}
304
+	if ($lat < 83.99173563) {
305
+		return 6;
306
+	}
307
+	if ($lat < 84.89166191) {
308
+		return 5;
309
+	}
310
+	if ($lat < 85.75541621) {
311
+		return 4;
312
+	}
313
+	if ($lat < 86.53536998) {
314
+		return 3;
315
+	}
316
+	if ($lat < 87.00000000) {
317
+		return 2;
318
+	}
179 319
 	return 1;
180 320
     }
181 321
     
182 322
     public function cprN($lat,$isodd) {
183 323
 	$nl = $this->cprNL($lat) - $isodd;
184
-	if ($nl > 1) return $nl;
185
-	else return 1;
324
+	if ($nl > 1) {
325
+		return $nl;
326
+	} else {
327
+		return 1;
328
+	}
186 329
     }
187 330
 
188 331
 
@@ -208,10 +351,13 @@  discard block
 block discarded – undo
208 351
 	$checksum = intval(substr($msg,22,6),16);
209 352
 
210 353
 	for ($j = 0; $j < strlen($bin); $j++) {
211
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
354
+	    if ($bin[$j]) {
355
+	    	$crc = $crc^intval($modes_checksum_table[$j],0);
356
+	    }
212 357
 	}
213
-	if ($crc == $checksum) return true;
214
-	else {
358
+	if ($crc == $checksum) {
359
+		return true;
360
+	} else {
215 361
 	    //echo "**** CRC ERROR ****\n";
216 362
 	    return false;
217 363
 	}
@@ -258,22 +404,37 @@  discard block
 block discarded – undo
258 404
 	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
259 405
 	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
260 406
 	    $msg['callsign'] = '';
261
-	    if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
262
-	    else $msg['altitude'] = '';
407
+	    if (isset($data['altitude'])) {
408
+	    	$msg['altitude'] = $data['altitude'];
409
+	    } else {
410
+	    	$msg['altitude'] = '';
411
+	    }
263 412
 	    $msg['speed'] = $data['speed'];
264
-	    if (isset($data['heading'])) $msg['track'] = $data['heading'];
265
-	    else $msg['track'] = '';
413
+	    if (isset($data['heading'])) {
414
+	    	$msg['track'] = $data['heading'];
415
+	    } else {
416
+	    	$msg['track'] = '';
417
+	    }
266 418
 	    $msg['latitude'] = $data['latitude'];
267 419
 	    $msg['longitude'] = $data['longitude'];
268
-	    if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate'];
269
-	    else $msg['verticalrate'] = '';
270
-	    if (isset($data['squawk'])) $msg['squawk'] = $data['squawk'];
271
-	    else $msg['squawk'] = 0;
420
+	    if (isset($data['verticalrate'])) {
421
+	    	$msg['verticalrate'] = $data['verticalrate'];
422
+	    } else {
423
+	    	$msg['verticalrate'] = '';
424
+	    }
425
+	    if (isset($data['squawk'])) {
426
+	    	$msg['squawk'] = $data['squawk'];
427
+	    } else {
428
+	    	$msg['squawk'] = 0;
429
+	    }
272 430
 	    $msg['alert'] = 0;
273 431
 	    $msg['emergency'] = 0;
274 432
 	    $msg['SPI'] = 0;
275
-	    if (isset($data['ground'])) $msg['ground'] = 1;
276
-	    else $msg['ground'] = 0;
433
+	    if (isset($data['ground'])) {
434
+	    	$msg['ground'] = 1;
435
+	    } else {
436
+	    	$msg['ground'] = 0;
437
+	    }
277 438
     	    $result[] = implode(',',$msg);
278 439
         }
279 440
         return $result;
Please login to merge, or discard this patch.
require/class.Marine.php 3 patches
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	/**
14
-	* Get SQL query part for filter used
15
-	* @param Array $filter the filter
16
-	* @return Array the SQL part
17
-	*/
14
+	 * Get SQL query part for filter used
15
+	 * @param Array $filter the filter
16
+	 * @return Array the SQL part
17
+	 */
18 18
 	
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	}
79 79
 
80 80
 	/**
81
-	* Executes the SQL statements to get the spotter information
82
-	*
83
-	* @param String $query the SQL query
84
-	* @param Array $params parameter of the query
85
-	* @param String $limitQuery the limit query
86
-	* @return Array the spotter information
87
-	*
88
-	*/
81
+	 * Executes the SQL statements to get the spotter information
82
+	 *
83
+	 * @param String $query the SQL query
84
+	 * @param Array $params parameter of the query
85
+	 * @param String $limitQuery the limit query
86
+	 * @return Array the spotter information
87
+	 *
88
+	 */
89 89
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	
214 214
 	
215 215
 	/**
216
-	* Gets all the spotter information based on the latest data entry
217
-	*
218
-	* @return Array the spotter information
219
-	*
220
-	*/
216
+	 * Gets all the spotter information based on the latest data entry
217
+	 *
218
+	 * @return Array the spotter information
219
+	 *
220
+	 */
221 221
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
222 222
 	{
223 223
 		global $global_query;
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 	}
267 267
 
268 268
 	/**
269
-	* Gets all the spotter information based on the callsign
270
-	*
271
-	* @return Array the spotter information
272
-	*
273
-	*/
269
+	 * Gets all the spotter information based on the callsign
270
+	 *
271
+	 * @return Array the spotter information
272
+	 *
273
+	 */
274 274
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
275 275
 	{
276 276
 		global $global_query;
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
 
382 382
 
383 383
 	/**
384
-	* Gets all source name
385
-	*
386
-	* @param String type format of source
387
-	* @return Array list of source name
388
-	*
389
-	*/
384
+	 * Gets all source name
385
+	 *
386
+	 * @param String type format of source
387
+	 * @return Array list of source name
388
+	 *
389
+	 */
390 390
 	public function getAllSourceName($type = '',$filters = array())
391 391
 	{
392 392
 		$filter_query = $this->getFilter($filters,true,true);
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 
417 417
 
418 418
 	/**
419
-	* Gets a list of all idents/callsigns
420
-	*
421
-	* @return Array list of ident/callsign names
422
-	*
423
-	*/
419
+	 * Gets a list of all idents/callsigns
420
+	 *
421
+	 * @return Array list of ident/callsign names
422
+	 *
423
+	 */
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426 426
 		$filter_query = $this->getFilter($filters,true,true);
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
 	}
445 445
 
446 446
 	/**
447
-	* Gets all info from a mmsi
448
-	*
449
-	* @return Array list of mmsi info
450
-	*
451
-	*/
447
+	 * Gets all info from a mmsi
448
+	 *
449
+	 * @return Array list of mmsi info
450
+	 *
451
+	 */
452 452
 	public function getIdentity($mmsi)
453 453
 	{
454 454
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -505,18 +505,18 @@  discard block
 block discarded – undo
505 505
 	
506 506
 	
507 507
 	/**
508
-	* Update ident tracker data
509
-	*
510
-	* @param String $fammarine_id the ID
511
-	* @param String $ident the marine ident
512
-	* @return String success or false
513
-	*
514
-	*/	
508
+	 * Update ident tracker data
509
+	 *
510
+	 * @param String $fammarine_id the ID
511
+	 * @param String $ident the marine ident
512
+	 * @return String success or false
513
+	 *
514
+	 */	
515 515
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
516 516
 	{
517 517
 
518 518
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
519
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
519
+				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
520 520
 
521 521
 		try {
522 522
 			$sth = $this->db->prepare($query);
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
 	}
531 531
 
532 532
 	/**
533
-	* Update Status data
534
-	*
535
-	* @param String $fammarine_id the ID
536
-	* @param String $status_id the marine status id
537
-	* @param String $status the marine status
538
-	* @return String success or false
539
-	*
540
-	*/	
533
+	 * Update Status data
534
+	 *
535
+	 * @param String $fammarine_id the ID
536
+	 * @param String $status_id the marine status id
537
+	 * @param String $status the marine status
538
+	 * @return String success or false
539
+	 *
540
+	 */	
541 541
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
542 542
 	{
543 543
 
544 544
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
545
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
545
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
546 546
 
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
@@ -555,17 +555,17 @@  discard block
 block discarded – undo
555 555
 
556 556
 	}
557 557
 	/**
558
-	* Update latest marine data
559
-	*
560
-	* @param String $fammarine_id the ID
561
-	* @param String $ident the marine ident
562
-	* @return String success or false
563
-	*
564
-	*/	
558
+	 * Update latest marine data
559
+	 *
560
+	 * @param String $fammarine_id the ID
561
+	 * @param String $ident the marine ident
562
+	 * @return String success or false
563
+	 *
564
+	 */	
565 565
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
566 566
 	{
567 567
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
568
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
568
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
@@ -579,30 +579,30 @@  discard block
 block discarded – undo
579 579
 	}
580 580
 
581 581
 	/**
582
-	* Adds a new spotter data
583
-	*
584
-	* @param String $fammarine_id the ID
585
-	* @param String $ident the marine ident
586
-	* @param String $departure_airport_icao the departure airport
587
-	* @param String $arrival_airport_icao the arrival airport
588
-	* @param String $latitude latitude of flight
589
-	* @param String $longitude latitude of flight
590
-	* @param String $waypoints waypoints of flight
591
-	* @param String $heading heading of flight
592
-	* @param String $groundspeed speed of flight
593
-	* @param String $date date of flight
594
-	* @param String $departure_airport_time departure time of flight
595
-	* @param String $arrival_airport_time arrival time of flight
596
-	* @param String $squawk squawk code of flight
597
-	* @param String $route_stop route stop of flight
598
-	* @param String $highlight highlight or not
599
-	* @param String $ModeS ModesS code of flight
600
-	* @param String $registration registration code of flight
601
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
602
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
603
-	* @param String $verticalrate vertival rate of flight
604
-	* @return String success or false
605
-	*/
582
+	 * Adds a new spotter data
583
+	 *
584
+	 * @param String $fammarine_id the ID
585
+	 * @param String $ident the marine ident
586
+	 * @param String $departure_airport_icao the departure airport
587
+	 * @param String $arrival_airport_icao the arrival airport
588
+	 * @param String $latitude latitude of flight
589
+	 * @param String $longitude latitude of flight
590
+	 * @param String $waypoints waypoints of flight
591
+	 * @param String $heading heading of flight
592
+	 * @param String $groundspeed speed of flight
593
+	 * @param String $date date of flight
594
+	 * @param String $departure_airport_time departure time of flight
595
+	 * @param String $arrival_airport_time arrival time of flight
596
+	 * @param String $squawk squawk code of flight
597
+	 * @param String $route_stop route stop of flight
598
+	 * @param String $highlight highlight or not
599
+	 * @param String $ModeS ModesS code of flight
600
+	 * @param String $registration registration code of flight
601
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
602
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
603
+	 * @param String $verticalrate vertival rate of flight
604
+	 * @return String success or false
605
+	 */
606 606
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
607 607
 	{
608 608
 		global $globalURL, $globalMarineImageFetch;
@@ -699,13 +699,13 @@  discard block
 block discarded – undo
699 699
 			unset($Image);
700 700
 		}
701 701
 		
702
-                if ($latitude == '' && $longitude == '') {
703
-            		$latitude = 0;
704
-            		$longitude = 0;
705
-            	}
706
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
-                if ($arrival_date == '') $arrival_date = NULL;
702
+				if ($latitude == '' && $longitude == '') {
703
+					$latitude = 0;
704
+					$longitude = 0;
705
+				}
706
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
+				if ($arrival_date == '') $arrival_date = NULL;
709 709
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 710
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 711
 
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 			$sth->execute($query_values);
717 717
 			$this->db = null;
718 718
 		} catch (PDOException $e) {
719
-		    return "error : ".$e->getMessage();
719
+			return "error : ".$e->getMessage();
720 720
 		}
721 721
 		
722 722
 		return "success";
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
 	
726 726
   
727 727
 	/**
728
-	* Gets the aircraft ident within the last hour
729
-	*
730
-	* @return String the ident
731
-	*
732
-	*/
728
+	 * Gets the aircraft ident within the last hour
729
+	 *
730
+	 * @return String the ident
731
+	 *
732
+	 */
733 733
 	public function getIdentFromLastHour($ident)
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
746 746
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
747 747
 			$query_data = array(':ident' => $ident);
748
-    		}
748
+			}
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-    		$ident_result='';
752
+			$ident_result='';
753 753
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['ident'];
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 	
761 761
 	
762 762
 	/**
763
-	* Gets the aircraft data from the last 20 seconds
764
-	*
765
-	* @return Array the spotter data
766
-	*
767
-	*/
763
+	 * Gets the aircraft data from the last 20 seconds
764
+	 *
765
+	 * @return Array the spotter data
766
+	 *
767
+	 */
768 768
 	public function getRealTimeData($q = '')
769 769
 	{
770 770
 		global $globalDBdriver;
@@ -802,11 +802,11 @@  discard block
 block discarded – undo
802 802
 	
803 803
 
804 804
 	/**
805
-	* Gets all number of flight over countries
806
-	*
807
-	* @return Array the airline country list
808
-	*
809
-	*/
805
+	 * Gets all number of flight over countries
806
+	 *
807
+	 * @return Array the airline country list
808
+	 *
809
+	 */
810 810
 
811 811
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
812 812
 	{
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
 	
879 879
 	
880 880
 	/**
881
-	* Gets all callsigns that have flown over
882
-	*
883
-	* @return Array the callsign list
884
-	*
885
-	*/
881
+	 * Gets all callsigns that have flown over
882
+	 *
883
+	 * @return Array the callsign list
884
+	 *
885
+	 */
886 886
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
887 887
 	{
888 888
 		global $globalDBdriver;
@@ -949,11 +949,11 @@  discard block
 block discarded – undo
949 949
 
950 950
 
951 951
 	/**
952
-	* Counts all dates
953
-	*
954
-	* @return Array the date list
955
-	*
956
-	*/
952
+	 * Counts all dates
953
+	 *
954
+	 * @return Array the date list
955
+	 *
956
+	 */
957 957
 	public function countAllDates($filters = array())
958 958
 	{
959 959
 		global $globalTimezone, $globalDBdriver;
@@ -999,11 +999,11 @@  discard block
 block discarded – undo
999 999
 	
1000 1000
 	
1001 1001
 	/**
1002
-	* Counts all dates during the last 7 days
1003
-	*
1004
-	* @return Array the date list
1005
-	*
1006
-	*/
1002
+	 * Counts all dates during the last 7 days
1003
+	 *
1004
+	 * @return Array the date list
1005
+	 *
1006
+	 */
1007 1007
 	public function countAllDatesLast7Days($filters = array())
1008 1008
 	{
1009 1009
 		global $globalTimezone, $globalDBdriver;
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 			$query .= " GROUP BY date_name 
1026 1026
 								ORDER BY date_name ASC";
1027 1027
 			$query_data = array(':offset' => $offset);
1028
-    		}
1028
+			}
1029 1029
 		
1030 1030
 		$sth = $this->db->prepare($query);
1031 1031
 		$sth->execute($query_data);
@@ -1045,11 +1045,11 @@  discard block
 block discarded – undo
1045 1045
 	}
1046 1046
 
1047 1047
 	/**
1048
-	* Counts all dates during the last month
1049
-	*
1050
-	* @return Array the date list
1051
-	*
1052
-	*/
1048
+	 * Counts all dates during the last month
1049
+	 *
1050
+	 * @return Array the date list
1051
+	 *
1052
+	 */
1053 1053
 	public function countAllDatesLastMonth($filters = array())
1054 1054
 	{
1055 1055
 		global $globalTimezone, $globalDBdriver;
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 			$query .= " GROUP BY date_name 
1072 1072
 								ORDER BY date_name ASC";
1073 1073
 			$query_data = array(':offset' => $offset);
1074
-    		}
1074
+			}
1075 1075
 		
1076 1076
 		$sth = $this->db->prepare($query);
1077 1077
 		$sth->execute($query_data);
@@ -1093,11 +1093,11 @@  discard block
 block discarded – undo
1093 1093
 
1094 1094
 
1095 1095
 	/**
1096
-	* Counts all month
1097
-	*
1098
-	* @return Array the month list
1099
-	*
1100
-	*/
1096
+	 * Counts all month
1097
+	 *
1098
+	 * @return Array the month list
1099
+	 *
1100
+	 */
1101 1101
 	public function countAllMonths($filters = array())
1102 1102
 	{
1103 1103
 		global $globalTimezone, $globalDBdriver;
@@ -1142,11 +1142,11 @@  discard block
 block discarded – undo
1142 1142
 	
1143 1143
 
1144 1144
 	/**
1145
-	* Counts all dates during the last year
1146
-	*
1147
-	* @return Array the date list
1148
-	*
1149
-	*/
1145
+	 * Counts all dates during the last year
1146
+	 *
1147
+	 * @return Array the date list
1148
+	 *
1149
+	 */
1150 1150
 	public function countAllMonthsLastYear($filters)
1151 1151
 	{
1152 1152
 		global $globalTimezone, $globalDBdriver;
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 			$query .= " GROUP BY year_name, month_name
1169 1169
 								ORDER BY year_name, month_name ASC";
1170 1170
 			$query_data = array(':offset' => $offset);
1171
-    		}
1171
+			}
1172 1172
 		
1173 1173
 		$sth = $this->db->prepare($query);
1174 1174
 		$sth->execute($query_data);
@@ -1191,11 +1191,11 @@  discard block
 block discarded – undo
1191 1191
 	
1192 1192
 	
1193 1193
 	/**
1194
-	* Counts all hours
1195
-	*
1196
-	* @return Array the hour list
1197
-	*
1198
-	*/
1194
+	 * Counts all hours
1195
+	 *
1196
+	 * @return Array the hour list
1197
+	 *
1198
+	 */
1199 1199
 	public function countAllHours($orderby,$filters = array())
1200 1200
 	{
1201 1201
 		global $globalTimezone, $globalDBdriver;
@@ -1258,11 +1258,11 @@  discard block
 block discarded – undo
1258 1258
 	
1259 1259
 	
1260 1260
 	/**
1261
-	* Counts all hours by date
1262
-	*
1263
-	* @return Array the hour list
1264
-	*
1265
-	*/
1261
+	 * Counts all hours by date
1262
+	 *
1263
+	 * @return Array the hour list
1264
+	 *
1265
+	 */
1266 1266
 	public function countAllHoursByDate($date, $filters = array())
1267 1267
 	{
1268 1268
 		global $globalTimezone, $globalDBdriver;
@@ -1306,11 +1306,11 @@  discard block
 block discarded – undo
1306 1306
 	
1307 1307
 	
1308 1308
 	/**
1309
-	* Counts all hours by a ident/callsign
1310
-	*
1311
-	* @return Array the hour list
1312
-	*
1313
-	*/
1309
+	 * Counts all hours by a ident/callsign
1310
+	 *
1311
+	 * @return Array the hour list
1312
+	 *
1313
+	 */
1314 1314
 	public function countAllHoursByIdent($ident, $filters = array())
1315 1315
 	{
1316 1316
 		global $globalTimezone, $globalDBdriver;
@@ -1355,11 +1355,11 @@  discard block
 block discarded – undo
1355 1355
 	
1356 1356
 	
1357 1357
 	/**
1358
-	* Counts all flights that have flown over
1359
-	*
1360
-	* @return Integer the number of flights
1361
-	*
1362
-	*/
1358
+	 * Counts all flights that have flown over
1359
+	 *
1360
+	 * @return Integer the number of flights
1361
+	 *
1362
+	 */
1363 1363
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1364 1364
 	{
1365 1365
 		global $globalDBdriver;
@@ -1395,11 +1395,11 @@  discard block
 block discarded – undo
1395 1395
 	
1396 1396
   
1397 1397
 	/**
1398
-	* Counts all hours of today
1399
-	*
1400
-	* @return Array the hour list
1401
-	*
1402
-	*/
1398
+	 * Counts all hours of today
1399
+	 *
1400
+	 * @return Array the hour list
1401
+	 *
1402
+	 */
1403 1403
 	public function countAllHoursFromToday($filters = array())
1404 1404
 	{
1405 1405
 		global $globalTimezone, $globalDBdriver;
@@ -1439,12 +1439,12 @@  discard block
 block discarded – undo
1439 1439
 	}
1440 1440
     
1441 1441
     
1442
-     /**
1443
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1444
-	*
1445
-	* @return Integer the Barrie Spotter ID
1442
+	 /**
1443
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1444
+	  *
1445
+	  * @return Integer the Barrie Spotter ID
1446 1446
 q	*
1447
-	*/
1447
+	  */
1448 1448
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1449 1449
 	{
1450 1450
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1465,13 +1465,13 @@  discard block
 block discarded – undo
1465 1465
   
1466 1466
  
1467 1467
 	/**
1468
-	* Parses a date string
1469
-	*
1470
-	* @param String $dateString the date string
1471
-	* @param String $timezone the timezone of a user
1472
-	* @return Array the time information
1473
-	*
1474
-	*/
1468
+	 * Parses a date string
1469
+	 *
1470
+	 * @param String $dateString the date string
1471
+	 * @param String $timezone the timezone of a user
1472
+	 * @return Array the time information
1473
+	 *
1474
+	 */
1475 1475
 	public function parseDateString($dateString, $timezone = '')
1476 1476
 	{
1477 1477
 		$time_array = array();
@@ -1504,12 +1504,12 @@  discard block
 block discarded – undo
1504 1504
 	}
1505 1505
 	
1506 1506
 	/**
1507
-	* Parses the direction degrees to working
1508
-	*
1509
-	* @param Float $direction the direction in degrees
1510
-	* @return Array the direction information
1511
-	*
1512
-	*/
1507
+	 * Parses the direction degrees to working
1508
+	 *
1509
+	 * @param Float $direction the direction in degrees
1510
+	 * @return Array the direction information
1511
+	 *
1512
+	 */
1513 1513
 	public function parseDirection($direction = 0)
1514 1514
 	{
1515 1515
 		if ($direction == '') $direction = 0;
@@ -1588,12 +1588,12 @@  discard block
 block discarded – undo
1588 1588
 	
1589 1589
 	
1590 1590
 	/**
1591
-	* Gets Country from latitude/longitude
1592
-	*
1593
-	* @param Float $latitude latitute of the flight
1594
-	* @param Float $longitude longitute of the flight
1595
-	* @return String the countrie
1596
-	*/
1591
+	 * Gets Country from latitude/longitude
1592
+	 *
1593
+	 * @param Float $latitude latitute of the flight
1594
+	 * @param Float $longitude longitute of the flight
1595
+	 * @return String the countrie
1596
+	 */
1597 1597
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1598 1598
 	{
1599 1599
 		global $globalDBdriver, $globalDebug;
@@ -1630,11 +1630,11 @@  discard block
 block discarded – undo
1630 1630
 	}
1631 1631
 
1632 1632
 	/**
1633
-	* Gets Country from iso2
1634
-	*
1635
-	* @param String $iso2 ISO2 country code
1636
-	* @return String the countrie
1637
-	*/
1633
+	 * Gets Country from iso2
1634
+	 *
1635
+	 * @param String $iso2 ISO2 country code
1636
+	 * @return String the countrie
1637
+	 */
1638 1638
 	public function getCountryFromISO2($iso2)
1639 1639
 	{
1640 1640
 		global $globalDBdriver, $globalDebug;
@@ -1663,12 +1663,12 @@  discard block
 block discarded – undo
1663 1663
 
1664 1664
 	
1665 1665
 	/**
1666
-	* Gets the short url from bit.ly
1667
-	*
1668
-	* @param String $url the full url
1669
-	* @return String the bit.ly url
1670
-	*
1671
-	*/
1666
+	 * Gets the short url from bit.ly
1667
+	 *
1668
+	 * @param String $url the full url
1669
+	 * @return String the bit.ly url
1670
+	 *
1671
+	 */
1672 1672
 	public function getBitlyURL($url)
1673 1673
 	{
1674 1674
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @return Array the SQL part
17 17
 	*/
18 18
 	
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72 72
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73 73
 		if ($filter_query_where != '') {
74
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
74
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
75 75
 		}
76 76
 		$filter_query = $filter_query_join.$filter_query_where;
77 77
 		return $filter_query;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	* @return Array the spotter information
87 87
 	*
88 88
 	*/
89
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
89
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
92 92
 		if (!is_string($query))
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 			$sth = $this->db->prepare($query.$limitQuery);
107 107
 			$sth->execute($params);
108 108
 		} catch (PDOException $e) {
109
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
109
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
110 110
 			exit();
111 111
 		}
112 112
 		
113 113
 		$num_rows = 0;
114 114
 		$spotter_array = array();
115
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
115
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
116 116
 		{
117 117
 			$num_rows++;
118 118
 			$temp_array = array();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 			}
145 145
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 146
 
147
-			if($temp_array['mmsi'] != "")
147
+			if ($temp_array['mmsi'] != "")
148 148
 			{
149 149
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
150
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
151 151
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
152 152
 				unset($Image);
153 153
 				if (count($image_array) > 0) {
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 				{
184 184
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
185 185
 				} else {
186
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
186
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
187 187
 				}
188 188
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
189
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
190
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
189
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
190
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
191 191
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
192 192
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
193 193
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
194 194
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
195
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
196
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
195
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
196
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
197 197
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
198 198
 					}
199 199
 				}
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		if ($limit != "")
227 227
 		{
228 228
 			$limit_array = explode(",", $limit);
229
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
230
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
229
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
230
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
231 231
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
232 232
 			{
233 233
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 		} else {
242 242
 			$orderby_query = " ORDER BY marine_output.date DESC";
243 243
 		}
244
-		$query  = $global_query.$filter_query." ".$orderby_query;
245
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
244
+		$query = $global_query.$filter_query." ".$orderby_query;
245
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
246 246
 		return $spotter_array;
247 247
 	}
248 248
     
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 		if ($id == '') return array();
261 261
 		$additional_query = "marine_output.fammarine_id = :id";
262 262
 		$query_values = array(':id' => $id);
263
-		$query  = $global_query." WHERE ".$additional_query." ";
264
-		$spotter_array = $this->getDataFromDB($query,$query_values);
263
+		$query = $global_query." WHERE ".$additional_query." ";
264
+		$spotter_array = $this->getDataFromDB($query, $query_values);
265 265
 		return $spotter_array;
266 266
 	}
267 267
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$query_values = array();
281 281
 		$limit_query = '';
282 282
 		$additional_query = '';
283
-		$filter_query = $this->getFilter($filter,true,true);
283
+		$filter_query = $this->getFilter($filter, true, true);
284 284
 		if ($ident != "")
285 285
 		{
286 286
 			if (!is_string($ident))
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 		{
297 297
 			$limit_array = explode(",", $limit);
298 298
 			
299
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
300
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
299
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
300
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
301 301
 			
302 302
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
303 303
 			{
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		return $spotter_array;
322 322
 	}
323 323
 	
324
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
324
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
325 325
 	{
326 326
 		global $global_query, $globalTimezone, $globalDBdriver;
327 327
 		
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		$limit_query = '';
330 330
 		$additional_query = '';
331 331
 
332
-		$filter_query = $this->getFilter($filter,true,true);
332
+		$filter_query = $this->getFilter($filter, true, true);
333 333
 		
334 334
 		if ($date != "")
335 335
 		{
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 		{
356 356
 			$limit_array = explode(",", $limit);
357 357
 			
358
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
359
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
358
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
359
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
360 360
 			
361 361
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
362 362
 			{
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	* @return Array list of source name
388 388
 	*
389 389
 	*/
390
-	public function getAllSourceName($type = '',$filters = array())
390
+	public function getAllSourceName($type = '', $filters = array())
391 391
 	{
392
-		$filter_query = $this->getFilter($filters,true,true);
392
+		$filter_query = $this->getFilter($filters, true, true);
393 393
 		$query_values = array();
394
-		$query  = "SELECT DISTINCT marine_output.source_name 
394
+		$query = "SELECT DISTINCT marine_output.source_name 
395 395
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
396 396
 		if ($type != '') {
397 397
 			$query_values = array(':type' => $type);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		$source_array = array();
407 407
 		$temp_array = array();
408 408
 		
409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
410 410
 		{
411 411
 			$temp_array['source_name'] = $row['source_name'];
412 412
 			$source_array[] = $temp_array;
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 	*/
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426
-		$filter_query = $this->getFilter($filters,true,true);
427
-		$query  = "SELECT DISTINCT marine_output.ident
426
+		$filter_query = $this->getFilter($filters, true, true);
427
+		$query = "SELECT DISTINCT marine_output.ident
428 428
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
429 429
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
430 430
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		$ident_array = array();
435 435
 		$temp_array = array();
436 436
 		
437
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
437
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
438 438
 		{
439 439
 			$temp_array['ident'] = $row['ident'];
440 440
 			$ident_array[] = $temp_array;
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	*/
452 452
 	public function getIdentity($mmsi)
453 453
 	{
454
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
454
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
455 455
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
456 456
 		$sth = $this->db->prepare($query);
457 457
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 		} else $offset = '+00:00';
477 477
 
478 478
 		if ($globalDBdriver == 'mysql') {
479
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
479
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
480 480
 								FROM marine_output
481 481
 								WHERE marine_output.date <> '' 
482 482
 								ORDER BY marine_output.date ASC LIMIT 0,200";
483 483
 		} else {
484
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
484
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
485 485
 								FROM marine_output
486 486
 								WHERE marine_output.date <> '' 
487 487
 								ORDER BY marine_output.date ASC LIMIT 0,200";
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		$date_array = array();
494 494
 		$temp_array = array();
495 495
 		
496
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
496
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
497 497
 		{
498 498
 			$temp_array['date'] = $row['date'];
499 499
 
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	* @return String success or false
513 513
 	*
514 514
 	*/	
515
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
515
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
516 516
 	{
517 517
 
518 518
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
519
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
519
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
520 520
 
521 521
 		try {
522 522
 			$sth = $this->db->prepare($query);
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
 	* @return String success or false
539 539
 	*
540 540
 	*/	
541
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
541
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
542 542
 	{
543 543
 
544 544
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
545
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
545
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
546 546
 
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
566 566
 	{
567 567
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
568
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
568
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	* @param String $verticalrate vertival rate of flight
604 604
 	* @return String success or false
605 605
 	*/
606
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
606
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '')
607 607
 	{
608 608
 		global $globalURL, $globalMarineImageFetch;
609 609
 		
@@ -670,31 +670,31 @@  discard block
 block discarded – undo
670 670
 		}
671 671
 
672 672
     
673
-		if ($date == "" || strtotime($date) < time()-20*60)
673
+		if ($date == "" || strtotime($date) < time() - 20*60)
674 674
 		{
675 675
 			$date = date("Y-m-d H:i:s", time());
676 676
 		}
677 677
 
678
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
679
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
680
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
681
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
682
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
683
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
684
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
685
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
686
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
687
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
688
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
689
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
690
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
691
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
678
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
679
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
681
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
682
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
683
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
684
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
685
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
686
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
687
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
688
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
689
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
690
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
691
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
692 692
 	
693 693
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
694 694
 			$Image = new Image($this->db);
695
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
695
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
696 696
 			if (!isset($image_array[0]['mmsi'])) {
697
-				$Image->addMarineImage($mmsi,$imo,$ident);
697
+				$Image->addMarineImage($mmsi, $imo, $ident);
698 698
 			}
699 699
 			unset($Image);
700 700
 		}
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707 707
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708 708
                 if ($arrival_date == '') $arrival_date = NULL;
709
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
709
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 710
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 711
 
712
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
712
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
713 713
 		try {
714 714
 		        
715 715
 			$sth = $this->db->prepare($query);
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
736 736
 		if ($globalDBdriver == 'mysql') {
737
-			$query  = "SELECT marine_output.ident FROM marine_output 
737
+			$query = "SELECT marine_output.ident FROM marine_output 
738 738
 								WHERE marine_output.ident = :ident 
739 739
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
740 740
 								AND marine_output.date < UTC_TIMESTAMP()";
741 741
 			$query_data = array(':ident' => $ident);
742 742
 		} else {
743
-			$query  = "SELECT marine_output.ident FROM marine_output 
743
+			$query = "SELECT marine_output.ident FROM marine_output 
744 744
 								WHERE marine_output.ident = :ident 
745 745
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
746 746
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-    		$ident_result='';
753
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
752
+    		$ident_result = '';
753
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['ident'];
756 756
 		}
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 				return false;
777 777
 			} else {
778 778
 				$q_array = explode(" ", $q);
779
-				foreach ($q_array as $q_item){
780
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
779
+				foreach ($q_array as $q_item) {
780
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
781 781
 					$additional_query .= " AND (";
782 782
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
783 783
 					$additional_query .= ")";
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
 			}
786 786
 		}
787 787
 		if ($globalDBdriver == 'mysql') {
788
-			$query  = "SELECT marine_output.* FROM marine_output 
788
+			$query = "SELECT marine_output.* FROM marine_output 
789 789
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
790 790
 				AND marine_output.date < UTC_TIMESTAMP()";
791 791
 		} else {
792
-			$query  = "SELECT marine_output.* FROM marine_output 
792
+			$query = "SELECT marine_output.* FROM marine_output 
793 793
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
794 794
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
795 795
 		}
@@ -808,16 +808,16 @@  discard block
 block discarded – undo
808 808
 	*
809 809
 	*/
810 810
 
811
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
811
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
812 812
 	{
813 813
 		global $globalDBdriver, $globalArchive;
814 814
 		//$filter_query = $this->getFilter($filters,true,true);
815
-		$Connection= new Connection($this->db);
815
+		$Connection = new Connection($this->db);
816 816
 		if (!$Connection->tableExists('countries')) return array();
817 817
 		require_once('class.SpotterLive.php');
818 818
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 819
 			$MarineLive = new MarineLive();
820
-			$filter_query = $MarineLive->getFilter($filters,true,true);
820
+			$filter_query = $MarineLive->getFilter($filters, true, true);
821 821
 			$filter_query .= ' over_country IS NOT NULL';
822 822
 			if ($olderthanmonths > 0) {
823 823
 				if ($globalDBdriver == 'mysql') {
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM marine_live".$filter_query.") l ON c.iso2 = l.over_country ";
837 837
 		} else {
838 838
 			$MarineArchive = new MarineArchive();
839
-			$filter_query = $MarineLive->getFilter($filters,true,true);
839
+			$filter_query = $MarineLive->getFilter($filters, true, true);
840 840
 			$filter_query .= ' over_country IS NOT NULL';
841 841
 			if ($olderthanmonths > 0) {
842 842
 				if ($globalDBdriver == 'mysql') {
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 		$flight_array = array();
865 865
 		$temp_array = array();
866 866
         
867
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
867
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
868 868
 		{
869 869
 			$temp_array['flight_count'] = $row['nb'];
870 870
 			$temp_array['flight_country'] = $row['name'];
@@ -883,11 +883,11 @@  discard block
 block discarded – undo
883 883
 	* @return Array the callsign list
884 884
 	*
885 885
 	*/
886
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
886
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
887 887
 	{
888 888
 		global $globalDBdriver;
889
-		$filter_query = $this->getFilter($filters,true,true);
890
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
889
+		$filter_query = $this->getFilter($filters, true, true);
890
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
891 891
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
892 892
 		 if ($olderthanmonths > 0) {
893 893
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -901,28 +901,28 @@  discard block
 block discarded – undo
901 901
 		if ($year != '') {
902 902
 			if ($globalDBdriver == 'mysql') {
903 903
 				$query .= " AND YEAR(marine_output.date) = :year";
904
-				$query_values = array_merge($query_values,array(':year' => $year));
904
+				$query_values = array_merge($query_values, array(':year' => $year));
905 905
 			} else {
906 906
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
907
-				$query_values = array_merge($query_values,array(':year' => $year));
907
+				$query_values = array_merge($query_values, array(':year' => $year));
908 908
 			}
909 909
 		}
910 910
 		if ($month != '') {
911 911
 			if ($globalDBdriver == 'mysql') {
912 912
 				$query .= " AND MONTH(marine_output.date) = :month";
913
-				$query_values = array_merge($query_values,array(':month' => $month));
913
+				$query_values = array_merge($query_values, array(':month' => $month));
914 914
 			} else {
915 915
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
916
-				$query_values = array_merge($query_values,array(':month' => $month));
916
+				$query_values = array_merge($query_values, array(':month' => $month));
917 917
 			}
918 918
 		}
919 919
 		if ($day != '') {
920 920
 			if ($globalDBdriver == 'mysql') {
921 921
 				$query .= " AND DAY(marine_output.date) = :day";
922
-				$query_values = array_merge($query_values,array(':day' => $day));
922
+				$query_values = array_merge($query_values, array(':day' => $day));
923 923
 			} else {
924 924
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
925
-				$query_values = array_merge($query_values,array(':day' => $day));
925
+				$query_values = array_merge($query_values, array(':day' => $day));
926 926
 			}
927 927
 		}
928 928
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 		$callsign_array = array();
935 935
 		$temp_array = array();
936 936
         
937
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
937
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
938 938
 		{
939 939
 			$temp_array['callsign_icao'] = $row['ident'];
940 940
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 		$date_array = array();
987 987
 		$temp_array = array();
988 988
         
989
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
989
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
990 990
 		{
991 991
 			$temp_array['date_name'] = $row['date_name'];
992 992
 			$temp_array['date_count'] = $row['date_count'];
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 			$datetime = new DateTime();
1013 1013
 			$offset = $datetime->format('P');
1014 1014
 		} else $offset = '+00:00';
1015
-		$filter_query = $this->getFilter($filters,true,true);
1015
+		$filter_query = $this->getFilter($filters, true, true);
1016 1016
 		if ($globalDBdriver == 'mysql') {
1017 1017
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1018 1018
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 		$date_array = array();
1034 1034
 		$temp_array = array();
1035 1035
         
1036
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1036
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1037 1037
 		{
1038 1038
 			$temp_array['date_name'] = $row['date_name'];
1039 1039
 			$temp_array['date_count'] = $row['date_count'];
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 			$datetime = new DateTime();
1059 1059
 			$offset = $datetime->format('P');
1060 1060
 		} else $offset = '+00:00';
1061
-		$filter_query = $this->getFilter($filters,true,true);
1061
+		$filter_query = $this->getFilter($filters, true, true);
1062 1062
 		if ($globalDBdriver == 'mysql') {
1063 1063
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1064 1064
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 		$date_array = array();
1080 1080
 		$temp_array = array();
1081 1081
         
1082
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1082
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1083 1083
 		{
1084 1084
 			$temp_array['date_name'] = $row['date_name'];
1085 1085
 			$temp_array['date_count'] = $row['date_count'];
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 		$date_array = array();
1127 1127
 		$temp_array = array();
1128 1128
         
1129
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1129
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1130 1130
 		{
1131 1131
 			$temp_array['month_name'] = $row['month_name'];
1132 1132
 			$temp_array['year_name'] = $row['year_name'];
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			$datetime = new DateTime();
1156 1156
 			$offset = $datetime->format('P');
1157 1157
 		} else $offset = '+00:00';
1158
-		$filter_query = $this->getFilter($filters,true,true);
1158
+		$filter_query = $this->getFilter($filters, true, true);
1159 1159
 		if ($globalDBdriver == 'mysql') {
1160 1160
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1161 1161
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 		$date_array = array();
1177 1177
 		$temp_array = array();
1178 1178
         
1179
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1179
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1180 1180
 		{
1181 1181
 			$temp_array['year_name'] = $row['year_name'];
1182 1182
 			$temp_array['month_name'] = $row['month_name'];
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 	* @return Array the hour list
1197 1197
 	*
1198 1198
 	*/
1199
-	public function countAllHours($orderby,$filters = array())
1199
+	public function countAllHours($orderby, $filters = array())
1200 1200
 	{
1201 1201
 		global $globalTimezone, $globalDBdriver;
1202 1202
 		if ($globalTimezone != '') {
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 		$hour_array = array();
1245 1245
 		$temp_array = array();
1246 1246
         
1247
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1247
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1248 1248
 		{
1249 1249
 			$temp_array['hour_name'] = $row['hour_name'];
1250 1250
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1266,8 +1266,8 @@  discard block
 block discarded – undo
1266 1266
 	public function countAllHoursByDate($date, $filters = array())
1267 1267
 	{
1268 1268
 		global $globalTimezone, $globalDBdriver;
1269
-		$filter_query = $this->getFilter($filters,true,true);
1270
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1269
+		$filter_query = $this->getFilter($filters, true, true);
1270
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1271 1271
 		if ($globalTimezone != '') {
1272 1272
 			date_default_timezone_set($globalTimezone);
1273 1273
 			$datetime = new DateTime($date);
@@ -1275,12 +1275,12 @@  discard block
 block discarded – undo
1275 1275
 		} else $offset = '+00:00';
1276 1276
 
1277 1277
 		if ($globalDBdriver == 'mysql') {
1278
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1278
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1279 1279
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1280 1280
 								GROUP BY hour_name 
1281 1281
 								ORDER BY hour_name ASC";
1282 1282
 		} else {
1283
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1283
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1284 1284
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1285 1285
 								GROUP BY hour_name 
1286 1286
 								ORDER BY hour_name ASC";
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
 		$hour_array = array();
1293 1293
 		$temp_array = array();
1294 1294
         
1295
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1295
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1296 1296
 		{
1297 1297
 			$temp_array['hour_name'] = $row['hour_name'];
1298 1298
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1314,8 +1314,8 @@  discard block
 block discarded – undo
1314 1314
 	public function countAllHoursByIdent($ident, $filters = array())
1315 1315
 	{
1316 1316
 		global $globalTimezone, $globalDBdriver;
1317
-		$filter_query = $this->getFilter($filters,true,true);
1318
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1317
+		$filter_query = $this->getFilter($filters, true, true);
1318
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1319 1319
 		if ($globalTimezone != '') {
1320 1320
 			date_default_timezone_set($globalTimezone);
1321 1321
 			$datetime = new DateTime();
@@ -1323,12 +1323,12 @@  discard block
 block discarded – undo
1323 1323
 		} else $offset = '+00:00';
1324 1324
 
1325 1325
 		if ($globalDBdriver == 'mysql') {
1326
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1326
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1327 1327
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1328 1328
 								GROUP BY hour_name 
1329 1329
 								ORDER BY hour_name ASC";
1330 1330
 		} else {
1331
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1331
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1332 1332
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1333 1333
 								GROUP BY hour_name 
1334 1334
 								ORDER BY hour_name ASC";
@@ -1336,12 +1336,12 @@  discard block
 block discarded – undo
1336 1336
       
1337 1337
 		
1338 1338
 		$sth = $this->db->prepare($query);
1339
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1339
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1340 1340
       
1341 1341
 		$hour_array = array();
1342 1342
 		$temp_array = array();
1343 1343
         
1344
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1344
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1345 1345
 		{
1346 1346
 			$temp_array['hour_name'] = $row['hour_name'];
1347 1347
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1360,33 +1360,33 @@  discard block
 block discarded – undo
1360 1360
 	* @return Integer the number of flights
1361 1361
 	*
1362 1362
 	*/
1363
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1363
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1364 1364
 	{
1365 1365
 		global $globalDBdriver;
1366 1366
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1367
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1367
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1368 1368
 		$query_values = array();
1369 1369
 		$query = '';
1370 1370
 		if ($year != '') {
1371 1371
 			if ($globalDBdriver == 'mysql') {
1372 1372
 				$query .= " AND YEAR(marine_output.date) = :year";
1373
-				$query_values = array_merge($query_values,array(':year' => $year));
1373
+				$query_values = array_merge($query_values, array(':year' => $year));
1374 1374
 			} else {
1375 1375
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1376
-				$query_values = array_merge($query_values,array(':year' => $year));
1376
+				$query_values = array_merge($query_values, array(':year' => $year));
1377 1377
 			}
1378 1378
 		}
1379 1379
 		if ($month != '') {
1380 1380
 			if ($globalDBdriver == 'mysql') {
1381 1381
 				$query .= " AND MONTH(marine_output.date) = :month";
1382
-				$query_values = array_merge($query_values,array(':month' => $month));
1382
+				$query_values = array_merge($query_values, array(':month' => $month));
1383 1383
 			} else {
1384 1384
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1385
-				$query_values = array_merge($query_values,array(':month' => $month));
1385
+				$query_values = array_merge($query_values, array(':month' => $month));
1386 1386
 			}
1387 1387
 		}
1388 1388
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1389
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1389
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1390 1390
 		
1391 1391
 		$sth = $this->db->prepare($queryi);
1392 1392
 		$sth->execute($query_values);
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
 	public function countAllHoursFromToday($filters = array())
1404 1404
 	{
1405 1405
 		global $globalTimezone, $globalDBdriver;
1406
-		$filter_query = $this->getFilter($filters,true,true);
1406
+		$filter_query = $this->getFilter($filters, true, true);
1407 1407
 		if ($globalTimezone != '') {
1408 1408
 			date_default_timezone_set($globalTimezone);
1409 1409
 			$datetime = new DateTime();
@@ -1411,12 +1411,12 @@  discard block
 block discarded – undo
1411 1411
 		} else $offset = '+00:00';
1412 1412
 
1413 1413
 		if ($globalDBdriver == 'mysql') {
1414
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1414
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1415 1415
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1416 1416
 								GROUP BY hour_name 
1417 1417
 								ORDER BY hour_name ASC";
1418 1418
 		} else {
1419
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1419
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1420 1420
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1421 1421
 								GROUP BY hour_name 
1422 1422
 								ORDER BY hour_name ASC";
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 		$hour_array = array();
1429 1429
 		$temp_array = array();
1430 1430
         
1431
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1431
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1432 1432
 		{
1433 1433
 			$temp_array['hour_name'] = $row['hour_name'];
1434 1434
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1447,9 +1447,9 @@  discard block
 block discarded – undo
1447 1447
 	*/
1448 1448
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1449 1449
 	{
1450
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1450
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1451 1451
 
1452
-		$query  = "SELECT marine_output.marine_id
1452
+		$query = "SELECT marine_output.marine_id
1453 1453
 				FROM marine_output 
1454 1454
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1455 1455
         
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
 		$sth = $this->db->prepare($query);
1458 1458
 		$sth->execute();
1459 1459
 
1460
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1460
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1461 1461
 		{
1462 1462
 			return $row['marine_id'];
1463 1463
 		}
@@ -1482,23 +1482,23 @@  discard block
 block discarded – undo
1482 1482
 		}
1483 1483
 		
1484 1484
 		$current_date = date("Y-m-d H:i:s");
1485
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1485
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1486 1486
 		
1487 1487
 		$diff = abs(strtotime($current_date) - strtotime($date));
1488 1488
 
1489
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1489
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1490 1490
 		$years = $time_array['years'];
1491 1491
 		
1492
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1492
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1493 1493
 		$months = $time_array['months'];
1494 1494
 		
1495
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1495
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1496 1496
 		$days = $time_array['days'];
1497
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1497
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1498 1498
 		$hours = $time_array['hours'];
1499
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1499
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1500 1500
 		$minutes = $time_array['minutes'];
1501
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1501
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1502 1502
 		
1503 1503
 		return $time_array;
1504 1504
 	}
@@ -1521,63 +1521,63 @@  discard block
 block discarded – undo
1521 1521
 			$temp_array['direction_degree'] = $direction;
1522 1522
 			$temp_array['direction_shortname'] = "N";
1523 1523
 			$temp_array['direction_fullname'] = "North";
1524
-		} elseif ($direction >= 22.5 && $direction < 45){
1524
+		} elseif ($direction >= 22.5 && $direction < 45) {
1525 1525
 			$temp_array['direction_degree'] = $direction;
1526 1526
 			$temp_array['direction_shortname'] = "NNE";
1527 1527
 			$temp_array['direction_fullname'] = "North-Northeast";
1528
-		} elseif ($direction >= 45 && $direction < 67.5){
1528
+		} elseif ($direction >= 45 && $direction < 67.5) {
1529 1529
 			$temp_array['direction_degree'] = $direction;
1530 1530
 			$temp_array['direction_shortname'] = "NE";
1531 1531
 			$temp_array['direction_fullname'] = "Northeast";
1532
-		} elseif ($direction >= 67.5 && $direction < 90){
1532
+		} elseif ($direction >= 67.5 && $direction < 90) {
1533 1533
 			$temp_array['direction_degree'] = $direction;
1534 1534
 			$temp_array['direction_shortname'] = "ENE";
1535 1535
 			$temp_array['direction_fullname'] = "East-Northeast";
1536
-		} elseif ($direction >= 90 && $direction < 112.5){
1536
+		} elseif ($direction >= 90 && $direction < 112.5) {
1537 1537
 			$temp_array['direction_degree'] = $direction;
1538 1538
 			$temp_array['direction_shortname'] = "E";
1539 1539
 			$temp_array['direction_fullname'] = "East";
1540
-		} elseif ($direction >= 112.5 && $direction < 135){
1540
+		} elseif ($direction >= 112.5 && $direction < 135) {
1541 1541
 			$temp_array['direction_degree'] = $direction;
1542 1542
 			$temp_array['direction_shortname'] = "ESE";
1543 1543
 			$temp_array['direction_fullname'] = "East-Southeast";
1544
-		} elseif ($direction >= 135 && $direction < 157.5){
1544
+		} elseif ($direction >= 135 && $direction < 157.5) {
1545 1545
 			$temp_array['direction_degree'] = $direction;
1546 1546
 			$temp_array['direction_shortname'] = "SE";
1547 1547
 			$temp_array['direction_fullname'] = "Southeast";
1548
-		} elseif ($direction >= 157.5 && $direction < 180){
1548
+		} elseif ($direction >= 157.5 && $direction < 180) {
1549 1549
 			$temp_array['direction_degree'] = $direction;
1550 1550
 			$temp_array['direction_shortname'] = "SSE";
1551 1551
 			$temp_array['direction_fullname'] = "South-Southeast";
1552
-		} elseif ($direction >= 180 && $direction < 202.5){
1552
+		} elseif ($direction >= 180 && $direction < 202.5) {
1553 1553
 			$temp_array['direction_degree'] = $direction;
1554 1554
 			$temp_array['direction_shortname'] = "S";
1555 1555
 			$temp_array['direction_fullname'] = "South";
1556
-		} elseif ($direction >= 202.5 && $direction < 225){
1556
+		} elseif ($direction >= 202.5 && $direction < 225) {
1557 1557
 			$temp_array['direction_degree'] = $direction;
1558 1558
 			$temp_array['direction_shortname'] = "SSW";
1559 1559
 			$temp_array['direction_fullname'] = "South-Southwest";
1560
-		} elseif ($direction >= 225 && $direction < 247.5){
1560
+		} elseif ($direction >= 225 && $direction < 247.5) {
1561 1561
 			$temp_array['direction_degree'] = $direction;
1562 1562
 			$temp_array['direction_shortname'] = "SW";
1563 1563
 			$temp_array['direction_fullname'] = "Southwest";
1564
-		} elseif ($direction >= 247.5 && $direction < 270){
1564
+		} elseif ($direction >= 247.5 && $direction < 270) {
1565 1565
 			$temp_array['direction_degree'] = $direction;
1566 1566
 			$temp_array['direction_shortname'] = "WSW";
1567 1567
 			$temp_array['direction_fullname'] = "West-Southwest";
1568
-		} elseif ($direction >= 270 && $direction < 292.5){
1568
+		} elseif ($direction >= 270 && $direction < 292.5) {
1569 1569
 			$temp_array['direction_degree'] = $direction;
1570 1570
 			$temp_array['direction_shortname'] = "W";
1571 1571
 			$temp_array['direction_fullname'] = "West";
1572
-		} elseif ($direction >= 292.5 && $direction < 315){
1572
+		} elseif ($direction >= 292.5 && $direction < 315) {
1573 1573
 			$temp_array['direction_degree'] = $direction;
1574 1574
 			$temp_array['direction_shortname'] = "WNW";
1575 1575
 			$temp_array['direction_fullname'] = "West-Northwest";
1576
-		} elseif ($direction >= 315 && $direction < 337.5){
1576
+		} elseif ($direction >= 315 && $direction < 337.5) {
1577 1577
 			$temp_array['direction_degree'] = $direction;
1578 1578
 			$temp_array['direction_shortname'] = "NW";
1579 1579
 			$temp_array['direction_fullname'] = "Northwest";
1580
-		} elseif ($direction >= 337.5 && $direction < 360){
1580
+		} elseif ($direction >= 337.5 && $direction < 360) {
1581 1581
 			$temp_array['direction_degree'] = $direction;
1582 1582
 			$temp_array['direction_shortname'] = "NNW";
1583 1583
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1594,11 +1594,11 @@  discard block
 block discarded – undo
1594 1594
 	* @param Float $longitude longitute of the flight
1595 1595
 	* @return String the countrie
1596 1596
 	*/
1597
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1597
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1598 1598
 	{
1599 1599
 		global $globalDBdriver, $globalDebug;
1600
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1601
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1600
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1601
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1602 1602
 	
1603 1603
 		$Connection = new Connection($this->db);
1604 1604
 		if (!$Connection->tableExists('countries')) return '';
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
 	public function getCountryFromISO2($iso2)
1639 1639
 	{
1640 1640
 		global $globalDBdriver, $globalDebug;
1641
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1641
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1642 1642
 	
1643 1643
 		$Connection = new Connection($this->db);
1644 1644
 		if (!$Connection->tableExists('countries')) return '';
@@ -1686,7 +1686,7 @@  discard block
 block discarded – undo
1686 1686
 		
1687 1687
 		$bitly_data = json_decode($bitly_data);
1688 1688
 		$bitly_url = '';
1689
-		if ($bitly_data->status_txt = "OK"){
1689
+		if ($bitly_data->status_txt = "OK") {
1690 1690
 			$bitly_url = $bitly_data->data->url;
1691 1691
 		}
1692 1692
 
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 
1697 1697
 	public function getOrderBy()
1698 1698
 	{
1699
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1699
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1700 1700
 		
1701 1701
 		return $orderby;
1702 1702
 		
Please login to merge, or discard this patch.
Braces   +162 added lines, -58 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
69 71
 			}
70 72
 		}
71
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73
+		if ($filter_query_where == '' && $where) {
74
+			$filter_query_where = ' WHERE';
75
+		} elseif ($filter_query_where != '' && $and) {
76
+			$filter_query_where .= ' AND';
77
+		}
73 78
 		if ($filter_query_where != '') {
74 79
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75 80
 		}
@@ -123,32 +128,54 @@  discard block
 block discarded – undo
123 128
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
124 129
 			} elseif (isset($row['spotter_archive_output_id'])) {
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
126
-			*/} 
127
-			elseif (isset($row['marineid'])) {
131
+			*/} elseif (isset($row['marineid'])) {
128 132
 				$temp_array['marine_id'] = $row['marineid'];
129 133
 			} else {
130 134
 				$temp_array['marine_id'] = '';
131 135
 			}
132
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
133
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
134
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
135
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
136
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
137
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
138
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
139
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
136
+			if (isset($row['fammarine_id'])) {
137
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
138
+			}
139
+			if (isset($row['mmsi'])) {
140
+				$temp_array['mmsi'] = $row['mmsi'];
141
+			}
142
+			if (isset($row['type'])) {
143
+				$temp_array['type'] = $row['type'];
144
+			}
145
+			if (isset($row['type_id'])) {
146
+				$temp_array['type_id'] = $row['type_id'];
147
+			}
148
+			if (isset($row['ident'])) {
149
+				$temp_array['ident'] = $row['ident'];
150
+			}
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
140 160
 			if (isset($row['heading'])) {
141 161
 				$temp_array['heading'] = $row['heading'];
142 162
 				$heading_direction = $this->parseDirection($row['heading']);
143
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
163
+				if (isset($heading_direction[0]['direction_fullname'])) {
164
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
165
+				}
166
+			}
167
+			if (isset($row['ground_speed'])) {
168
+				$temp_array['ground_speed'] = $row['ground_speed'];
144 169
 			}
145
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 170
 
147 171
 			if($temp_array['mmsi'] != "")
148 172
 			{
149 173
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
151
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
174
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
175
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
176
+				} else {
177
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
178
+				}
152 179
 				unset($Image);
153 180
 				if (count($image_array) > 0) {
154 181
 					$temp_array['image'] = $image_array[0]['image'];
@@ -200,13 +227,21 @@  discard block
 block discarded – undo
200 227
 			}
201 228
 			
202 229
 			$fromsource = NULL;
203
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
204
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
205
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
230
+			if (isset($row['source_name']) && $row['source_name'] != '') {
231
+				$temp_array['source_name'] = $row['source_name'];
232
+			}
233
+			if (isset($row['over_country']) && $row['over_country'] != '') {
234
+				$temp_array['over_country'] = $row['over_country'];
235
+			}
236
+			if (isset($row['distance']) && $row['distance'] != '') {
237
+				$temp_array['distance'] = $row['distance'];
238
+			}
206 239
 			$temp_array['query_number_rows'] = $num_rows;
207 240
 			$spotter_array[] = $temp_array;
208 241
 		}
209
-		if ($num_rows == 0) return array();
242
+		if ($num_rows == 0) {
243
+			return array();
244
+		}
210 245
 		$spotter_array[0]['query_number_rows'] = $num_rows;
211 246
 		return $spotter_array;
212 247
 	}	
@@ -232,8 +267,12 @@  discard block
 block discarded – undo
232 267
 			{
233 268
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
234 269
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
235
-			} else $limit_query = "";
236
-		} else $limit_query = "";
270
+			} else {
271
+				$limit_query = "";
272
+			}
273
+		} else {
274
+			$limit_query = "";
275
+		}
237 276
 		if ($sort != "")
238 277
 		{
239 278
 			$search_orderby_array = $this->getOrderBy();
@@ -257,7 +296,9 @@  discard block
 block discarded – undo
257 296
 		global $global_query;
258 297
 		
259 298
 		date_default_timezone_set('UTC');
260
-		if ($id == '') return array();
299
+		if ($id == '') {
300
+			return array();
301
+		}
261 302
 		$additional_query = "marine_output.fammarine_id = :id";
262 303
 		$query_values = array(':id' => $id);
263 304
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -400,8 +441,11 @@  discard block
 block discarded – undo
400 441
 		$query .= " ORDER BY marine_output.source_name ASC";
401 442
 
402 443
 		$sth = $this->db->prepare($query);
403
-		if (!empty($query_values)) $sth->execute($query_values);
404
-		else $sth->execute();
444
+		if (!empty($query_values)) {
445
+			$sth->execute($query_values);
446
+		} else {
447
+			$sth->execute();
448
+		}
405 449
 
406 450
 		$source_array = array();
407 451
 		$temp_array = array();
@@ -456,8 +500,11 @@  discard block
 block discarded – undo
456 500
 		$sth = $this->db->prepare($query);
457 501
 		$sth->execute(array(':mmsi' => $mmsi));
458 502
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
459
-		if (isset($result[0])) return $result[0];
460
-		else return array();
503
+		if (isset($result[0])) {
504
+			return $result[0];
505
+		} else {
506
+			return array();
507
+		}
461 508
 	}
462 509
 
463 510
 	/*
@@ -473,7 +520,9 @@  discard block
 block discarded – undo
473 520
 			date_default_timezone_set($globalTimezone);
474 521
 			$datetime = new DateTime();
475 522
 			$offset = $datetime->format('P');
476
-		} else $offset = '+00:00';
523
+		} else {
524
+			$offset = '+00:00';
525
+		}
477 526
 
478 527
 		if ($globalDBdriver == 'mysql') {
479 528
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -703,9 +752,15 @@  discard block
 block discarded – undo
703 752
             		$latitude = 0;
704 753
             		$longitude = 0;
705 754
             	}
706
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
-                if ($arrival_date == '') $arrival_date = NULL;
755
+                if ($heading == '' || $Common->isInteger($heading) === false) {
756
+                	$heading = 0;
757
+                }
758
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
759
+                	$groundspeed = 0;
760
+                }
761
+                if ($arrival_date == '') {
762
+                	$arrival_date = NULL;
763
+                }
709 764
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 765
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 766
 
@@ -813,7 +868,9 @@  discard block
 block discarded – undo
813 868
 		global $globalDBdriver, $globalArchive;
814 869
 		//$filter_query = $this->getFilter($filters,true,true);
815 870
 		$Connection= new Connection($this->db);
816
-		if (!$Connection->tableExists('countries')) return array();
871
+		if (!$Connection->tableExists('countries')) {
872
+			return array();
873
+		}
817 874
 		require_once('class.SpotterLive.php');
818 875
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 876
 			$MarineLive = new MarineLive();
@@ -855,7 +912,9 @@  discard block
 block discarded – undo
855 912
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
856 913
 		}
857 914
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
858
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
915
+		if ($limit) {
916
+			$query .= " LIMIT 10 OFFSET 0";
917
+		}
859 918
       
860 919
 		
861 920
 		$sth = $this->db->prepare($query);
@@ -890,12 +949,18 @@  discard block
 block discarded – undo
890 949
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
891 950
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
892 951
 		 if ($olderthanmonths > 0) {
893
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
894
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
952
+			if ($globalDBdriver == 'mysql') {
953
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
954
+			} else {
955
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
956
+			}
895 957
 		}
896 958
 		if ($sincedate != '') {
897
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
898
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
959
+			if ($globalDBdriver == 'mysql') {
960
+				$query .= " AND marine_output.date > '".$sincedate."'";
961
+			} else {
962
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
963
+			}
899 964
 		}
900 965
 		$query_values = array();
901 966
 		if ($year != '') {
@@ -926,7 +991,9 @@  discard block
 block discarded – undo
926 991
 			}
927 992
 		}
928 993
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
929
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
994
+		if ($limit) {
995
+			$query .= " LIMIT 10 OFFSET 0";
996
+		}
930 997
       		
931 998
 		$sth = $this->db->prepare($query);
932 999
 		$sth->execute($query_values);
@@ -961,7 +1028,9 @@  discard block
 block discarded – undo
961 1028
 			date_default_timezone_set($globalTimezone);
962 1029
 			$datetime = new DateTime();
963 1030
 			$offset = $datetime->format('P');
964
-		} else $offset = '+00:00';
1031
+		} else {
1032
+			$offset = '+00:00';
1033
+		}
965 1034
 
966 1035
 		if ($globalDBdriver == 'mysql') {
967 1036
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1011,7 +1080,9 @@  discard block
 block discarded – undo
1011 1080
 			date_default_timezone_set($globalTimezone);
1012 1081
 			$datetime = new DateTime();
1013 1082
 			$offset = $datetime->format('P');
1014
-		} else $offset = '+00:00';
1083
+		} else {
1084
+			$offset = '+00:00';
1085
+		}
1015 1086
 		$filter_query = $this->getFilter($filters,true,true);
1016 1087
 		if ($globalDBdriver == 'mysql') {
1017 1088
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1057,7 +1128,9 @@  discard block
 block discarded – undo
1057 1128
 			date_default_timezone_set($globalTimezone);
1058 1129
 			$datetime = new DateTime();
1059 1130
 			$offset = $datetime->format('P');
1060
-		} else $offset = '+00:00';
1131
+		} else {
1132
+			$offset = '+00:00';
1133
+		}
1061 1134
 		$filter_query = $this->getFilter($filters,true,true);
1062 1135
 		if ($globalDBdriver == 'mysql') {
1063 1136
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1105,7 +1178,9 @@  discard block
 block discarded – undo
1105 1178
 			date_default_timezone_set($globalTimezone);
1106 1179
 			$datetime = new DateTime();
1107 1180
 			$offset = $datetime->format('P');
1108
-		} else $offset = '+00:00';
1181
+		} else {
1182
+			$offset = '+00:00';
1183
+		}
1109 1184
 
1110 1185
 		if ($globalDBdriver == 'mysql') {
1111 1186
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1154,7 +1229,9 @@  discard block
 block discarded – undo
1154 1229
 			date_default_timezone_set($globalTimezone);
1155 1230
 			$datetime = new DateTime();
1156 1231
 			$offset = $datetime->format('P');
1157
-		} else $offset = '+00:00';
1232
+		} else {
1233
+			$offset = '+00:00';
1234
+		}
1158 1235
 		$filter_query = $this->getFilter($filters,true,true);
1159 1236
 		if ($globalDBdriver == 'mysql') {
1160 1237
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1203,7 +1280,9 @@  discard block
 block discarded – undo
1203 1280
 			date_default_timezone_set($globalTimezone);
1204 1281
 			$datetime = new DateTime();
1205 1282
 			$offset = $datetime->format('P');
1206
-		} else $offset = '+00:00';
1283
+		} else {
1284
+			$offset = '+00:00';
1285
+		}
1207 1286
 
1208 1287
 		$orderby_sql = '';
1209 1288
 		if ($orderby == "hour")
@@ -1272,7 +1351,9 @@  discard block
 block discarded – undo
1272 1351
 			date_default_timezone_set($globalTimezone);
1273 1352
 			$datetime = new DateTime($date);
1274 1353
 			$offset = $datetime->format('P');
1275
-		} else $offset = '+00:00';
1354
+		} else {
1355
+			$offset = '+00:00';
1356
+		}
1276 1357
 
1277 1358
 		if ($globalDBdriver == 'mysql') {
1278 1359
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1320,7 +1401,9 @@  discard block
 block discarded – undo
1320 1401
 			date_default_timezone_set($globalTimezone);
1321 1402
 			$datetime = new DateTime();
1322 1403
 			$offset = $datetime->format('P');
1323
-		} else $offset = '+00:00';
1404
+		} else {
1405
+			$offset = '+00:00';
1406
+		}
1324 1407
 
1325 1408
 		if ($globalDBdriver == 'mysql') {
1326 1409
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1385,8 +1468,11 @@  discard block
 block discarded – undo
1385 1468
 				$query_values = array_merge($query_values,array(':month' => $month));
1386 1469
 			}
1387 1470
 		}
1388
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1389
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1471
+		if (empty($query_values)) {
1472
+			$queryi .= $this->getFilter($filters);
1473
+		} else {
1474
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1475
+		}
1390 1476
 		
1391 1477
 		$sth = $this->db->prepare($queryi);
1392 1478
 		$sth->execute($query_values);
@@ -1408,7 +1494,9 @@  discard block
 block discarded – undo
1408 1494
 			date_default_timezone_set($globalTimezone);
1409 1495
 			$datetime = new DateTime();
1410 1496
 			$offset = $datetime->format('P');
1411
-		} else $offset = '+00:00';
1497
+		} else {
1498
+			$offset = '+00:00';
1499
+		}
1412 1500
 
1413 1501
 		if ($globalDBdriver == 'mysql') {
1414 1502
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1512,7 +1600,9 @@  discard block
 block discarded – undo
1512 1600
 	*/
1513 1601
 	public function parseDirection($direction = 0)
1514 1602
 	{
1515
-		if ($direction == '') $direction = 0;
1603
+		if ($direction == '') {
1604
+			$direction = 0;
1605
+		}
1516 1606
 		$direction_array = array();
1517 1607
 		$temp_array = array();
1518 1608
 
@@ -1601,7 +1691,9 @@  discard block
 block discarded – undo
1601 1691
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1602 1692
 	
1603 1693
 		$Connection = new Connection($this->db);
1604
-		if (!$Connection->tableExists('countries')) return '';
1694
+		if (!$Connection->tableExists('countries')) {
1695
+			return '';
1696
+		}
1605 1697
 	
1606 1698
 		try {
1607 1699
 			/*
@@ -1621,9 +1713,13 @@  discard block
 block discarded – undo
1621 1713
 			$sth->closeCursor();
1622 1714
 			if (count($row) > 0) {
1623 1715
 				return $row;
1624
-			} else return '';
1716
+			} else {
1717
+				return '';
1718
+			}
1625 1719
 		} catch (PDOException $e) {
1626
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1720
+			if (isset($globalDebug) && $globalDebug) {
1721
+				echo 'Error : '.$e->getMessage()."\n";
1722
+			}
1627 1723
 			return '';
1628 1724
 		}
1629 1725
 	
@@ -1641,7 +1737,9 @@  discard block
 block discarded – undo
1641 1737
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1642 1738
 	
1643 1739
 		$Connection = new Connection($this->db);
1644
-		if (!$Connection->tableExists('countries')) return '';
1740
+		if (!$Connection->tableExists('countries')) {
1741
+			return '';
1742
+		}
1645 1743
 	
1646 1744
 		try {
1647 1745
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1653,9 +1751,13 @@  discard block
 block discarded – undo
1653 1751
 			$sth->closeCursor();
1654 1752
 			if (count($row) > 0) {
1655 1753
 				return $row;
1656
-			} else return '';
1754
+			} else {
1755
+				return '';
1756
+			}
1657 1757
 		} catch (PDOException $e) {
1658
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1758
+			if (isset($globalDebug) && $globalDebug) {
1759
+				echo 'Error : '.$e->getMessage()."\n";
1760
+			}
1659 1761
 			return '';
1660 1762
 		}
1661 1763
 	
@@ -1673,7 +1775,9 @@  discard block
 block discarded – undo
1673 1775
 	{
1674 1776
 		global $globalBitlyAccessToken;
1675 1777
 		
1676
-		if ($globalBitlyAccessToken == '') return $url;
1778
+		if ($globalBitlyAccessToken == '') {
1779
+			return $url;
1780
+		}
1677 1781
         
1678 1782
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1679 1783
 		
Please login to merge, or discard this patch.
statistics.php 3 patches
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -63,35 +63,35 @@  discard block
 block discarded – undo
63 63
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
64 64
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
65 65
 	}
66
-    ?>
66
+	?>
67 67
     </div>
68 68
     <?php include('statistics-sub-menu.php'); ?>
69 69
     <p class="global-stats">
70 70
 <?php
71
-    if ($type == 'aircraft') {
71
+	if ($type == 'aircraft') {
72 72
 ?>
73 73
         <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
74 74
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
75 75
         <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
76 76
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
77 77
 	<?php
78
-	    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
78
+		if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
79 79
 	?>
80 80
     	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
81 81
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
82 82
         <?php
83
-    	    } else {
84
-    	?>
83
+			} else {
84
+		?>
85 85
     	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
86 86
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
87 87
     	<?php
88
-    	    }
89
-    	?>
88
+			}
89
+		?>
90 90
         <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
91 91
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
92 92
         <?php
93
-    		if ($airline_icao == '') {
94
-    	?>
93
+			if ($airline_icao == '') {
94
+		?>
95 95
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
96 96
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
97 97
 	<?php
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 	?>
110 110
 <?php
111
-    } elseif ($type == 'marine') {
111
+	} elseif ($type == 'marine') {
112 112
 ?>
113 113
 	<span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
114 114
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
115 115
 <?php
116
-    } elseif ($type == 'tracker') {
116
+	} elseif ($type == 'tracker') {
117 117
 ?>
118 118
 	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
119 119
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
120 120
 <?php
121
-    }
121
+	}
122 122
 ?>
123 123
     </p>
124 124
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -127,88 +127,88 @@  discard block
 block discarded – undo
127 127
             <div class="col-md-6">
128 128
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
129 129
                  <?php
130
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
131
-		    if (count($aircraft_array) == 0) print _("No data available");
132
-		    else {
133
-                    print '<div id="chart1" class="chart" width="100%"></div><script>';
134
-                    $aircraft_data = '';
135
-                    foreach($aircraft_array as $aircraft_item)
136
-                    {
137
-                        $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
138
-                    }
139
-                    $aircraft_data = substr($aircraft_data, 0, -1);
140
-		    print 'var series = ['.$aircraft_data.'];';
141
-		    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
142
-		    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
143
-		    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
144
-                    print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
145
-                    print 'dataset';
146
-                    print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
147
-                    print '</script>';
148
-                  }
149
-                  ?>
130
+				  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
131
+			if (count($aircraft_array) == 0) print _("No data available");
132
+			else {
133
+					print '<div id="chart1" class="chart" width="100%"></div><script>';
134
+					$aircraft_data = '';
135
+					foreach($aircraft_array as $aircraft_item)
136
+					{
137
+						$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
138
+					}
139
+					$aircraft_data = substr($aircraft_data, 0, -1);
140
+			print 'var series = ['.$aircraft_data.'];';
141
+			print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
142
+			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
143
+			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
144
+					print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
145
+					print 'dataset';
146
+					print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
147
+					print '</script>';
148
+				  }
149
+				  ?>
150 150
                 <div class="more">
151 151
             	    <?php
152
-            		if ($year != '' && $month != '') {
153
-            	    ?>
152
+					if ($year != '' && $month != '') {
153
+					?>
154 154
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
155 155
             	    <?php
156
-            		} else {
157
-            	    ?>
156
+					} else {
157
+					?>
158 158
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
159 159
             	    <?php
160
-            		}
161
-            	    ?>
160
+					}
161
+					?>
162 162
                 </div>
163 163
             </div>
164 164
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
165 165
 <?php
166 166
 //    echo $airline_icao;
167
-    if ($airline_icao == '' || $airline_icao == 'all') {
167
+	if ($airline_icao == '' || $airline_icao == 'all') {
168 168
 	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
169 169
 	if (count($airline_array) > 0) {
170
-            print '<div class="col-md-6">';
171
-	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
172
-	    print '<div id="chart2" class="chart" width="100%"></div><script>';
173
-	    $airline_data = '';
174
-	    foreach($airline_array as $airline_item)
175
-	    {
170
+			print '<div class="col-md-6">';
171
+		print '<h2>'._("Top 10 Most Common Airline").'</h2>';
172
+		print '<div id="chart2" class="chart" width="100%"></div><script>';
173
+		$airline_data = '';
174
+		foreach($airline_array as $airline_item)
175
+		{
176 176
 		$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
177
-	    }
178
-	    $airline_data = substr($airline_data, 0, -1);
179
-	    print 'var series = ['.$airline_data.'];';
180
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
181
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
182
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
183
-            print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
184
-	    print 'dataset';
185
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
186
-            print '</script>';
187
-	    if ($year != '' && $month != '') {
177
+		}
178
+		$airline_data = substr($airline_data, 0, -1);
179
+		print 'var series = ['.$airline_data.'];';
180
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
181
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
182
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
183
+			print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
184
+		print 'dataset';
185
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
186
+			print '</script>';
187
+		if ($year != '' && $month != '') {
188 188
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189 189
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
190 190
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191
-	    } else {
191
+		} else {
192 192
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
193 193
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
194 194
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
195
-	    }
196
-    	    print '</div>';
195
+		}
196
+			print '</div>';
197 197
 	}
198 198
 ?>
199 199
         </div>
200 200
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
201 201
 <?php
202
-    }
202
+	}
203 203
 ?>
204 204
         <div class="row column">
205 205
 <?php
206
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
207
-    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
206
+	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
207
+	if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
208 208
 	if (empty($flightover_array)) {
209
-	    print '<div class="col-md-12">';
209
+		print '<div class="col-md-12">';
210 210
 	} else {
211
-            print '<div class="col-md-6">';
211
+			print '<div class="col-md-6">';
212 212
 	}
213 213
 ?>
214 214
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
@@ -216,23 +216,23 @@  discard block
 block discarded – undo
216 216
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
217 217
 	if (count($pilot_array) == 0) print _("No data available");
218 218
 	else {
219
-	    print '<div id="chart7" class="chart" width="100%"></div><script>';
220
-	    $pilot_data = '';
221
-	    foreach($pilot_array as $pilot_item)
222
-	    {
219
+		print '<div id="chart7" class="chart" width="100%"></div><script>';
220
+		$pilot_data = '';
221
+		foreach($pilot_array as $pilot_item)
222
+		{
223 223
 		$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
224
-	    }
225
-	    $pilot_data = substr($pilot_data, 0, -1);
226
-	    print 'var series = ['.$pilot_data.'];';
227
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
228
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
229
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
230
-            print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
231
-	    print 'dataset';
232
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
233
-            print '</script>';
234
-        }
235
-        print '<div class="more">';
224
+		}
225
+		$pilot_data = substr($pilot_data, 0, -1);
226
+		print 'var series = ['.$pilot_data.'];';
227
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
228
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
229
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
230
+			print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
231
+		print 'dataset';
232
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
233
+			print '</script>';
234
+		}
235
+		print '<div class="more">';
236 236
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
237 237
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
238 238
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
         
243 243
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
244 244
 <?php
245
-    } else {
245
+	} else {
246 246
 ?>
247 247
             <div class="col-md-6">
248 248
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
@@ -250,21 +250,21 @@  discard block
 block discarded – undo
250 250
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
251 251
 	if (count($owner_array) == 0) print _("No data available");
252 252
 	else {
253
-	    print '<div id="chart7" class="chart" width="100%"></div><script>';
254
-	    $owner_data = '';
255
-	    foreach($owner_array as $owner_item)
256
-	    {
253
+		print '<div id="chart7" class="chart" width="100%"></div><script>';
254
+		$owner_data = '';
255
+		foreach($owner_array as $owner_item)
256
+		{
257 257
 		$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
258
-	    }
259
-	    $owner_data = substr($owner_data, 0, -1);
260
-	    print 'var series = ['.$owner_data.'];';
261
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
262
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
263
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
264
-            print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
265
-	    print 'dataset';
266
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
267
-	    print '</script>';
258
+		}
259
+		$owner_data = substr($owner_data, 0, -1);
260
+		print 'var series = ['.$owner_data.'];';
261
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
262
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
263
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
264
+			print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
265
+		print 'dataset';
266
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
267
+		print '</script>';
268 268
 	}
269 269
 ?>
270 270
                 <div class="more">
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
         
275 275
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
276 276
 <?php
277
-    }
278
-    if (!empty($flightover_array)) {
277
+	}
278
+	if (!empty($flightover_array)) {
279 279
 ?>
280 280
             <div class="col-md-6">
281 281
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
@@ -283,20 +283,20 @@  discard block
 block discarded – undo
283 283
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
284 284
 	if (count($flightover_array) == 0) print _("No data available");
285 285
 	else {
286
-	    print '<div id="chart10" class="chart" width="100%"></div><script>';
287
-	    print 'var series = [';
288
-            $flightover_data = '';
289
-	    foreach($flightover_array as $flightover_item)
290
-	    {
286
+		print '<div id="chart10" class="chart" width="100%"></div><script>';
287
+		print 'var series = [';
288
+			$flightover_data = '';
289
+		foreach($flightover_array as $flightover_item)
290
+		{
291 291
 		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
292
-	    }
293
-	    $flightover_data = substr($flightover_data, 0, -1);
294
-	    print $flightover_data;
295
-	    print '];';
296
-	    print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
297
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
298
-	    print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
299
-	    print 'new Datamap({
292
+		}
293
+		$flightover_data = substr($flightover_data, 0, -1);
294
+		print $flightover_data;
295
+		print '];';
296
+		print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
297
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
298
+		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
299
+		print 'new Datamap({
300 300
 		element: document.getElementById("chart10"),
301 301
 		projection: "mercator", // big world map
302 302
 		fills: { defaultFill: "#F5F5F5" },
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
         	    }
322 322
 		}
323 323
 	    });";
324
-	    print '</script>';
324
+		print '</script>';
325 325
 	}
326 326
 ?>
327 327
                 <div class="more">
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                 </div>
330 330
             </div>
331 331
 <?php
332
-    }
332
+	}
333 333
 ?>
334 334
         </div>
335 335
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
         <div class="row column">
340 340
             <div class="col-md-6">
341 341
 <?php
342
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
343
-    if (count($airport_airport_array) > 0) {
342
+	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
343
+	if (count($airport_airport_array) > 0) {
344 344
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
345 345
 	print '<div id="chart3" class="chart" width="100%"></div><script>';
346
-        print "\n";
347
-        print 'var series = [';
348
-        $airport_data = '';
346
+		print "\n";
347
+		print 'var series = [';
348
+		$airport_data = '';
349 349
 	foreach($airport_airport_array as $airport_item)
350 350
 	{
351 351
 		$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
@@ -394,20 +394,20 @@  discard block
 block discarded – undo
394 394
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
395 395
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
396 396
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
397
-    }
397
+	}
398 398
 ?>
399 399
             </div>
400 400
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
401 401
 
402 402
             <div class="col-md-6">
403 403
 <?php
404
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
405
-    if (count($airport_airport_array2) > 0) {
404
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
405
+	if (count($airport_airport_array2) > 0) {
406 406
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
407 407
 	print '<div id="chart4" class="chart" width="100%"></div><script>';
408
-        print "\n";
409
-        print 'var series = [';
410
-        $airport_data = '';
408
+		print "\n";
409
+		print 'var series = [';
410
+		$airport_data = '';
411 411
 	foreach($airport_airport_array2 as $airport_item)
412 412
 	{
413 413
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
@@ -457,28 +457,28 @@  discard block
 block discarded – undo
457 457
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
458 458
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
459 459
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
460
-    }
460
+	}
461 461
 ?>
462 462
             </div>
463 463
         </div>
464 464
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
465 465
 <?php
466
-    if ($year == '' && $month == '') {
466
+	if ($year == '' && $month == '') {
467 467
 ?>
468 468
         <div class="row column">
469 469
             <div class="col-md-6">
470 470
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
471 471
                 <?php
472
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
473
-		    if (count($year_array) == 0) print _("No data available");
474
-		    else {
472
+				  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
473
+			if (count($year_array) == 0) print _("No data available");
474
+			else {
475 475
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
476 476
 			$year_data = '';
477 477
 			$year_cnt = '';
478 478
 			foreach($year_array as $year_item)
479 479
 			{
480
-			    $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
481
-			    $year_cnt .= $year_item['date_count'].',';
480
+				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
481
+				$year_cnt .= $year_item['date_count'].',';
482 482
 			}
483 483
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
484 484
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
                 	     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
489 489
                 	     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
490 490
 			print '</script>';
491
-                    }
492
-                  ?>
491
+					}
492
+				  ?>
493 493
                 <div class="more">
494 494
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
495 495
                 </div>
@@ -498,16 +498,16 @@  discard block
 block discarded – undo
498 498
             <div class="col-md-6">
499 499
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
500 500
                 <?php
501
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
502
-		    if (count($month_array) == 0) print _("No data available");
503
-		    else {
504
-                	print '<div id="chart9" class="chart" width="100%"></div><script>';
505
-                        $month_data = '';
501
+				  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
502
+			if (count($month_array) == 0) print _("No data available");
503
+			else {
504
+					print '<div id="chart9" class="chart" width="100%"></div><script>';
505
+						$month_data = '';
506 506
 			$month_cnt = '';
507 507
 			foreach($month_array as $month_item)
508 508
 			{
509
-			    $month_data .= '"'.$month_item['date_name'].'",';
510
-			    $month_cnt .= $month_item['date_count'].',';
509
+				$month_data .= '"'.$month_item['date_name'].'",';
510
+				$month_cnt .= $month_item['date_count'].',';
511 511
 			}
512 512
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
513 513
 			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
                 	     columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
518 518
                 	     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
519 519
 			
520
-            		print '</script>';
521
-                    }
522
-                  ?>
520
+					print '</script>';
521
+					}
522
+				  ?>
523 523
                 <div class="more">
524 524
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
525 525
                 </div>
@@ -529,16 +529,16 @@  discard block
 block discarded – undo
529 529
             <div class="col-md-6">
530 530
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
531 531
                 <?php
532
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
533
-		    if (empty($date_array)) print _("No data available");
534
-		    else {
535
-                	print '<div id="chart5" class="chart" width="100%"></div><script>';
536
-                        $date_data = '';
532
+					$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
533
+			if (empty($date_array)) print _("No data available");
534
+			else {
535
+					print '<div id="chart5" class="chart" width="100%"></div><script>';
536
+						$date_data = '';
537 537
 			$date_cnt = '';
538 538
 			foreach($date_array as $date_item)
539 539
 			{
540
-			    $date_data .= '"'.$date_item['date_name'].'",';
541
-			    $date_cnt .= $date_item['date_count'].',';
540
+				$date_data .= '"'.$date_item['date_name'].'",';
541
+				$date_cnt .= $date_item['date_count'].',';
542 542
 			}
543 543
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
544 544
 			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
                 	     columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
549 549
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
550 550
 			
551
-                	print '</script>';
552
-                    }
553
-                  ?>
551
+					print '</script>';
552
+					}
553
+				  ?>
554 554
                 <div class="more">
555 555
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
556 556
                 </div>
@@ -559,16 +559,16 @@  discard block
 block discarded – undo
559 559
             <div class="col-md-6">
560 560
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
561 561
                 <?php
562
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
563
-		    if (empty($hour_array)) print _("No data available");
564
-		    else {
565
-                	print '<div id="chart6" class="chart" width="100%"></div><script>';
566
-                        $hour_data = '';
562
+				  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
563
+			if (empty($hour_array)) print _("No data available");
564
+			else {
565
+					print '<div id="chart6" class="chart" width="100%"></div><script>';
566
+						$hour_data = '';
567 567
 			$hour_cnt = '';
568 568
 			foreach($hour_array as $hour_item)
569 569
 			{
570
-			    $hour_data .= '"'.$hour_item['hour_name'].':00",';
571
-			    $hour_cnt .= $hour_item['hour_count'].',';
570
+				$hour_data .= '"'.$hour_item['hour_name'].':00",';
571
+				$hour_cnt .= $hour_item['hour_count'].',';
572 572
 			}
573 573
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
574 574
 			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
                 	     columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
579 579
                 	     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
580 580
 
581
-            	     print '</script>';
582
-                  }
583
-                ?>
581
+					 print '</script>';
582
+				  }
583
+				?>
584 584
                 <div class="more">
585 585
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
586 586
                 </div>
@@ -588,26 +588,26 @@  discard block
 block discarded – undo
588 588
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
589 589
         </div>
590 590
 <?php
591
-    }
591
+	}
592 592
 ?>
593 593
 
594 594
 <?php
595
-    if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
595
+	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
596 596
 ?>
597 597
         <div class="row column">
598 598
             <div class="col-md-6">
599 599
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
600 600
                 <?php
601
-                  $year_array = $Stats->countFatalitiesByYear();
602
-		    if (count($year_array) == 0) print _("No data available");
603
-		    else {
601
+				  $year_array = $Stats->countFatalitiesByYear();
602
+			if (count($year_array) == 0) print _("No data available");
603
+			else {
604 604
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
605
-                        $year_data = '';
605
+						$year_data = '';
606 606
 			$year_cnt = '';
607 607
 			foreach($year_array as $year_item)
608 608
 			{
609
-			    $year_data .= '"'.$year_item['year'].'-01-01",';
610
-			    $year_cnt .= $year_item['count'].',';
609
+				$year_data .= '"'.$year_item['year'].'-01-01",';
610
+				$year_cnt .= $year_item['count'].',';
611 611
 			}
612 612
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
613 613
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -618,8 +618,8 @@  discard block
 block discarded – undo
618 618
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
619 619
 
620 620
 			print '</script>';
621
-		    }
622
-                  ?>
621
+			}
622
+				  ?>
623 623
                 <div class="more">
624 624
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
625 625
                 </div>
@@ -630,16 +630,16 @@  discard block
 block discarded – undo
630 630
             <div class="col-md-6">
631 631
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
632 632
                 <?php
633
-                  $year_array = $Stats->countFatalitiesLast12Months();
634
-		    if (count($year_array) == 0) print _("No data available");
635
-		    else {
633
+				  $year_array = $Stats->countFatalitiesLast12Months();
634
+			if (count($year_array) == 0) print _("No data available");
635
+			else {
636 636
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
637
-                        $year_data = '';
637
+						$year_data = '';
638 638
 			$year_cnt = '';
639 639
 			foreach($year_array as $year_item)
640 640
 			{
641
-			    $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
642
-			    $year_cnt .= $year_item['count'].',';
641
+				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
642
+				$year_cnt .= $year_item['count'].',';
643 643
 			}
644 644
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
645 645
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
                 	     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
650 650
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
651 651
 			print '</script>';
652
-		    }
653
-                  ?>
652
+			}
653
+				  ?>
654 654
                 <div class="more">
655 655
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
656 656
                 </div>
@@ -658,30 +658,30 @@  discard block
 block discarded – undo
658 658
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
659 659
 <br/>
660 660
 <?php
661
-    }
661
+	}
662 662
 ?>
663 663
 
664 664
 <?php
665
-    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
665
+	if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
666 666
 ?>
667 667
         <div class="row column">
668 668
         	<?php
669
-        	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
670
-        	    if ($year == '' && $month == '') {
671
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
672
-		    } else {
673
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
674
-        	    }
675
-        	    if (!empty($polar)) {
676
-            		print '<h2>'._("Coverage pattern").'</h2>';
677
-        		foreach ($polar as $eachpolar) {
678
-        		    unset($polar_data);
679
-	        	    $Spotter = new Spotter();
680
-        		    $data = json_decode($eachpolar['source_data']);
681
-        		    foreach($data as $value => $key) {
682
-        			$direction = $Spotter->parseDirection(($value*22.5));
683
-        			$distance = $key;
684
-        			$unit = 'km';
669
+				//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
670
+				if ($year == '' && $month == '') {
671
+				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
672
+			} else {
673
+				$polar = $Stats->getStatsSource('polar',$year,$month);
674
+				}
675
+				if (!empty($polar)) {
676
+					print '<h2>'._("Coverage pattern").'</h2>';
677
+				foreach ($polar as $eachpolar) {
678
+					unset($polar_data);
679
+					$Spotter = new Spotter();
680
+					$data = json_decode($eachpolar['source_data']);
681
+					foreach($data as $value => $key) {
682
+					$direction = $Spotter->parseDirection(($value*22.5));
683
+					$distance = $key;
684
+					$unit = 'km';
685 685
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
686 686
 					$distance = round($distance*0.539957);
687 687
 					$unit = 'nm';
@@ -692,10 +692,10 @@  discard block
 block discarded – undo
692 692
 					$distance = $distance;
693 693
 					$unit = 'km';
694 694
 				}
695
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
696
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
697
-        		    }
698
-        	?>
695
+					if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
696
+						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
697
+					}
698
+			?>
699 699
             <div class="col-md-6">
700 700
                 <h4><?php print $eachpolar['source_name']; ?></h4>
701 701
         	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
@@ -727,27 +727,27 @@  discard block
 block discarded – undo
727 727
 		</script>
728 728
             </div>
729 729
             <?php
730
-        	    }
731
-        	}
732
-            ?>
730
+				}
731
+			}
732
+			?>
733 733
         </div>
734 734
         <div class="row column">
735 735
             <div class="col-md-6">
736 736
         	<?php
737
-        	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
738
-        	    if ($year == '' && $month == '') {
739
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
740
-        	    } else {
741
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
742
-        	    }
743
-        	    if (!empty($msg)) {
744
-            		print '<h2>'._("Messages received").'</h2>';
745
-        		foreach ($msg as $eachmsg) {
746
-        		    //$eachmsg = $msg[0];
747
-        		    $data = $eachmsg['source_data'];
748
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
749
-        		    else $max = 500;
750
-        	?>
737
+				//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
738
+				if ($year == '' && $month == '') {
739
+				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
740
+				} else {
741
+				$msg = $Stats->getStatsSource('msg',$year,$month);
742
+				}
743
+				if (!empty($msg)) {
744
+					print '<h2>'._("Messages received").'</h2>';
745
+				foreach ($msg as $eachmsg) {
746
+					//$eachmsg = $msg[0];
747
+					$data = $eachmsg['source_data'];
748
+					if ($data > 500) $max = (round(($data+100)/100))*100;
749
+					else $max = 500;
750
+			?>
751 751
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
752 752
         	<script>
753 753
 		      var g = new JustGage({
@@ -763,9 +763,9 @@  discard block
 block discarded – undo
763 763
 			  });
764 764
 		</script>
765 765
             <?php
766
-        	   }
767
-        	}
768
-            ?>
766
+			   }
767
+			}
768
+			?>
769 769
             </div>
770 770
         </div>
771 771
         <div class="row column">
@@ -803,26 +803,26 @@  discard block
 block discarded – undo
803 803
 			//$hist_data = substr($hist_data, 0, -1);
804 804
 			$distance_data = "['x',".substr($distance_data, 0, -1)."]";
805 805
 			$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
806
-            ?>
806
+			?>
807 807
             <div class="col-md-6">
808 808
                 <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
809 809
                 <?php
810
-                    print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
811
-		    print 'c3.generate({
810
+					print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
811
+			print 'c3.generate({
812 812
 			bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
813 813
 			data: { x: "x",
814 814
 			columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
815 815
 			axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
816
-		    print '</script>';
817
-        	?>
816
+			print '</script>';
817
+			?>
818 818
     	    </div>
819 819
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
820 820
         	<?php
821
-                  }
822
-                ?>
821
+				  }
822
+				?>
823 823
         </div>
824 824
 <?php
825
-    }
825
+	}
826 826
 ?>
827 827
     </div>
828 828
 </div>  
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 }
20 20
 
21 21
 if (!isset($filter_name)) $filter_name = '';
22
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
22
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
23 23
 if ($airline_icao == '' && isset($globalFilter)) {
24 24
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25 25
 }
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 	$title = _("Statistics");
35 35
 }
36 36
 
37
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
38
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
37
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
38
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
39 39
 
40 40
 require_once('header.php');
41 41
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		date_default_timezone_set('UTC');
62 62
 		$lastupdate = strtotime($last_update[0]['value']);
63 63
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
64
-		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
64
+		print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
65 65
 	}
66 66
     ?>
67 67
     </div>
@@ -70,30 +70,30 @@  discard block
 block discarded – undo
70 70
 <?php
71 71
     if ($type == 'aircraft') {
72 72
 ?>
73
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
74
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
75
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
76
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
73
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
74
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
75
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
76
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
77 77
 	<?php
78
-	    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
78
+	    if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
79 79
 	?>
80
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
81
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
80
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
81
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
82 82
         <?php
83 83
     	    } else {
84 84
     	?>
85
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
86
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
85
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
86
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
87 87
     	<?php
88 88
     	    }
89 89
     	?>
90
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
91
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
90
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
91
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
92 92
         <?php
93 93
     		if ($airline_icao == '') {
94 94
     	?>
95
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
96
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
95
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
96
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
97 97
 	<?php
98 98
 		}
99 99
 	?>
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
102 102
 			if ($airline_icao == '' || $airline_icao == 'all') {
103 103
 	?>
104
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
105
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
104
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
105
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
106 106
 	<?php
107 107
 			}
108 108
 		}
@@ -110,29 +110,29 @@  discard block
 block discarded – undo
110 110
 <?php
111 111
     } elseif ($type == 'marine') {
112 112
 ?>
113
-	<span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
114
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
113
+	<span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name, $year, $month)); ?></span> <?php echo _("Vessels"); ?></span>
114
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
115 115
 <?php
116 116
     } elseif ($type == 'tracker') {
117 117
 ?>
118
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
119
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
118
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name, $year, $month)); ?></span> <?php echo _("Trackers"); ?></span>
119
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
120 120
 <?php
121 121
     }
122 122
 ?>
123 123
     </p>
124
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
124
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
125 125
     <div class="specific-stats">
126 126
         <div class="row column">
127 127
             <div class="col-md-6">
128 128
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
129 129
                  <?php
130
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
130
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
131 131
 		    if (count($aircraft_array) == 0) print _("No data available");
132 132
 		    else {
133 133
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
134 134
                     $aircraft_data = '';
135
-                    foreach($aircraft_array as $aircraft_item)
135
+                    foreach ($aircraft_array as $aircraft_item)
136 136
                     {
137 137
                         $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
138 138
                     }
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
             	    ?>
162 162
                 </div>
163 163
             </div>
164
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
164
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
165 165
 <?php
166 166
 //    echo $airline_icao;
167 167
     if ($airline_icao == '' || $airline_icao == 'all') {
168
-	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
168
+	$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
169 169
 	if (count($airline_array) > 0) {
170 170
             print '<div class="col-md-6">';
171 171
 	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
172 172
 	    print '<div id="chart2" class="chart" width="100%"></div><script>';
173 173
 	    $airline_data = '';
174
-	    foreach($airline_array as $airline_item)
174
+	    foreach ($airline_array as $airline_item)
175 175
 	    {
176 176
 		$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
177 177
 	    }
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	}
198 198
 ?>
199 199
         </div>
200
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
200
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
201 201
 <?php
202 202
     }
203 203
 ?>
204 204
         <div class="row column">
205 205
 <?php
206
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
207
-    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
206
+    $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
207
+    if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
208 208
 	if (empty($flightover_array)) {
209 209
 	    print '<div class="col-md-12">';
210 210
 	} else {
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
 ?>
214 214
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
215 215
 <?php
216
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
216
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
217 217
 	if (count($pilot_array) == 0) print _("No data available");
218 218
 	else {
219 219
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
220 220
 	    $pilot_data = '';
221
-	    foreach($pilot_array as $pilot_item)
221
+	    foreach ($pilot_array as $pilot_item)
222 222
 	    {
223 223
 		$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
224 224
 	    }
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
 ?>
241 241
             </div>
242 242
         
243
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
243
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
244 244
 <?php
245 245
     } else {
246 246
 ?>
247 247
             <div class="col-md-6">
248 248
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
249 249
 <?php
250
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
250
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
251 251
 	if (count($owner_array) == 0) print _("No data available");
252 252
 	else {
253 253
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
254 254
 	    $owner_data = '';
255
-	    foreach($owner_array as $owner_item)
255
+	    foreach ($owner_array as $owner_item)
256 256
 	    {
257 257
 		$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
258 258
 	    }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                 </div>
273 273
             </div>
274 274
         
275
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
275
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
276 276
 <?php
277 277
     }
278 278
     if (!empty($flightover_array)) {
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	    print '<div id="chart10" class="chart" width="100%"></div><script>';
287 287
 	    print 'var series = [';
288 288
             $flightover_data = '';
289
-	    foreach($flightover_array as $flightover_item)
289
+	    foreach ($flightover_array as $flightover_item)
290 290
 	    {
291 291
 		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
292 292
 	    }
@@ -332,21 +332,21 @@  discard block
 block discarded – undo
332 332
     }
333 333
 ?>
334 334
         </div>
335
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
335
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
336 336
 
337 337
     	
338 338
         </div>
339 339
         <div class="row column">
340 340
             <div class="col-md-6">
341 341
 <?php
342
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
342
+    $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
343 343
     if (count($airport_airport_array) > 0) {
344 344
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
345 345
 	print '<div id="chart3" class="chart" width="100%"></div><script>';
346 346
         print "\n";
347 347
         print 'var series = [';
348 348
         $airport_data = '';
349
-	foreach($airport_airport_array as $airport_item)
349
+	foreach ($airport_airport_array as $airport_item)
350 350
 	{
351 351
 		$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
352 352
 	}
@@ -397,18 +397,18 @@  discard block
 block discarded – undo
397 397
     }
398 398
 ?>
399 399
             </div>
400
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
400
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
401 401
 
402 402
             <div class="col-md-6">
403 403
 <?php
404
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
404
+    $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
405 405
     if (count($airport_airport_array2) > 0) {
406 406
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
407 407
 	print '<div id="chart4" class="chart" width="100%"></div><script>';
408 408
         print "\n";
409 409
         print 'var series = [';
410 410
         $airport_data = '';
411
-	foreach($airport_airport_array2 as $airport_item)
411
+	foreach ($airport_airport_array2 as $airport_item)
412 412
 	{
413 413
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
414 414
 	}
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 ?>
462 462
             </div>
463 463
         </div>
464
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
464
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
465 465
 <?php
466 466
     if ($year == '' && $month == '') {
467 467
 ?>
@@ -469,19 +469,19 @@  discard block
 block discarded – undo
469 469
             <div class="col-md-6">
470 470
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
471 471
                 <?php
472
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
472
+                  $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
473 473
 		    if (count($year_array) == 0) print _("No data available");
474 474
 		    else {
475 475
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
476 476
 			$year_data = '';
477 477
 			$year_cnt = '';
478
-			foreach($year_array as $year_item)
478
+			foreach ($year_array as $year_item)
479 479
 			{
480 480
 			    $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
481 481
 			    $year_cnt .= $year_item['date_count'].',';
482 482
 			}
483 483
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
484
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
484
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
485 485
 			print 'c3.generate({
486 486
                 	    bindto: "#chart8",
487 487
                 	    data: { x: "x",
@@ -494,23 +494,23 @@  discard block
 block discarded – undo
494 494
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
495 495
                 </div>
496 496
             </div>
497
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
497
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
498 498
             <div class="col-md-6">
499 499
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
500 500
                 <?php
501
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
501
+                  $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
502 502
 		    if (count($month_array) == 0) print _("No data available");
503 503
 		    else {
504 504
                 	print '<div id="chart9" class="chart" width="100%"></div><script>';
505 505
                         $month_data = '';
506 506
 			$month_cnt = '';
507
-			foreach($month_array as $month_item)
507
+			foreach ($month_array as $month_item)
508 508
 			{
509 509
 			    $month_data .= '"'.$month_item['date_name'].'",';
510 510
 			    $month_cnt .= $month_item['date_count'].',';
511 511
 			}
512 512
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
513
-			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
513
+			$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
514 514
 			print 'c3.generate({
515 515
                 	    bindto: "#chart9",
516 516
                 	    data: { x: "x",
@@ -524,24 +524,24 @@  discard block
 block discarded – undo
524 524
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
525 525
                 </div>
526 526
             </div>
527
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
527
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
528 528
 
529 529
             <div class="col-md-6">
530 530
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
531 531
                 <?php
532
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
532
+                    $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
533 533
 		    if (empty($date_array)) print _("No data available");
534 534
 		    else {
535 535
                 	print '<div id="chart5" class="chart" width="100%"></div><script>';
536 536
                         $date_data = '';
537 537
 			$date_cnt = '';
538
-			foreach($date_array as $date_item)
538
+			foreach ($date_array as $date_item)
539 539
 			{
540 540
 			    $date_data .= '"'.$date_item['date_name'].'",';
541 541
 			    $date_cnt .= $date_item['date_count'].',';
542 542
 			}
543 543
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
544
-			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
544
+			$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
545 545
 			print 'c3.generate({
546 546
                 	    bindto: "#chart5",
547 547
                 	    data: { x: "x",
@@ -555,23 +555,23 @@  discard block
 block discarded – undo
555 555
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
556 556
                 </div>
557 557
             </div>
558
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
558
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
559 559
             <div class="col-md-6">
560 560
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
561 561
                 <?php
562
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
562
+                  $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
563 563
 		    if (empty($hour_array)) print _("No data available");
564 564
 		    else {
565 565
                 	print '<div id="chart6" class="chart" width="100%"></div><script>';
566 566
                         $hour_data = '';
567 567
 			$hour_cnt = '';
568
-			foreach($hour_array as $hour_item)
568
+			foreach ($hour_array as $hour_item)
569 569
 			{
570 570
 			    $hour_data .= '"'.$hour_item['hour_name'].':00",';
571 571
 			    $hour_cnt .= $hour_item['hour_count'].',';
572 572
 			}
573 573
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
574
-			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
574
+			$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
575 575
 			print 'c3.generate({
576 576
                 	    bindto: "#chart6",
577 577
                 	    data: {
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
586 586
                 </div>
587 587
             </div>
588
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
588
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
589 589
         </div>
590 590
 <?php
591 591
     }
@@ -604,13 +604,13 @@  discard block
 block discarded – undo
604 604
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
605 605
                         $year_data = '';
606 606
 			$year_cnt = '';
607
-			foreach($year_array as $year_item)
607
+			foreach ($year_array as $year_item)
608 608
 			{
609 609
 			    $year_data .= '"'.$year_item['year'].'-01-01",';
610 610
 			    $year_cnt .= $year_item['count'].',';
611 611
 			}
612 612
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
613
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
613
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
614 614
 			print 'c3.generate({
615 615
                 	    bindto: "#chart32",
616 616
                 	    data: { x: "x",
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
625 625
                 </div>
626 626
             </div>
627
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
627
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
628 628
 
629 629
         <div class="row column">
630 630
             <div class="col-md-6">
@@ -636,13 +636,13 @@  discard block
 block discarded – undo
636 636
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
637 637
                         $year_data = '';
638 638
 			$year_cnt = '';
639
-			foreach($year_array as $year_item)
639
+			foreach ($year_array as $year_item)
640 640
 			{
641 641
 			    $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
642 642
 			    $year_cnt .= $year_item['count'].',';
643 643
 			}
644 644
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
645
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
645
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
646 646
 			print 'c3.generate({
647 647
                 	    bindto: "#chart33",
648 648
                 	    data: { x: "x",
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
656 656
                 </div>
657 657
             </div>
658
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
658
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
659 659
 <br/>
660 660
 <?php
661 661
     }
@@ -668,9 +668,9 @@  discard block
 block discarded – undo
668 668
         	<?php
669 669
         	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
670 670
         	    if ($year == '' && $month == '') {
671
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
671
+		        $polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
672 672
 		    } else {
673
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
673
+        		$polar = $Stats->getStatsSource('polar', $year, $month);
674 674
         	    }
675 675
         	    if (!empty($polar)) {
676 676
             		print '<h2>'._("Coverage pattern").'</h2>';
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
         		    unset($polar_data);
679 679
 	        	    $Spotter = new Spotter();
680 680
         		    $data = json_decode($eachpolar['source_data']);
681
-        		    foreach($data as $value => $key) {
681
+        		    foreach ($data as $value => $key) {
682 682
         			$direction = $Spotter->parseDirection(($value*22.5));
683 683
         			$distance = $key;
684 684
         			$unit = 'km';
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
         	?>
699 699
             <div class="col-md-6">
700 700
                 <h4><?php print $eachpolar['source_name']; ?></h4>
701
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
701
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
702 702
         	<script>
703 703
         	    (function() {
704 704
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		      color: color,
723 723
 		      unit: '<?php echo $unit; ?>'
724 724
 		    };
725
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
725
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
726 726
 		    })();
727 727
 		</script>
728 728
             </div>
@@ -736,22 +736,22 @@  discard block
 block discarded – undo
736 736
         	<?php
737 737
         	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
738 738
         	    if ($year == '' && $month == '') {
739
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
739
+        		$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
740 740
         	    } else {
741
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
741
+        		$msg = $Stats->getStatsSource('msg', $year, $month);
742 742
         	    }
743 743
         	    if (!empty($msg)) {
744 744
             		print '<h2>'._("Messages received").'</h2>';
745 745
         		foreach ($msg as $eachmsg) {
746 746
         		    //$eachmsg = $msg[0];
747 747
         		    $data = $eachmsg['source_data'];
748
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
748
+        		    if ($data > 500) $max = (round(($data + 100)/100))*100;
749 749
         		    else $max = 500;
750 750
         	?>
751
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
751
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
752 752
         	<script>
753 753
 		      var g = new JustGage({
754
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
754
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
755 755
 			    value: <?php echo $data; ?>,
756 756
 			    min: 0,
757 757
 			    max: <?php print $max; ?>,
@@ -773,9 +773,9 @@  discard block
 block discarded – undo
773 773
             <?php
774 774
 		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
775 775
 		if ($year == '' && $month == '') {
776
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
776
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
777 777
 		} else {
778
-			$hist = $Stats->getStatsSource('hist',$year,$month);
778
+			$hist = $Stats->getStatsSource('hist', $year, $month);
779 779
 		}
780 780
 		foreach ($hist as $hists) {
781 781
 			//$hist_data = '';
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 			$source = $hists['source_name'];
785 785
 			$hist_array = json_decode($hists['source_data']);
786 786
 			$unit = 'km';
787
-			foreach($hist_array as $distance => $nb)
787
+			foreach ($hist_array as $distance => $nb)
788 788
 			{
789 789
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
790 790
 					$distance = round($distance*0.539957);
@@ -805,18 +805,18 @@  discard block
 block discarded – undo
805 805
 			$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
806 806
             ?>
807 807
             <div class="col-md-6">
808
-                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
808
+                <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2>
809 809
                 <?php
810
-                    print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
810
+                    print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
811 811
 		    print 'c3.generate({
812
-			bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
812
+			bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
813 813
 			data: { x: "x",
814 814
 			columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
815 815
 			axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
816 816
 		    print '</script>';
817 817
         	?>
818 818
     	    </div>
819
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
819
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
820 820
         	<?php
821 821
                   }
822 822
                 ?>
Please login to merge, or discard this patch.
Braces   +103 added lines, -42 removed lines patch added patch discarded remove patch
@@ -18,11 +18,15 @@  discard block
 block discarded – undo
18 18
 	require_once('require/class.Spotter.php');
19 19
 }
20 20
 
21
-if (!isset($filter_name)) $filter_name = '';
21
+if (!isset($filter_name)) {
22
+	$filter_name = '';
23
+}
22 24
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23 25
 if ($airline_icao == '' && isset($globalFilter)) {
24
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25
-}
26
+	if (isset($globalFilter['airline'])) {
27
+		$airline_icao = $globalFilter['airline'][0];
28
+	}
29
+	}
26 30
 if ($airline_icao != '' && $airline_icao != 'all') {
27 31
 	$Spotter = new Spotter();
28 32
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -53,14 +57,21 @@  discard block
 block discarded – undo
53 57
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
54 58
 <div class="column">
55 59
     <div class="info">
56
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
60
+            <h1><?php if (isset($airline_name)) {
61
+	echo _("Statistics for ").$airline_name;
62
+} else {
63
+	echo _("Statistics");
64
+}
65
+?></h1>
57 66
     <?php 
58 67
 	$last_update = $Stats->getLastStatsUpdate();
59 68
 	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
60 69
 	if (isset($last_update[0]['value'])) {
61 70
 		date_default_timezone_set('UTC');
62 71
 		$lastupdate = strtotime($last_update[0]['value']);
63
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
72
+		if (isset($globalTimezone) && $globalTimezone != '') {
73
+			date_default_timezone_set($globalTimezone);
74
+		}
64 75
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
65 76
 	}
66 77
     ?>
@@ -128,8 +139,9 @@  discard block
 block discarded – undo
128 139
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
129 140
                  <?php
130 141
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
131
-		    if (count($aircraft_array) == 0) print _("No data available");
132
-		    else {
142
+		    if (count($aircraft_array) == 0) {
143
+		    	print _("No data available");
144
+		    } else {
133 145
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
134 146
                     $aircraft_data = '';
135 147
                     foreach($aircraft_array as $aircraft_item)
@@ -151,11 +163,17 @@  discard block
 block discarded – undo
151 163
             	    <?php
152 164
             		if ($year != '' && $month != '') {
153 165
             	    ?>
154
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
166
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
167
+	echo '/'.$airline_icao;
168
+}
169
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
155 170
             	    <?php
156 171
             		} else {
157 172
             	    ?>
158
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
173
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
174
+	echo '/'.$airline_icao;
175
+}
176
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
159 177
             	    <?php
160 178
             		}
161 179
             	    ?>
@@ -186,11 +204,15 @@  discard block
 block discarded – undo
186 204
             print '</script>';
187 205
 	    if ($year != '' && $month != '') {
188 206
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
207
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
208
+			echo '/'.$airline_icao;
209
+		}
190 210
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191 211
 	    } else {
192 212
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
193
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
213
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
214
+			echo '/'.$airline_icao;
215
+		}
194 216
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
195 217
 	    }
196 218
     	    print '</div>';
@@ -214,8 +236,9 @@  discard block
 block discarded – undo
214 236
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
215 237
 <?php
216 238
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
217
-	if (count($pilot_array) == 0) print _("No data available");
218
-	else {
239
+	if (count($pilot_array) == 0) {
240
+		print _("No data available");
241
+	} else {
219 242
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
220 243
 	    $pilot_data = '';
221 244
 	    foreach($pilot_array as $pilot_item)
@@ -234,7 +257,9 @@  discard block
 block discarded – undo
234 257
         }
235 258
         print '<div class="more">';
236 259
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
237
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
260
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
261
+		echo '/'.$airline_icao;
262
+	}
238 263
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
239 264
 	print '</div>';
240 265
 ?>
@@ -248,8 +273,9 @@  discard block
 block discarded – undo
248 273
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
249 274
 <?php
250 275
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
251
-	if (count($owner_array) == 0) print _("No data available");
252
-	else {
276
+	if (count($owner_array) == 0) {
277
+		print _("No data available");
278
+	} else {
253 279
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
254 280
 	    $owner_data = '';
255 281
 	    foreach($owner_array as $owner_item)
@@ -268,7 +294,10 @@  discard block
 block discarded – undo
268 294
 	}
269 295
 ?>
270 296
                 <div class="more">
271
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
297
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
298
+	echo '/'.$airline_icao;
299
+}
300
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
272 301
                 </div>
273 302
             </div>
274 303
         
@@ -281,8 +310,9 @@  discard block
 block discarded – undo
281 310
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
282 311
 <?php
283 312
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
284
-	if (count($flightover_array) == 0) print _("No data available");
285
-	else {
313
+	if (count($flightover_array) == 0) {
314
+		print _("No data available");
315
+	} else {
286 316
 	    print '<div id="chart10" class="chart" width="100%"></div><script>';
287 317
 	    print 'var series = [';
288 318
             $flightover_data = '';
@@ -325,7 +355,10 @@  discard block
 block discarded – undo
325 355
 	}
326 356
 ?>
327 357
                 <div class="more">
328
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
358
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
359
+	echo '/'.$airline_icao;
360
+}
361
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
329 362
                 </div>
330 363
             </div>
331 364
 <?php
@@ -392,7 +425,9 @@  discard block
 block discarded – undo
392 425
 	print '</script>';
393 426
 
394 427
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
395
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
428
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
429
+		echo '/'.$airline_icao;
430
+	}
396 431
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
397 432
     }
398 433
 ?>
@@ -455,7 +490,9 @@  discard block
 block discarded – undo
455 490
 
456 491
 
457 492
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
458
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
493
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
494
+		echo '/'.$airline_icao;
495
+	}
459 496
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
460 497
     }
461 498
 ?>
@@ -470,8 +507,9 @@  discard block
 block discarded – undo
470 507
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
471 508
                 <?php
472 509
                   $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
473
-		    if (count($year_array) == 0) print _("No data available");
474
-		    else {
510
+		    if (count($year_array) == 0) {
511
+		    	print _("No data available");
512
+		    } else {
475 513
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
476 514
 			$year_data = '';
477 515
 			$year_cnt = '';
@@ -491,7 +529,10 @@  discard block
 block discarded – undo
491 529
                     }
492 530
                   ?>
493 531
                 <div class="more">
494
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
532
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
533
+	echo '/'.$airline_icao;
534
+}
535
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
495 536
                 </div>
496 537
             </div>
497 538
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -499,8 +540,9 @@  discard block
 block discarded – undo
499 540
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
500 541
                 <?php
501 542
                   $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
502
-		    if (count($month_array) == 0) print _("No data available");
503
-		    else {
543
+		    if (count($month_array) == 0) {
544
+		    	print _("No data available");
545
+		    } else {
504 546
                 	print '<div id="chart9" class="chart" width="100%"></div><script>';
505 547
                         $month_data = '';
506 548
 			$month_cnt = '';
@@ -521,7 +563,10 @@  discard block
 block discarded – undo
521 563
                     }
522 564
                   ?>
523 565
                 <div class="more">
524
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
566
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
567
+	echo '/'.$airline_icao;
568
+}
569
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
525 570
                 </div>
526 571
             </div>
527 572
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -530,8 +575,9 @@  discard block
 block discarded – undo
530 575
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
531 576
                 <?php
532 577
                     $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
533
-		    if (empty($date_array)) print _("No data available");
534
-		    else {
578
+		    if (empty($date_array)) {
579
+		    	print _("No data available");
580
+		    } else {
535 581
                 	print '<div id="chart5" class="chart" width="100%"></div><script>';
536 582
                         $date_data = '';
537 583
 			$date_cnt = '';
@@ -552,7 +598,10 @@  discard block
 block discarded – undo
552 598
                     }
553 599
                   ?>
554 600
                 <div class="more">
555
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
601
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
602
+	echo '/'.$airline_icao;
603
+}
604
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
556 605
                 </div>
557 606
             </div>
558 607
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -560,8 +609,9 @@  discard block
 block discarded – undo
560 609
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
561 610
                 <?php
562 611
                   $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
563
-		    if (empty($hour_array)) print _("No data available");
564
-		    else {
612
+		    if (empty($hour_array)) {
613
+		    	print _("No data available");
614
+		    } else {
565 615
                 	print '<div id="chart6" class="chart" width="100%"></div><script>';
566 616
                         $hour_data = '';
567 617
 			$hour_cnt = '';
@@ -582,7 +632,10 @@  discard block
 block discarded – undo
582 632
                   }
583 633
                 ?>
584 634
                 <div class="more">
585
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
636
+	echo '/'.$airline_icao;
637
+}
638
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
586 639
                 </div>
587 640
             </div>
588 641
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -599,8 +652,9 @@  discard block
 block discarded – undo
599 652
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
600 653
                 <?php
601 654
                   $year_array = $Stats->countFatalitiesByYear();
602
-		    if (count($year_array) == 0) print _("No data available");
603
-		    else {
655
+		    if (count($year_array) == 0) {
656
+		    	print _("No data available");
657
+		    } else {
604 658
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
605 659
                         $year_data = '';
606 660
 			$year_cnt = '';
@@ -631,8 +685,9 @@  discard block
 block discarded – undo
631 685
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
632 686
                 <?php
633 687
                   $year_array = $Stats->countFatalitiesLast12Months();
634
-		    if (count($year_array) == 0) print _("No data available");
635
-		    else {
688
+		    if (count($year_array) == 0) {
689
+		    	print _("No data available");
690
+		    } else {
636 691
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
637 692
                         $year_data = '';
638 693
 			$year_cnt = '';
@@ -692,8 +747,11 @@  discard block
 block discarded – undo
692 747
 					$distance = $distance;
693 748
 					$unit = 'km';
694 749
 				}
695
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
696
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
750
+        			if (!isset($polar_data)) {
751
+        				$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
752
+        			} else {
753
+        	    			$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
754
+        	    		}
697 755
         		    }
698 756
         	?>
699 757
             <div class="col-md-6">
@@ -745,8 +803,11 @@  discard block
 block discarded – undo
745 803
         		foreach ($msg as $eachmsg) {
746 804
         		    //$eachmsg = $msg[0];
747 805
         		    $data = $eachmsg['source_data'];
748
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
749
-        		    else $max = 500;
806
+        		    if ($data > 500) {
807
+        		    	$max = (round(($data+100)/100))*100;
808
+        		    } else {
809
+        		    	$max = 500;
810
+        		    }
750 811
         	?>
751 812
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
752 813
         	<script>
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     <?php }; if (isset($globalTracker) && $globalTracker) { ?><td><div id="ibxtracker"><h4><?php echo _("Trackers Detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?>
41 41
 </tr></table></div>
42 42
 <?php
43
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
43
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
44 44
 
45 45
 ?>
46 46
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
61 61
 <?php
62 62
 	}
63
-    }
63
+	}
64 64
 ?>
65 65
 <div id="dialog" title="<?php echo _("Session has timed-out"); ?>">
66 66
   <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p>
@@ -74,34 +74,34 @@  discard block
 block discarded – undo
74 74
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
75 75
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
76 76
 <?php
77
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
77
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
78 78
 	if (isset($globalArchive) && $globalArchive == TRUE) {
79 79
 ?>
80 80
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
81 81
 <?php
82 82
 	}
83
-    }
83
+	}
84 84
 ?>
85 85
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
86 86
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
87 87
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
88 88
 <?php
89
-    if (isset($globalMap3D) && $globalMap3D) {
89
+	if (isset($globalMap3D) && $globalMap3D) {
90 90
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
91 91
 ?>
92 92
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
93 93
 <?php
94
-        } else {
95
-    	    if (isset($globalMapSatellites) && $globalMapSatellites) {
94
+		} else {
95
+			if (isset($globalMapSatellites) && $globalMapSatellites) {
96 96
 ?>
97 97
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
98 98
 <?php
99
-	    }
99
+		}
100 100
 ?>
101 101
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
102 102
 <?php
103 103
 	}
104
-    }
104
+	}
105 105
 ?>
106 106
     </ul>
107 107
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 ?>
176 176
         </div>
177 177
 <?php
178
-    if (isset($globalArchive) && $globalArchive == TRUE) {
178
+	if (isset($globalArchive) && $globalArchive == TRUE) {
179 179
 ?>
180 180
         <div class="sidebar-pane" id="archive">
181 181
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	    </form>
236 236
 	</div>
237 237
 <?php
238
-    }
238
+	}
239 239
 ?>
240 240
         <div class="sidebar-pane" id="settings">
241 241
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -246,56 +246,56 @@  discard block
 block discarded – undo
246 246
 			    <?php
247 247
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
248 248
 				else $MapType = $_COOKIE['MapType'];
249
-			    ?>
249
+				?>
250 250
 			    <?php
251 251
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
252
-			    ?>
252
+				?>
253 253
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
254 254
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
255 255
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
256 256
 			    <?php
257 257
 				}
258
-			    ?>
258
+				?>
259 259
 			    <?php
260
-			        if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
261
-			    ?>
260
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
261
+				?>
262 262
 			    <?php
263
-				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
264
-			    ?>
263
+					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
264
+				?>
265 265
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
266 266
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
267 267
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
268 268
 			    <?php
269
-				    }
270
-			    ?>
269
+					}
270
+				?>
271 271
 			    <?php
272
-				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
273
-			    ?>
272
+					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
273
+				?>
274 274
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
275 275
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
276 276
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
277 277
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
278 278
 			    <?php
279
-				    }
280
-			    ?>
279
+					}
280
+				?>
281 281
 			    <?php
282
-				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
283
-			    ?>
282
+					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
283
+				?>
284 284
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
285 285
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
286 286
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
287 287
 			    <?php
288
-				    }
289
-			    ?>
288
+					}
289
+				?>
290 290
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
291 291
 			    <?php
292 292
 				}
293
-			    ?>
293
+				?>
294 294
 			    <?php
295
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
295
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
296 296
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
297 297
 					else $MapBoxId = $_COOKIE['MapTypeId'];
298
-			    ?>
298
+				?>
299 299
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
300 300
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
301 301
 			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
310 310
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
311 311
 			    <?php
312
-				    }
313
-			    ?>
312
+					}
313
+				?>
314 314
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
315 315
 			</select>
316 316
 		    </li>
317 317
 <?php
318
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
318
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
319 319
 ?>
320 320
 		    <li><?php echo _("Type of Terrain:"); ?>
321 321
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -325,10 +325,10 @@  discard block
 block discarded – undo
325 325
 			</select>
326 326
 		    </li>
327 327
 <?php
328
-    }
328
+	}
329 329
 ?>
330 330
 <?php
331
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
331
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
332 332
 ?>
333 333
 		    
334 334
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
@@ -336,75 +336,75 @@  discard block
 block discarded – undo
336 336
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
337 337
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
338 338
 <?php
339
-    }
339
+	}
340 340
 ?>
341 341
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
342 342
 <?php
343
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
343
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
344 344
 ?>
345 345
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
346 346
 <?php
347
-    }
348
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
347
+	}
348
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
349 349
 ?>
350 350
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
351 351
 <?php
352
-    }
352
+	}
353 353
 ?>
354 354
 
355 355
 		    <?php
356 356
 			if (function_exists('array_column')) {
357
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
358
-		    ?>
357
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
358
+			?>
359 359
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
360 360
 		    <?php
361
-			    }
361
+				}
362 362
 			} elseif (isset($globalSources)) {
363
-			    $dispolar = false;
364
-			    foreach ($globalSources as $testsource) {
365
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
366
-			    }
367
-			    if ($dispolar) {
368
-		    ?>
363
+				$dispolar = false;
364
+				foreach ($globalSources as $testsource) {
365
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
366
+				}
367
+				if ($dispolar) {
368
+			?>
369 369
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
370 370
 		    <?php
371
-			    }
372
-		        }
373
-		    ?>
371
+				}
372
+				}
373
+			?>
374 374
 <?php
375
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
375
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
376 376
 ?>
377 377
 
378 378
 		    <?php
379 379
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
380
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
381
-		    ?>
380
+					if (extension_loaded('gd') && function_exists('gd_info')) {
381
+			?>
382 382
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
383 383
 		    <?php 
384 384
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
385
-		    ?>
385
+			?>
386 386
 		    <li><?php echo _("Aircraft icon color:"); ?>
387 387
 			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
388 388
 		    </li>
389 389
 		    <?php
390 390
 				}
391
-			    }
392
-		        }
393
-		    ?>
391
+				}
392
+				}
393
+			?>
394 394
 		    <?php
395 395
 			if (isset($globalMarine) && $globalMarine === TRUE) {
396
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
397
-		    ?>
396
+				if (extension_loaded('gd') && function_exists('gd_info')) {
397
+			?>
398 398
 		    <li><?php echo _("Marine icon color:"); ?>
399 399
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
400 400
 		    </li>
401 401
 		    <?php
402
-			    }
403
-		        }
404
-		    ?>
402
+				}
403
+				}
404
+			?>
405 405
 		    <?php
406 406
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
407
-		    ?>
407
+			?>
408 408
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
409 409
 			<div class="range">
410 410
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -413,9 +413,9 @@  discard block
 block discarded – undo
413 413
 		    </li>
414 414
 		    <?php
415 415
 			}
416
-		    ?>
416
+			?>
417 417
 <?php
418
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
418
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
419 419
 ?>
420 420
 <?php
421 421
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		    </li>
437 437
 <?php
438 438
 	}
439
-    }
439
+	}
440 440
 ?>
441 441
 		    <li><?php echo _("Distance unit:"); ?>
442 442
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -469,19 +469,19 @@  discard block
 block discarded – undo
469 469
 		    <ul>
470 470
 		    <?php
471 471
 			if (!isset($globalAircraft) || $globalAircraft) {
472
-		    ?>
472
+			?>
473 473
 		    <?php
474 474
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
475
-		    ?>
475
+			?>
476 476
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
477 477
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
478 478
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
479 479
 		    <?php
480 480
 			}
481
-		    ?>
481
+			?>
482 482
 		    <?php
483 483
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
484
-		    ?>
484
+			?>
485 485
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
486 486
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
487 487
 			<?php } ?>
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 			<?php } ?>
491 491
 		    <?php
492 492
 			}
493
-		    ?>
493
+			?>
494 494
 		    <li><?php echo _("Display airlines:"); ?>
495 495
 		    <br/>
496 496
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -510,14 +510,14 @@  discard block
 block discarded – undo
510 510
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
511 511
 					}
512 512
 				}
513
-			    ?>
513
+				?>
514 514
 			</select>
515 515
 		    </li>
516 516
 		    <?php
517 517
 			$Spotter = new Spotter();
518 518
 			$allalliancenames = $Spotter->getAllAllianceNames();
519 519
 			if (!empty($allalliancenames)) {
520
-		    ?>
520
+			?>
521 521
 		    <li><?php echo _("Display alliance:"); ?>
522 522
 		    <br/>
523 523
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -531,18 +531,18 @@  discard block
 block discarded – undo
531 531
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
532 532
 					}
533 533
 				}
534
-			    ?>
534
+				?>
535 535
 			</select>
536 536
 		    </li>
537 537
 		    <?php
538 538
 			}
539
-		    ?>
539
+			?>
540 540
 		    <?php
541 541
 			}
542
-		    ?>
542
+			?>
543 543
 		    <?php
544 544
 			if (isset($globalAPRS) && $globalAPRS) {
545
-		    ?>
545
+			?>
546 546
 		    <li><?php echo _("Display APRS sources name:"); ?>
547 547
 			<select class="selectpicker" multiple onchange="sources(this);">
548 548
 			    <?php
@@ -554,18 +554,18 @@  discard block
 block discarded – undo
554 554
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
555 555
 					}
556 556
 				}
557
-			    ?>
557
+				?>
558 558
 			</select>
559 559
 		    </li>
560 560
 		    <?php
561 561
 			}
562
-		    ?>
562
+			?>
563 563
 		    <?php
564 564
 			if (!isset($globalAircraft) && $globalAircraft) {
565
-		    ?>
565
+			?>
566 566
 		    <?php
567 567
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
568
-		    ?>
568
+			?>
569 569
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
570 570
 			<select class="selectpicker" onchange="airlinestype(this);">
571 571
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -576,14 +576,14 @@  discard block
 block discarded – undo
576 576
 		    </li>
577 577
 		    <?php
578 578
 			}
579
-		    ?>
579
+			?>
580 580
 		    <li>
581 581
 			<?php echo _("Display flight with ident:"); ?>
582 582
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
583 583
 		    </li>
584 584
 		    <?php
585 585
 			}
586
-		    ?>
586
+			?>
587 587
 		</ul>
588 588
 	    </form>
589 589
 	    <form method="post">
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 	    </form>
593 593
     	</div>
594 594
 <?php
595
-    if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
595
+	if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
596 596
 ?>
597 597
         <div class="sidebar-pane" id="satellites">
598 598
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -632,14 +632,14 @@  discard block
 block discarded – undo
632 632
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
633 633
 					}
634 634
 				}
635
-			    ?>
635
+				?>
636 636
 			</select>
637 637
 		    </li>
638 638
 		</ul>
639 639
 	    </form>
640 640
 	</div>
641 641
 <?php
642
-    }
642
+	}
643 643
 ?>
644 644
     </div>
645 645
 </div>
Please login to merge, or discard this patch.
Braces   +393 added lines, -101 removed lines patch added patch discarded remove patch
@@ -154,11 +154,26 @@  discard block
 block discarded – undo
154 154
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
155 155
 				<li><?php echo _("NOTAM scope:"); ?>
156 156
 					<select class="selectpicker" onchange="notamscope(this);">
157
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
158
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
159
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
160
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
161
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
157
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
158
+	print ' selected';
159
+}
160
+?>>All</option>
161
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
162
+	print ' selected';
163
+}
164
+?>>Airport/Enroute warning</option>
165
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
166
+	print ' selected';
167
+}
168
+?>>Airport warning</option>
169
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
170
+	print ' selected';
171
+}
172
+?>>Navigation warning</option>
173
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
174
+	print ' selected';
175
+}
176
+?>>Enroute warning</option>
162 177
 					</select
163 178
 				</li>
164 179
 			</ul>
@@ -186,7 +201,12 @@  discard block
 block discarded – undo
186 201
 		        <div class="form-group">
187 202
 			    <label>From (UTC):</label>
188 203
 		            <div class='input-group date' id='datetimepicker1'>
189
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
204
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) {
205
+	print $_POST['start_date'];
206
+} elseif (isset($_COOKIE['archive_begin'])) {
207
+	print date("m/d/Y h:i a",$_COOKIE['archive_begin']);
208
+}
209
+?>" required />
190 210
 		                <span class="input-group-addon">
191 211
             			    <span class="glyphicon glyphicon-calendar"></span>
192 212
 		                </span>
@@ -195,7 +215,12 @@  discard block
 block discarded – undo
195 215
 		        <div class="form-group">
196 216
 			    <label>To (UTC):</label>
197 217
 		            <div class='input-group date' id='datetimepicker2'>
198
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
218
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) {
219
+	print $_POST['end_date'];
220
+} elseif (isset($_COOKIE['archive_end'])) {
221
+	print date("m/d/Y h:i a",$_COOKIE['archive_end']);
222
+}
223
+?>" />
199 224
             			<span class="input-group-addon">
200 225
 		                    <span class="glyphicon glyphicon-calendar"></span>
201 226
             			</span>
@@ -221,8 +246,20 @@  discard block
 block discarded – undo
221 246
 
222 247
 		    <li><?php echo _("Playback speed:"); ?>
223 248
 			<div class="range">
224
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
225
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
249
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
250
+	print $_POST['archivespeed'];
251
+} elseif (isset($_COOKIE['archive_speed'])) {
252
+	print $_COOKIE['archive_speed'];
253
+} else {
254
+	print '1';
255
+}
256
+?>">
257
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
258
+	print $_COOKIE['archive_speed'];
259
+} else {
260
+	print '1';
261
+}
262
+?></output>
226 263
 			</div>
227 264
 		    </li>
228 265
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -244,15 +281,27 @@  discard block
 block discarded – undo
244 281
 		    <li><?php echo _("Type of Map:"); ?>
245 282
 			<select  class="selectpicker" onchange="mapType(this);">
246 283
 			    <?php
247
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
248
-				else $MapType = $_COOKIE['MapType'];
284
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
285
+					$MapType = $globalMapProvider;
286
+				} else {
287
+					$MapType = $_COOKIE['MapType'];
288
+				}
249 289
 			    ?>
250 290
 			    <?php
251 291
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
252 292
 			    ?>
253
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
254
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
255
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
293
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
294
+	print ' selected';
295
+}
296
+?>>Bing-Aerial</option>
297
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
298
+	print ' selected';
299
+}
300
+?>>Bing-Hybrid</option>
301
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
302
+	print ' selected';
303
+}
304
+?>>Bing-Road</option>
256 305
 			    <?php
257 306
 				}
258 307
 			    ?>
@@ -262,56 +311,131 @@  discard block
 block discarded – undo
262 311
 			    <?php
263 312
 				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
264 313
 			    ?>
265
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
266
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
267
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
314
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
315
+	print ' selected';
316
+}
317
+?>>Here-Aerial</option>
318
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
319
+	print ' selected';
320
+}
321
+?>>Here-Hybrid</option>
322
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
323
+	print ' selected';
324
+}
325
+?>>Here-Road</option>
268 326
 			    <?php
269 327
 				    }
270 328
 			    ?>
271 329
 			    <?php
272 330
 				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
273 331
 			    ?>
274
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
275
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
276
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
277
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
332
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
333
+	print ' selected';
334
+}
335
+?>>Google Roadmap</option>
336
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
337
+	print ' selected';
338
+}
339
+?>>Google Satellite</option>
340
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
341
+	print ' selected';
342
+}
343
+?>>Google Hybrid</option>
344
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
345
+	print ' selected';
346
+}
347
+?>>Google Terrain</option>
278 348
 			    <?php
279 349
 				    }
280 350
 			    ?>
281 351
 			    <?php
282 352
 				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
283 353
 			    ?>
284
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
285
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
286
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
354
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
355
+	print ' selected';
356
+}
357
+?>>MapQuest-OSM</option>
358
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
359
+	print ' selected';
360
+}
361
+?>>MapQuest-Aerial</option>
362
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
363
+	print ' selected';
364
+}
365
+?>>MapQuest-Hybrid</option>
287 366
 			    <?php
288 367
 				    }
289 368
 			    ?>
290
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
369
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
370
+	print ' selected';
371
+}
372
+?>>Yandex</option>
291 373
 			    <?php
292 374
 				}
293 375
 			    ?>
294 376
 			    <?php
295 377
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
296
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
297
-					else $MapBoxId = $_COOKIE['MapTypeId'];
378
+					if (!isset($_COOKIE['MapTypeId'])) {
379
+						$MapBoxId = 'default';
380
+					} else {
381
+						$MapBoxId = $_COOKIE['MapTypeId'];
382
+					}
298 383
 			    ?>
299
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
300
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
301
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
302
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
303
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
304
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
305
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
306
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
307
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
308
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
309
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
310
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
384
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
385
+	print ' selected';
386
+}
387
+?>>Mapbox default</option>
388
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
389
+	print ' selected';
390
+}
391
+?>>Mapbox streets</option>
392
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
393
+	print ' selected';
394
+}
395
+?>>Mapbox light</option>
396
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
397
+	print ' selected';
398
+}
399
+?>>Mapbox dark</option>
400
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
401
+	print ' selected';
402
+}
403
+?>>Mapbox satellite</option>
404
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
405
+	print ' selected';
406
+}
407
+?>>Mapbox streets-satellite</option>
408
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
409
+	print ' selected';
410
+}
411
+?>>Mapbox streets-basic</option>
412
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
413
+	print ' selected';
414
+}
415
+?>>Mapbox comic</option>
416
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
417
+	print ' selected';
418
+}
419
+?>>Mapbox outdoors</option>
420
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
421
+	print ' selected';
422
+}
423
+?>>Mapbox pencil</option>
424
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
425
+	print ' selected';
426
+}
427
+?>>Mapbox pirates</option>
428
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
429
+	print ' selected';
430
+}
431
+?>>Mapbox emerald</option>
311 432
 			    <?php
312 433
 				    }
313 434
 			    ?>
314
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
435
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
436
+	print ' selected';
437
+}
438
+?>>OpenStreetMap</option>
315 439
 			</select>
316 440
 		    </li>
317 441
 <?php
@@ -319,9 +443,18 @@  discard block
 block discarded – undo
319 443
 ?>
320 444
 		    <li><?php echo _("Type of Terrain:"); ?>
321 445
 			<select  class="selectpicker" onchange="terrainType(this);">
322
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
323
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
324
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
446
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
447
+	print ' selected';
448
+}
449
+?>>stk terrain</option>
450
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
451
+	print ' selected';
452
+}
453
+?>>ellipsoid</option>
454
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
455
+	print ' selected';
456
+}
457
+?>>vr terrain</option>
325 458
 			</select>
326 459
 		    </li>
327 460
 <?php
@@ -331,18 +464,36 @@  discard block
 block discarded – undo
331 464
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
332 465
 ?>
333 466
 		    
334
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
335
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
336
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
337
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
467
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
468
+	print 'checked';
469
+}
470
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
471
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
472
+	print 'checked';
473
+}
474
+?> ><?php echo _("Display flight path"); ?></label></div></li>
475
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) {
476
+	print 'checked';
477
+}
478
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
479
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
480
+	print 'checked';
481
+}
482
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
338 483
 <?php
339 484
     }
340 485
 ?>
341
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
486
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') {
487
+	print 'checked';
488
+}
489
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
342 490
 <?php
343 491
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
344 492
 ?>
345
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
493
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
494
+	print 'checked';
495
+}
496
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
346 497
 <?php
347 498
     }
348 499
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -356,17 +507,25 @@  discard block
 block discarded – undo
356 507
 			if (function_exists('array_column')) {
357 508
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
358 509
 		    ?>
359
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
510
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
511
+	print 'checked';
512
+}
513
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
360 514
 		    <?php
361 515
 			    }
362 516
 			} elseif (isset($globalSources)) {
363 517
 			    $dispolar = false;
364 518
 			    foreach ($globalSources as $testsource) {
365
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
519
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
520
+			        	$dispolar = true;
521
+			        }
366 522
 			    }
367 523
 			    if ($dispolar) {
368 524
 		    ?>
369
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
525
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
526
+	print 'checked';
527
+}
528
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
370 529
 		    <?php
371 530
 			    }
372 531
 		        }
@@ -379,12 +538,22 @@  discard block
 block discarded – undo
379 538
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
380 539
 		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
381 540
 		    ?>
382
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
541
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
542
+	print 'checked';
543
+}
544
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
383 545
 		    <?php 
384 546
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
385 547
 		    ?>
386 548
 		    <li><?php echo _("Aircraft icon color:"); ?>
387
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
549
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
550
+	print $_COOKIE['IconColor'];
551
+} elseif (isset($globalAircraftIconColor)) {
552
+	print $globalAircraftIconColor;
553
+} else {
554
+	print '1a3151';
555
+}
556
+?>">
388 557
 		    </li>
389 558
 		    <?php
390 559
 				}
@@ -396,7 +565,14 @@  discard block
 block discarded – undo
396 565
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
397 566
 		    ?>
398 567
 		    <li><?php echo _("Marine icon color:"); ?>
399
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
568
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
569
+	print $_COOKIE['MarineIconColor'];
570
+} elseif (isset($globalMarineIconColor)) {
571
+	print $globalMarineIconColor;
572
+} else {
573
+	print '1a3151';
574
+}
575
+?>">
400 576
 		    </li>
401 577
 		    <?php
402 578
 			    }
@@ -407,8 +583,22 @@  discard block
 block discarded – undo
407 583
 		    ?>
408 584
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
409 585
 			<div class="range">
410
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
411
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
586
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
587
+	print $_COOKIE['AirportZoom'];
588
+} elseif (isset($globalAirportZoom)) {
589
+	print $globalAirportZoom;
590
+} else {
591
+	print '7';
592
+}
593
+?>">
594
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
595
+	print $_COOKIE['AirportZoom'];
596
+} elseif (isset($globalAirportZoom)) {
597
+	print $globalAirportZoom;
598
+} else {
599
+	print '7';
600
+}
601
+?></output>
412 602
 			</div>
413 603
 		    </li>
414 604
 		    <?php
@@ -420,9 +610,19 @@  discard block
 block discarded – undo
420 610
 <?php
421 611
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
422 612
 ?>
423
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
613
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
614
+	print 'checked';
615
+}
616
+?> ><?php echo _("Force Aircraft color"); ?></li>
424 617
 		    <li><?php echo _("Aircraft icon color:"); ?>
425
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>">
618
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
619
+	print $_COOKIE['IconColor'];
620
+} elseif (isset($globalAircraftIconColor)) {
621
+	print $globalAircraftIconColor;
622
+} else {
623
+	print 'ff0000';
624
+}
625
+?>">
426 626
 		    </li>
427 627
 <?php
428 628
 	}
@@ -430,9 +630,19 @@  discard block
 block discarded – undo
430 630
 <?php
431 631
 	if (isset($globalMarine) && $globalMarine === TRUE) {
432 632
 ?>
433
-		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?></li>
633
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
634
+	print 'checked';
635
+}
636
+?> ><?php echo _("Force Marine color"); ?></li>
434 637
 		    <li><?php echo _("Marine icon color:"); ?>
435
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>">
638
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
639
+	print $_COOKIE['MarineIconColor'];
640
+} elseif (isset($globalMarineIconColor)) {
641
+	print $globalMarineIconColor;
642
+} else {
643
+	print 'ff0000';
644
+}
645
+?>">
436 646
 		    </li>
437 647
 <?php
438 648
 	}
@@ -440,22 +650,46 @@  discard block
 block discarded – undo
440 650
 ?>
441 651
 		    <li><?php echo _("Distance unit:"); ?>
442 652
 			<select class="selectpicker" onchange="unitdistance(this);">
443
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
444
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
445
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
653
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
654
+	echo ' selected';
655
+}
656
+?>>km</option>
657
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
658
+	echo ' selected';
659
+}
660
+?>>nm</option>
661
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
662
+	echo ' selected';
663
+}
664
+?>>mi</option>
446 665
 		        </select>
447 666
 		    </li>
448 667
 		    <li><?php echo _("Altitude unit:"); ?>
449 668
 			<select class="selectpicker" onchange="unitaltitude(this);">
450
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
451
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
669
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
670
+	echo ' selected';
671
+}
672
+?>>m</option>
673
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
674
+	echo ' selected';
675
+}
676
+?>>feet</option>
452 677
 		        </select>
453 678
 		    </li>
454 679
 		    <li><?php echo _("Speed unit:"); ?>
455 680
 			<select class="selectpicker" onchange="unitspeed(this);">
456
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
457
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
458
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
681
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
682
+	echo ' selected';
683
+}
684
+?>>km/h</option>
685
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
686
+	echo ' selected';
687
+}
688
+?>>mph</option>
689
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
690
+	echo ' selected';
691
+}
692
+?>>knots</option>
459 693
 		        </select>
460 694
 		    </li>
461 695
 
@@ -473,9 +707,18 @@  discard block
 block discarded – undo
473 707
 		    <?php
474 708
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
475 709
 		    ?>
476
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
477
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
478
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
710
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
711
+	print 'checked';
712
+}
713
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
714
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
715
+	print 'checked';
716
+}
717
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
718
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
719
+	print 'checked';
720
+}
721
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
479 722
 		    <?php
480 723
 			}
481 724
 		    ?>
@@ -483,10 +726,16 @@  discard block
 block discarded – undo
483 726
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
484 727
 		    ?>
485 728
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
486
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
729
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
730
+	print 'checked';
731
+}
732
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
487 733
 			<?php } ?>
488 734
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
489
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
735
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
736
+	print 'checked';
737
+}
738
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
490 739
 			<?php } ?>
491 740
 		    <?php
492 741
 			}
@@ -503,7 +752,9 @@  discard block
 block discarded – undo
503 752
 				}
504 753
 				foreach($allairlinenames as $airline) {
505 754
 					$airline_name = $airline['airline_name'];
506
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
755
+					if (strlen($airline_name) > 30) {
756
+						$airline_name = substr($airline_name,0,30).'...';
757
+					}
507 758
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
508 759
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
509 760
 					} else {
@@ -521,7 +772,10 @@  discard block
 block discarded – undo
521 772
 		    <li><?php echo _("Display alliance:"); ?>
522 773
 		    <br/>
523 774
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
524
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
775
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
776
+	echo ' selected';
777
+}
778
+?>><?php echo _("All"); ?></option>
525 779
 			    <?php
526 780
 				foreach($allalliancenames as $alliance) {
527 781
 					$alliance_name = $alliance['alliance'];
@@ -568,10 +822,22 @@  discard block
 block discarded – undo
568 822
 		    ?>
569 823
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
570 824
 			<select class="selectpicker" onchange="airlinestype(this);">
571
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
572
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
573
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
574
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
825
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
826
+	echo ' selected';
827
+}
828
+?>><?php echo _("All"); ?></option>
829
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
830
+	echo ' selected';
831
+}
832
+?>><?php echo _("Passenger"); ?></option>
833
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
834
+	echo ' selected';
835
+}
836
+?>><?php echo _("Cargo"); ?></option>
837
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
838
+	echo ' selected';
839
+}
840
+?>><?php echo _("Military"); ?></option>
575 841
 			</select>
576 842
 		    </li>
577 843
 		    <?php
@@ -579,7 +845,10 @@  discard block
 block discarded – undo
579 845
 		    ?>
580 846
 		    <li>
581 847
 			<?php echo _("Display flight with ident:"); ?>
582
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
848
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
849
+	print $_COOKIE['filter_ident'];
850
+}
851
+?>" />
583 852
 		    </li>
584 853
 		    <?php
585 854
 			}
@@ -598,7 +867,10 @@  discard block
 block discarded – undo
598 867
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
599 868
 	    <form>
600 869
 		<ul>
601
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
870
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') {
871
+	print 'checked';
872
+}
873
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
602 874
 		    <li><?php echo _("Type:"); ?>
603 875
 			<select class="selectpicker" multiple onchange="sattypes(this);">
604 876
 			    <?php
@@ -606,25 +878,45 @@  discard block
 block discarded – undo
606 878
 				$types = $Satellite->get_tle_types();
607 879
 				foreach ($types as $type) {
608 880
 					$type_name = $type['tle_type'];
609
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
610
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
611
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
612
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
613
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
614
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
615
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
616
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
617
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
618
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
619
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
620
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
621
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
622
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
623
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
624
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
625
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
626
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
627
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
881
+					if ($type_name == 'musson') {
882
+						$type_name = 'Russian LEO Navigation';
883
+					} else if ($type_name == 'nnss') {
884
+						$type_name = 'Navi Navigation Satellite System';
885
+					} else if ($type_name == 'sbas') {
886
+						$type_name = 'Satellite-Based Augmentation System';
887
+					} else if ($type_name == 'glo-ops') {
888
+						$type_name = 'Glonass Operational';
889
+					} else if ($type_name == 'gps-ops') {
890
+						$type_name = 'GPS Operational';
891
+					} else if ($type_name == 'argos') {
892
+						$type_name = 'ARGOS Data Collection System';
893
+					} else if ($type_name == 'tdrss') {
894
+						$type_name = 'Tracking and Data Relay Satellite System';
895
+					} else if ($type_name == 'sarsat') {
896
+						$type_name = 'Search & Rescue';
897
+					} else if ($type_name == 'dmc') {
898
+						$type_name = 'Disaster Monitoring';
899
+					} else if ($type_name == 'resource') {
900
+						$type_name = 'Earth Resources';
901
+					} else if ($type_name == 'stations') {
902
+						$type_name = 'Space Stations';
903
+					} else if ($type_name == 'geo') {
904
+						$type_name = 'Geostationary';
905
+					} else if ($type_name == 'amateur') {
906
+						$type_name = 'Amateur Radio';
907
+					} else if ($type_name == 'x-comm') {
908
+						$type_name = 'Experimental';
909
+					} else if ($type_name == 'other-comm') {
910
+						$type_name = 'Other Comm';
911
+					} else if ($type_name == 'science') {
912
+						$type_name = 'Space & Earth Science';
913
+					} else if ($type_name == 'military') {
914
+						$type_name = 'Miscellaneous Military';
915
+					} else if ($type_name == 'radar') {
916
+						$type_name = 'Radar Calibration';
917
+					} else if ($type_name == 'tle-new') {
918
+						$type_name = 'Last 30 days launches';
919
+					}
628 920
 					
629 921
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
630 922
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.