Completed
Push — master ( 5eede3...37e7ec )
by Yannick
39:37 queued 09:31
created
require/class.Tracker.php 4 patches
Doc Comments   +2 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	* Get SQL query part for filter used
17 17
 	* @param Array $filter the filter
18
-	* @return Array the SQL part
18
+	* @return string the SQL part
19 19
 	*/
20 20
 	
21 21
 	public function getFilter($filter = array(),$where = false,$and = false) {
@@ -486,9 +486,6 @@  discard block
 block discarded – undo
486 486
 	/**
487 487
 	* Update ident spotter data
488 488
 	*
489
-	* @param String $flightaware_id the ID from flightaware
490
-	* @param String $ident the flight ident
491
-	* @return String success or false
492 489
 	*
493 490
 	*/	
494 491
 	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
@@ -510,10 +507,6 @@  discard block
 block discarded – undo
510 507
 	/**
511 508
 	* Update latest spotter data
512 509
 	*
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 510
 	*
518 511
 	*/	
519 512
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
@@ -535,29 +528,6 @@  discard block
 block discarded – undo
535 528
 	/**
536 529
 	* Adds a new spotter data
537 530
 	*
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 531
 	*/
562 532
 	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
563 533
 	{
@@ -1428,7 +1398,7 @@  discard block
 block discarded – undo
1428 1398
 	/**
1429 1399
 	* Parses the direction degrees to working
1430 1400
 	*
1431
-	* @param Float $direction the direction in degrees
1401
+	* @param integer $direction the direction in degrees
1432 1402
 	* @return Array the direction information
1433 1403
 	*
1434 1404
 	*/
Please login to merge, or discard this patch.
Indentation   +205 added lines, -205 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 trackers that have flown over
1302
-	*
1303
-	* @return Integer the number of trackers
1304
-	*
1305
-	*/
1301
+	 * Counts all trackers that have flown over
1302
+	 *
1303
+	 * @return Integer the number of trackers
1304
+	 *
1305
+	 */
1306 1306
 	public function countOverallTracker($filters = array(),$year = '',$month = '')
1307 1307
 	{
1308 1308
 		global $globalDBdriver;
@@ -1337,11 +1337,11 @@  discard block
 block discarded – undo
1337 1337
 	}
1338 1338
 	
1339 1339
 	/**
1340
-	* Counts all trackers type that have flown over
1341
-	*
1342
-	* @return Integer the number of flights
1343
-	*
1344
-	*/
1340
+	 * Counts all trackers type that have flown over
1341
+	 *
1342
+	 * @return Integer the number of flights
1343
+	 *
1344
+	 */
1345 1345
 	public function countOverallTrackerTypes($filters = array(),$year = '',$month = '')
1346 1346
 	{
1347 1347
 		global $globalDBdriver;
@@ -1376,11 +1376,11 @@  discard block
 block discarded – undo
1376 1376
 	
1377 1377
   
1378 1378
 	/**
1379
-	* Counts all hours of today
1380
-	*
1381
-	* @return Array the hour list
1382
-	*
1383
-	*/
1379
+	 * Counts all hours of today
1380
+	 *
1381
+	 * @return Array the hour list
1382
+	 *
1383
+	 */
1384 1384
 	public function countAllHoursFromToday($filters = array())
1385 1385
 	{
1386 1386
 		global $globalTimezone, $globalDBdriver;
@@ -1420,12 +1420,12 @@  discard block
 block discarded – undo
1420 1420
 	}
1421 1421
     
1422 1422
     
1423
-     /**
1424
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1425
-	*
1426
-	* @return Integer the Barrie Spotter ID
1423
+	 /**
1424
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1425
+	  *
1426
+	  * @return Integer the Barrie Spotter ID
1427 1427
 q	*
1428
-	*/
1428
+	  */
1429 1429
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1430 1430
 	{
1431 1431
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -1446,13 +1446,13 @@  discard block
 block discarded – undo
1446 1446
   
1447 1447
  
1448 1448
 	/**
1449
-	* Parses a date string
1450
-	*
1451
-	* @param String $dateString the date string
1452
-	* @param String $timezone the timezone of a user
1453
-	* @return Array the time information
1454
-	*
1455
-	*/
1449
+	 * Parses a date string
1450
+	 *
1451
+	 * @param String $dateString the date string
1452
+	 * @param String $timezone the timezone of a user
1453
+	 * @return Array the time information
1454
+	 *
1455
+	 */
1456 1456
 	public function parseDateString($dateString, $timezone = '')
1457 1457
 	{
1458 1458
 		$time_array = array();
@@ -1485,12 +1485,12 @@  discard block
 block discarded – undo
1485 1485
 	}
1486 1486
 	
1487 1487
 	/**
1488
-	* Parses the direction degrees to working
1489
-	*
1490
-	* @param Float $direction the direction in degrees
1491
-	* @return Array the direction information
1492
-	*
1493
-	*/
1488
+	 * Parses the direction degrees to working
1489
+	 *
1490
+	 * @param Float $direction the direction in degrees
1491
+	 * @return Array the direction information
1492
+	 *
1493
+	 */
1494 1494
 	public function parseDirection($direction = 0)
1495 1495
 	{
1496 1496
 		if ($direction == '') $direction = 0;
@@ -1569,12 +1569,12 @@  discard block
 block discarded – undo
1569 1569
 	
1570 1570
 	
1571 1571
 	/**
1572
-	* Gets Country from latitude/longitude
1573
-	*
1574
-	* @param Float $latitude latitute of the flight
1575
-	* @param Float $longitude longitute of the flight
1576
-	* @return String the countrie
1577
-	*/
1572
+	 * Gets Country from latitude/longitude
1573
+	 *
1574
+	 * @param Float $latitude latitute of the flight
1575
+	 * @param Float $longitude longitute of the flight
1576
+	 * @return String the countrie
1577
+	 */
1578 1578
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1579 1579
 	{
1580 1580
 		global $globalDBdriver, $globalDebug;
@@ -1611,11 +1611,11 @@  discard block
 block discarded – undo
1611 1611
 	}
1612 1612
 
1613 1613
 	/**
1614
-	* Gets Country from iso2
1615
-	*
1616
-	* @param String $iso2 ISO2 country code
1617
-	* @return String the countrie
1618
-	*/
1614
+	 * Gets Country from iso2
1615
+	 *
1616
+	 * @param String $iso2 ISO2 country code
1617
+	 * @return String the countrie
1618
+	 */
1619 1619
 	public function getCountryFromISO2($iso2)
1620 1620
 	{
1621 1621
 		global $globalDBdriver, $globalDebug;
@@ -1643,11 +1643,11 @@  discard block
 block discarded – undo
1643 1643
 	}
1644 1644
 
1645 1645
 	/**
1646
-	* Gets all vessels types that have flown over
1647
-	*
1648
-	* @return Array the vessel type list
1649
-	*
1650
-	*/
1646
+	 * Gets all vessels types that have flown over
1647
+	 *
1648
+	 * @return Array the vessel type list
1649
+	 *
1650
+	 */
1651 1651
 	public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1652 1652
 	{
1653 1653
 		global $globalDBdriver;
@@ -1714,12 +1714,12 @@  discard block
 block discarded – undo
1714 1714
 
1715 1715
 	
1716 1716
 	/**
1717
-	* Gets the short url from bit.ly
1718
-	*
1719
-	* @param String $url the full url
1720
-	* @return String the bit.ly url
1721
-	*
1722
-	*/
1717
+	 * Gets the short url from bit.ly
1718
+	 *
1719
+	 * @param String $url the full url
1720
+	 * @return String the bit.ly url
1721
+	 *
1722
+	 */
1723 1723
 	public function getBitlyURL($url)
1724 1724
 	{
1725 1725
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
Spacing   +161 added lines, -161 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) {
@@ -19,33 +19,33 @@  discard block
 block discarded – undo
19 19
 	* @return Array the SQL part
20 20
 	*/
21 21
 	
22
-	public function getFilter($filter = array(),$where = false,$and = false) {
22
+	public function getFilter($filter = array(), $where = false, $and = false) {
23 23
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
24 24
 		$filters = array();
25 25
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
26 26
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
27 27
 				$filters = $globalStatsFilters[$globalFilterName];
28 28
 			} else {
29
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
29
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
30 30
 			}
31 31
 		}
32 32
 		if (isset($filter[0]['source'])) {
33
-			$filters = array_merge($filters,$filter);
33
+			$filters = array_merge($filters, $filter);
34 34
 		}
35
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
36 36
 		$filter_query_join = '';
37 37
 		$filter_query_where = '';
38
-		foreach($filters as $flt) {
38
+		foreach ($filters as $flt) {
39 39
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
40 40
 				if (isset($flt['source'])) {
41
-					$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
+					$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";
42 42
 				} else {
43
-					$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
+					$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";
44 44
 				}
45 45
 			}
46 46
 		}
47 47
 		if (isset($filter['source']) && !empty($filter['source'])) {
48
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
48
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
49 49
 		}
50 50
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
51 51
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
75 75
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
76 76
 		if ($filter_query_where != '') {
77
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
77
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
78 78
 		}
79 79
 		$filter_query = $filter_query_join.$filter_query_where;
80 80
 		return $filter_query;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	* @return Array the spotter information
90 90
 	*
91 91
 	*/
92
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
92
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
93 93
 	{
94 94
 		date_default_timezone_set('UTC');
95 95
 		if (!is_string($query))
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 			$sth = $this->db->prepare($query.$limitQuery);
110 110
 			$sth->execute($params);
111 111
 		} catch (PDOException $e) {
112
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
112
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
113 113
 			exit();
114 114
 		}
115 115
 		
116 116
 		$num_rows = 0;
117 117
 		$spotter_array = array();
118
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
118
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
119 119
 		{
120 120
 			$num_rows++;
121 121
 			$temp_array = array();
@@ -171,17 +171,17 @@  discard block
 block discarded – undo
171 171
 				{
172 172
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
173 173
 				} else {
174
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
174
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
175 175
 				}
176 176
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
177
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
178
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
177
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
178
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
179 179
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
180 180
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
181 181
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
182 182
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
183
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
184
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
183
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
184
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
185 185
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
186 186
 					}
187 187
 				}
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 		{
219 219
 			$limit_array = explode(",", $limit);
220 220
 			
221
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
222
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
221
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
222
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
223 223
 			
224 224
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
225 225
 			{
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 			$orderby_query = " ORDER BY tracker_output.date DESC";
237 237
 		}
238 238
 
239
-		$query  = $global_query.$filter_query." ".$orderby_query;
239
+		$query = $global_query.$filter_query." ".$orderby_query;
240 240
 
241
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
241
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
242 242
 
243 243
 		return $spotter_array;
244 244
 	}
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 		if ($id == '') return array();
258 258
 		$additional_query = "tracker_output.famtrackid = :id";
259 259
 		$query_values = array(':id' => $id);
260
-		$query  = $global_query." WHERE ".$additional_query." ";
261
-		$spotter_array = $this->getDataFromDB($query,$query_values);
260
+		$query = $global_query." WHERE ".$additional_query." ";
261
+		$spotter_array = $this->getDataFromDB($query, $query_values);
262 262
 		return $spotter_array;
263 263
 	}
264 264
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 		$query_values = array();
278 278
 		$limit_query = '';
279 279
 		$additional_query = '';
280
-		$filter_query = $this->getFilter($filter,true,true);
280
+		$filter_query = $this->getFilter($filter, true, true);
281 281
 		if ($ident != "")
282 282
 		{
283 283
 			if (!is_string($ident))
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 		{
294 294
 			$limit_array = explode(",", $limit);
295 295
 			
296
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
297
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
296
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
297
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
298 298
 			
299 299
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
300 300
 			{
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 		return $spotter_array;
319 319
 	}
320 320
 	
321
-	public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array())
321
+	public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array())
322 322
 	{
323 323
 		global $global_query, $globalTimezone, $globalDBdriver;
324 324
 		
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		$limit_query = '';
327 327
 		$additional_query = '';
328 328
 
329
-		$filter_query = $this->getFilter($filter,true,true);
329
+		$filter_query = $this->getFilter($filter, true, true);
330 330
 		
331 331
 		if ($date != "")
332 332
 		{
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 		{
353 353
 			$limit_array = explode(",", $limit);
354 354
 			
355
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
356
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
355
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
356
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
357 357
 			
358 358
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
359 359
 			{
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 	* @return Array list of source name
385 385
 	*
386 386
 	*/
387
-	public function getAllSourceName($type = '',$filters = array())
387
+	public function getAllSourceName($type = '', $filters = array())
388 388
 	{
389
-		$filter_query = $this->getFilter($filters,true,true);
389
+		$filter_query = $this->getFilter($filters, true, true);
390 390
 		$query_values = array();
391
-		$query  = "SELECT DISTINCT tracker_output.source_name 
391
+		$query = "SELECT DISTINCT tracker_output.source_name 
392 392
 				FROM tracker_output".$filter_query." tracker_output.source_name <> ''";
393 393
 		if ($type != '') {
394 394
 			$query_values = array(':type' => $type);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 		$source_array = array();
404 404
 		$temp_array = array();
405 405
 		
406
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
406
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
407 407
 		{
408 408
 			$temp_array['source_name'] = $row['source_name'];
409 409
 			$source_array[] = $temp_array;
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	*/
421 421
 	public function getAllIdents($filters = array())
422 422
 	{
423
-		$filter_query = $this->getFilter($filters,true,true);
424
-		$query  = "SELECT DISTINCT tracker_output.ident
423
+		$filter_query = $this->getFilter($filters, true, true);
424
+		$query = "SELECT DISTINCT tracker_output.ident
425 425
 								FROM tracker_output".$filter_query." tracker_output.ident <> '' 
426 426
 								ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0";
427 427
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 		$ident_array = array();
432 432
 		$temp_array = array();
433 433
 		
434
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
434
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
435 435
 		{
436 436
 			$temp_array['ident'] = $row['ident'];
437 437
 			$ident_array[] = $temp_array;
@@ -456,12 +456,12 @@  discard block
 block discarded – undo
456 456
 		} else $offset = '+00:00';
457 457
 
458 458
 		if ($globalDBdriver == 'mysql') {
459
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
459
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
460 460
 								FROM tracker_output
461 461
 								WHERE tracker_output.date <> '' 
462 462
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
463 463
 		} else {
464
-			$query  = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
464
+			$query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
465 465
 								FROM tracker_output
466 466
 								WHERE tracker_output.date <> '' 
467 467
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 		$date_array = array();
474 474
 		$temp_array = array();
475 475
 		
476
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
476
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
477 477
 		{
478 478
 			$temp_array['date'] = $row['date'];
479 479
 
@@ -492,11 +492,11 @@  discard block
 block discarded – undo
492 492
 	* @return String success or false
493 493
 	*
494 494
 	*/	
495
-	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
495
+	public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL)
496 496
 	{
497 497
 
498 498
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
499
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
499
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident);
500 500
 
501 501
 		try {
502 502
 			$sth = $this->db->prepare($query);
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
521 521
 	{
522 522
 		$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';
523
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
523
+                $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
524 524
 
525 525
 		try {
526 526
 			$sth = $this->db->prepare($query);
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	* @param String $verticalrate vertival rate of flight
561 561
 	* @return String success or false
562 562
 	*/
563
-	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
563
+	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '')
564 564
 	{
565 565
 		global $globalURL;
566 566
 		
@@ -628,21 +628,21 @@  discard block
 block discarded – undo
628 628
 		}
629 629
 
630 630
     
631
-		if ($date == "" || strtotime($date) < time()-20*60)
631
+		if ($date == "" || strtotime($date) < time() - 20*60)
632 632
 		{
633 633
 			$date = date("Y-m-d H:i:s", time());
634 634
 		}
635 635
 
636
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
637
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
638
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
639
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
640
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
641
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
642
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
643
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
644
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
645
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
636
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
637
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
638
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
639
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
640
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
641
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
642
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
643
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
644
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
645
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
646 646
 	
647 647
                 if ($latitude == '' && $longitude == '') {
648 648
             		$latitude = 0;
@@ -650,10 +650,10 @@  discard block
 block discarded – undo
650 650
             	}
651 651
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
652 652
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
653
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
653
+                $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
654 654
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
655 655
 
656
-                $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
+                $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);
657 657
 
658 658
 		try {
659 659
 		        
@@ -679,13 +679,13 @@  discard block
 block discarded – undo
679 679
 	{
680 680
 		global $globalDBdriver, $globalTimezone;
681 681
 		if ($globalDBdriver == 'mysql') {
682
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
682
+			$query = "SELECT tracker_output.ident FROM tracker_output 
683 683
 								WHERE tracker_output.ident = :ident 
684 684
 								AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
685 685
 								AND tracker_output.date < UTC_TIMESTAMP()";
686 686
 			$query_data = array(':ident' => $ident);
687 687
 		} else {
688
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
688
+			$query = "SELECT tracker_output.ident FROM tracker_output 
689 689
 								WHERE tracker_output.ident = :ident 
690 690
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
691 691
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
 		
695 695
 		$sth = $this->db->prepare($query);
696 696
 		$sth->execute($query_data);
697
-    		$ident_result='';
698
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
697
+    		$ident_result = '';
698
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
699 699
 		{
700 700
 			$ident_result = $row['ident'];
701 701
 		}
@@ -721,8 +721,8 @@  discard block
 block discarded – undo
721 721
 				return false;
722 722
 			} else {
723 723
 				$q_array = explode(" ", $q);
724
-				foreach ($q_array as $q_item){
725
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
724
+				foreach ($q_array as $q_item) {
725
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
726 726
 					$additional_query .= " AND (";
727 727
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%')";
728 728
 					$additional_query .= ")";
@@ -730,11 +730,11 @@  discard block
 block discarded – undo
730 730
 			}
731 731
 		}
732 732
 		if ($globalDBdriver == 'mysql') {
733
-			$query  = "SELECT tracker_output.* FROM tracker_output 
733
+			$query = "SELECT tracker_output.* FROM tracker_output 
734 734
 				WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
735 735
 				AND tracker_output.date < UTC_TIMESTAMP()";
736 736
 		} else {
737
-			$query  = "SELECT tracker_output.* FROM tracker_output 
737
+			$query = "SELECT tracker_output.* FROM tracker_output 
738 738
 				WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
739 739
 				AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
740 740
 		}
@@ -753,16 +753,16 @@  discard block
 block discarded – undo
753 753
 	*
754 754
 	*/
755 755
 
756
-	public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
756
+	public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
757 757
 	{
758 758
 		global $globalDBdriver, $globalArchive;
759 759
 		//$filter_query = $this->getFilter($filters,true,true);
760
-		$Connection= new Connection($this->db);
760
+		$Connection = new Connection($this->db);
761 761
 		if (!$Connection->tableExists('countries')) return array();
762 762
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
763 763
 			require_once('class.TrackerLive.php');
764 764
 			$TrackerLive = new TrackerLive($this->db);
765
-			$filter_query = $TrackerLive->getFilter($filters,true,true);
765
+			$filter_query = $TrackerLive->getFilter($filters, true, true);
766 766
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
767 767
 			if ($olderthanmonths > 0) {
768 768
 				if ($globalDBdriver == 'mysql') {
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 		} else {
783 783
 			require_once('class.TrackerArchive.php');
784 784
 			$TrackerArchive = new TrackerArchive($this->db);
785
-			$filter_query = $TrackerArchive->getFilter($filters,true,true);
785
+			$filter_query = $TrackerArchive->getFilter($filters, true, true);
786 786
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
787 787
 			if ($olderthanmonths > 0) {
788 788
 				if ($globalDBdriver == 'mysql') {
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 		$flight_array = array();
811 811
 		$temp_array = array();
812 812
         
813
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
813
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
814 814
 		{
815 815
 			$temp_array['flight_count'] = $row['nb'];
816 816
 			$temp_array['flight_country'] = $row['name'];
@@ -827,11 +827,11 @@  discard block
 block discarded – undo
827 827
 	* @return Array the callsign list
828 828
 	*
829 829
 	*/
830
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
830
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
831 831
 	{
832 832
 		global $globalDBdriver;
833
-		$filter_query = $this->getFilter($filters,true,true);
834
-		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
833
+		$filter_query = $this->getFilter($filters, true, true);
834
+		$query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
835 835
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
836 836
 		 if ($olderthanmonths > 0) {
837 837
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -845,28 +845,28 @@  discard block
 block discarded – undo
845 845
 		if ($year != '') {
846 846
 			if ($globalDBdriver == 'mysql') {
847 847
 				$query .= " AND YEAR(tracker_output.date) = :year";
848
-				$query_values = array_merge($query_values,array(':year' => $year));
848
+				$query_values = array_merge($query_values, array(':year' => $year));
849 849
 			} else {
850 850
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
851
-				$query_values = array_merge($query_values,array(':year' => $year));
851
+				$query_values = array_merge($query_values, array(':year' => $year));
852 852
 			}
853 853
 		}
854 854
 		if ($month != '') {
855 855
 			if ($globalDBdriver == 'mysql') {
856 856
 				$query .= " AND MONTH(tracker_output.date) = :month";
857
-				$query_values = array_merge($query_values,array(':month' => $month));
857
+				$query_values = array_merge($query_values, array(':month' => $month));
858 858
 			} else {
859 859
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
860
-				$query_values = array_merge($query_values,array(':month' => $month));
860
+				$query_values = array_merge($query_values, array(':month' => $month));
861 861
 			}
862 862
 		}
863 863
 		if ($day != '') {
864 864
 			if ($globalDBdriver == 'mysql') {
865 865
 				$query .= " AND DAY(tracker_output.date) = :day";
866
-				$query_values = array_merge($query_values,array(':day' => $day));
866
+				$query_values = array_merge($query_values, array(':day' => $day));
867 867
 			} else {
868 868
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
869
-				$query_values = array_merge($query_values,array(':day' => $day));
869
+				$query_values = array_merge($query_values, array(':day' => $day));
870 870
 			}
871 871
 		}
872 872
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 		$callsign_array = array();
879 879
 		$temp_array = array();
880 880
         
881
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
881
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
882 882
 		{
883 883
 			$temp_array['callsign_icao'] = $row['ident'];
884 884
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 		$date_array = array();
931 931
 		$temp_array = array();
932 932
         
933
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
933
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
934 934
 		{
935 935
 			$temp_array['date_name'] = $row['date_name'];
936 936
 			$temp_array['date_count'] = $row['date_count'];
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 			$datetime = new DateTime();
957 957
 			$offset = $datetime->format('P');
958 958
 		} else $offset = '+00:00';
959
-		$filter_query = $this->getFilter($filters,true,true);
959
+		$filter_query = $this->getFilter($filters, true, true);
960 960
 		if ($globalDBdriver == 'mysql') {
961 961
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
962 962
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 		$date_array = array();
978 978
 		$temp_array = array();
979 979
         
980
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
980
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
981 981
 		{
982 982
 			$temp_array['date_name'] = $row['date_name'];
983 983
 			$temp_array['date_count'] = $row['date_count'];
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 			$datetime = new DateTime();
1003 1003
 			$offset = $datetime->format('P');
1004 1004
 		} else $offset = '+00:00';
1005
-		$filter_query = $this->getFilter($filters,true,true);
1005
+		$filter_query = $this->getFilter($filters, true, true);
1006 1006
 		if ($globalDBdriver == 'mysql') {
1007 1007
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1008 1008
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 		$date_array = array();
1024 1024
 		$temp_array = array();
1025 1025
         
1026
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1026
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1027 1027
 		{
1028 1028
 			$temp_array['date_name'] = $row['date_name'];
1029 1029
 			$temp_array['date_count'] = $row['date_count'];
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 		$date_array = array();
1071 1071
 		$temp_array = array();
1072 1072
         
1073
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1073
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1074 1074
 		{
1075 1075
 			$temp_array['month_name'] = $row['month_name'];
1076 1076
 			$temp_array['year_name'] = $row['year_name'];
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 			$datetime = new DateTime();
1100 1100
 			$offset = $datetime->format('P');
1101 1101
 		} else $offset = '+00:00';
1102
-		$filter_query = $this->getFilter($filters,true,true);
1102
+		$filter_query = $this->getFilter($filters, true, true);
1103 1103
 		if ($globalDBdriver == 'mysql') {
1104 1104
 			$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
1105 1105
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 		$date_array = array();
1121 1121
 		$temp_array = array();
1122 1122
         
1123
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1123
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1124 1124
 		{
1125 1125
 			$temp_array['year_name'] = $row['year_name'];
1126 1126
 			$temp_array['month_name'] = $row['month_name'];
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 	* @return Array the hour list
1141 1141
 	*
1142 1142
 	*/
1143
-	public function countAllHours($orderby,$filters = array())
1143
+	public function countAllHours($orderby, $filters = array())
1144 1144
 	{
1145 1145
 		global $globalTimezone, $globalDBdriver;
1146 1146
 		if ($globalTimezone != '') {
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 		$hour_array = array();
1189 1189
 		$temp_array = array();
1190 1190
         
1191
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1191
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1192 1192
 		{
1193 1193
 			$temp_array['hour_name'] = $row['hour_name'];
1194 1194
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1210,8 +1210,8 @@  discard block
 block discarded – undo
1210 1210
 	public function countAllHoursByDate($date, $filters = array())
1211 1211
 	{
1212 1212
 		global $globalTimezone, $globalDBdriver;
1213
-		$filter_query = $this->getFilter($filters,true,true);
1214
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1213
+		$filter_query = $this->getFilter($filters, true, true);
1214
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1215 1215
 		if ($globalTimezone != '') {
1216 1216
 			date_default_timezone_set($globalTimezone);
1217 1217
 			$datetime = new DateTime($date);
@@ -1219,12 +1219,12 @@  discard block
 block discarded – undo
1219 1219
 		} else $offset = '+00:00';
1220 1220
 
1221 1221
 		if ($globalDBdriver == 'mysql') {
1222
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1222
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1223 1223
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date
1224 1224
 								GROUP BY hour_name 
1225 1225
 								ORDER BY hour_name ASC";
1226 1226
 		} else {
1227
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1227
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1228 1228
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1229 1229
 								GROUP BY hour_name 
1230 1230
 								ORDER BY hour_name ASC";
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 		$hour_array = array();
1237 1237
 		$temp_array = array();
1238 1238
         
1239
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1239
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1240 1240
 		{
1241 1241
 			$temp_array['hour_name'] = $row['hour_name'];
1242 1242
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1258,8 +1258,8 @@  discard block
 block discarded – undo
1258 1258
 	public function countAllHoursByIdent($ident, $filters = array())
1259 1259
 	{
1260 1260
 		global $globalTimezone, $globalDBdriver;
1261
-		$filter_query = $this->getFilter($filters,true,true);
1262
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1261
+		$filter_query = $this->getFilter($filters, true, true);
1262
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1263 1263
 		if ($globalTimezone != '') {
1264 1264
 			date_default_timezone_set($globalTimezone);
1265 1265
 			$datetime = new DateTime();
@@ -1267,12 +1267,12 @@  discard block
 block discarded – undo
1267 1267
 		} else $offset = '+00:00';
1268 1268
 
1269 1269
 		if ($globalDBdriver == 'mysql') {
1270
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1270
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1271 1271
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1272 1272
 								GROUP BY hour_name 
1273 1273
 								ORDER BY hour_name ASC";
1274 1274
 		} else {
1275
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1275
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1276 1276
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1277 1277
 								GROUP BY hour_name 
1278 1278
 								ORDER BY hour_name ASC";
@@ -1280,12 +1280,12 @@  discard block
 block discarded – undo
1280 1280
       
1281 1281
 		
1282 1282
 		$sth = $this->db->prepare($query);
1283
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1283
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1284 1284
       
1285 1285
 		$hour_array = array();
1286 1286
 		$temp_array = array();
1287 1287
         
1288
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1288
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1289 1289
 		{
1290 1290
 			$temp_array['hour_name'] = $row['hour_name'];
1291 1291
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1304,33 +1304,33 @@  discard block
 block discarded – undo
1304 1304
 	* @return Integer the number of trackers
1305 1305
 	*
1306 1306
 	*/
1307
-	public function countOverallTracker($filters = array(),$year = '',$month = '')
1307
+	public function countOverallTracker($filters = array(), $year = '', $month = '')
1308 1308
 	{
1309 1309
 		global $globalDBdriver;
1310 1310
 		//$queryi  = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1311
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output";
1311
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output";
1312 1312
 		$query_values = array();
1313 1313
 		$query = '';
1314 1314
 		if ($year != '') {
1315 1315
 			if ($globalDBdriver == 'mysql') {
1316 1316
 				$query .= " AND YEAR(tracker_output.date) = :year";
1317
-				$query_values = array_merge($query_values,array(':year' => $year));
1317
+				$query_values = array_merge($query_values, array(':year' => $year));
1318 1318
 			} else {
1319 1319
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1320
-				$query_values = array_merge($query_values,array(':year' => $year));
1320
+				$query_values = array_merge($query_values, array(':year' => $year));
1321 1321
 			}
1322 1322
 		}
1323 1323
 		if ($month != '') {
1324 1324
 			if ($globalDBdriver == 'mysql') {
1325 1325
 				$query .= " AND MONTH(tracker_output.date) = :month";
1326
-				$query_values = array_merge($query_values,array(':month' => $month));
1326
+				$query_values = array_merge($query_values, array(':month' => $month));
1327 1327
 			} else {
1328 1328
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1329
-				$query_values = array_merge($query_values,array(':month' => $month));
1329
+				$query_values = array_merge($query_values, array(':month' => $month));
1330 1330
 			}
1331 1331
 		}
1332 1332
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1333
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1333
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1334 1334
 		
1335 1335
 		$sth = $this->db->prepare($queryi);
1336 1336
 		$sth->execute($query_values);
@@ -1343,32 +1343,32 @@  discard block
 block discarded – undo
1343 1343
 	* @return Integer the number of flights
1344 1344
 	*
1345 1345
 	*/
1346
-	public function countOverallTrackerTypes($filters = array(),$year = '',$month = '')
1346
+	public function countOverallTrackerTypes($filters = array(), $year = '', $month = '')
1347 1347
 	{
1348 1348
 		global $globalDBdriver;
1349
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output";
1349
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output";
1350 1350
 		$query_values = array();
1351 1351
 		$query = '';
1352 1352
 		if ($year != '') {
1353 1353
 			if ($globalDBdriver == 'mysql') {
1354 1354
 				$query .= " AND YEAR(tracker_output.date) = :year";
1355
-				$query_values = array_merge($query_values,array(':year' => $year));
1355
+				$query_values = array_merge($query_values, array(':year' => $year));
1356 1356
 			} else {
1357 1357
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1358
-				$query_values = array_merge($query_values,array(':year' => $year));
1358
+				$query_values = array_merge($query_values, array(':year' => $year));
1359 1359
 			}
1360 1360
 		}
1361 1361
 		if ($month != '') {
1362 1362
 			if ($globalDBdriver == 'mysql') {
1363 1363
 				$query .= " AND MONTH(tracker_output.date) = :month";
1364
-				$query_values = array_merge($query_values,array(':month' => $month));
1364
+				$query_values = array_merge($query_values, array(':month' => $month));
1365 1365
 			} else {
1366 1366
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1367
-				$query_values = array_merge($query_values,array(':month' => $month));
1367
+				$query_values = array_merge($query_values, array(':month' => $month));
1368 1368
 			}
1369 1369
 		}
1370 1370
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1371
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1371
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1372 1372
 		
1373 1373
 		$sth = $this->db->prepare($queryi);
1374 1374
 		$sth->execute($query_values);
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 	public function countAllHoursFromToday($filters = array())
1386 1386
 	{
1387 1387
 		global $globalTimezone, $globalDBdriver;
1388
-		$filter_query = $this->getFilter($filters,true,true);
1388
+		$filter_query = $this->getFilter($filters, true, true);
1389 1389
 		if ($globalTimezone != '') {
1390 1390
 			date_default_timezone_set($globalTimezone);
1391 1391
 			$datetime = new DateTime();
@@ -1393,12 +1393,12 @@  discard block
 block discarded – undo
1393 1393
 		} else $offset = '+00:00';
1394 1394
 
1395 1395
 		if ($globalDBdriver == 'mysql') {
1396
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1396
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1397 1397
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE()
1398 1398
 								GROUP BY hour_name 
1399 1399
 								ORDER BY hour_name ASC";
1400 1400
 		} else {
1401
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1401
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1402 1402
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1403 1403
 								GROUP BY hour_name 
1404 1404
 								ORDER BY hour_name ASC";
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 		$hour_array = array();
1411 1411
 		$temp_array = array();
1412 1412
         
1413
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1413
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1414 1414
 		{
1415 1415
 			$temp_array['hour_name'] = $row['hour_name'];
1416 1416
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1429,9 +1429,9 @@  discard block
 block discarded – undo
1429 1429
 	*/
1430 1430
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1431 1431
 	{
1432
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
1432
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
1433 1433
 
1434
-		$query  = "SELECT tracker_output.tracker_id
1434
+		$query = "SELECT tracker_output.tracker_id
1435 1435
 				FROM tracker_output 
1436 1436
 				WHERE tracker_output.famtrackid = '".$famtrackid."'";
1437 1437
         
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
 		$sth = $this->db->prepare($query);
1440 1440
 		$sth->execute();
1441 1441
 
1442
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1442
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1443 1443
 		{
1444 1444
 			return $row['tracker_id'];
1445 1445
 		}
@@ -1464,23 +1464,23 @@  discard block
 block discarded – undo
1464 1464
 		}
1465 1465
 		
1466 1466
 		$current_date = date("Y-m-d H:i:s");
1467
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1467
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1468 1468
 		
1469 1469
 		$diff = abs(strtotime($current_date) - strtotime($date));
1470 1470
 
1471
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1471
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1472 1472
 		$years = $time_array['years'];
1473 1473
 		
1474
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1474
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1475 1475
 		$months = $time_array['months'];
1476 1476
 		
1477
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1477
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1478 1478
 		$days = $time_array['days'];
1479
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1479
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1480 1480
 		$hours = $time_array['hours'];
1481
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1481
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1482 1482
 		$minutes = $time_array['minutes'];
1483
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1483
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1484 1484
 		
1485 1485
 		return $time_array;
1486 1486
 	}
@@ -1503,63 +1503,63 @@  discard block
 block discarded – undo
1503 1503
 			$temp_array['direction_degree'] = $direction;
1504 1504
 			$temp_array['direction_shortname'] = "N";
1505 1505
 			$temp_array['direction_fullname'] = "North";
1506
-		} elseif ($direction >= 22.5 && $direction < 45){
1506
+		} elseif ($direction >= 22.5 && $direction < 45) {
1507 1507
 			$temp_array['direction_degree'] = $direction;
1508 1508
 			$temp_array['direction_shortname'] = "NNE";
1509 1509
 			$temp_array['direction_fullname'] = "North-Northeast";
1510
-		} elseif ($direction >= 45 && $direction < 67.5){
1510
+		} elseif ($direction >= 45 && $direction < 67.5) {
1511 1511
 			$temp_array['direction_degree'] = $direction;
1512 1512
 			$temp_array['direction_shortname'] = "NE";
1513 1513
 			$temp_array['direction_fullname'] = "Northeast";
1514
-		} elseif ($direction >= 67.5 && $direction < 90){
1514
+		} elseif ($direction >= 67.5 && $direction < 90) {
1515 1515
 			$temp_array['direction_degree'] = $direction;
1516 1516
 			$temp_array['direction_shortname'] = "ENE";
1517 1517
 			$temp_array['direction_fullname'] = "East-Northeast";
1518
-		} elseif ($direction >= 90 && $direction < 112.5){
1518
+		} elseif ($direction >= 90 && $direction < 112.5) {
1519 1519
 			$temp_array['direction_degree'] = $direction;
1520 1520
 			$temp_array['direction_shortname'] = "E";
1521 1521
 			$temp_array['direction_fullname'] = "East";
1522
-		} elseif ($direction >= 112.5 && $direction < 135){
1522
+		} elseif ($direction >= 112.5 && $direction < 135) {
1523 1523
 			$temp_array['direction_degree'] = $direction;
1524 1524
 			$temp_array['direction_shortname'] = "ESE";
1525 1525
 			$temp_array['direction_fullname'] = "East-Southeast";
1526
-		} elseif ($direction >= 135 && $direction < 157.5){
1526
+		} elseif ($direction >= 135 && $direction < 157.5) {
1527 1527
 			$temp_array['direction_degree'] = $direction;
1528 1528
 			$temp_array['direction_shortname'] = "SE";
1529 1529
 			$temp_array['direction_fullname'] = "Southeast";
1530
-		} elseif ($direction >= 157.5 && $direction < 180){
1530
+		} elseif ($direction >= 157.5 && $direction < 180) {
1531 1531
 			$temp_array['direction_degree'] = $direction;
1532 1532
 			$temp_array['direction_shortname'] = "SSE";
1533 1533
 			$temp_array['direction_fullname'] = "South-Southeast";
1534
-		} elseif ($direction >= 180 && $direction < 202.5){
1534
+		} elseif ($direction >= 180 && $direction < 202.5) {
1535 1535
 			$temp_array['direction_degree'] = $direction;
1536 1536
 			$temp_array['direction_shortname'] = "S";
1537 1537
 			$temp_array['direction_fullname'] = "South";
1538
-		} elseif ($direction >= 202.5 && $direction < 225){
1538
+		} elseif ($direction >= 202.5 && $direction < 225) {
1539 1539
 			$temp_array['direction_degree'] = $direction;
1540 1540
 			$temp_array['direction_shortname'] = "SSW";
1541 1541
 			$temp_array['direction_fullname'] = "South-Southwest";
1542
-		} elseif ($direction >= 225 && $direction < 247.5){
1542
+		} elseif ($direction >= 225 && $direction < 247.5) {
1543 1543
 			$temp_array['direction_degree'] = $direction;
1544 1544
 			$temp_array['direction_shortname'] = "SW";
1545 1545
 			$temp_array['direction_fullname'] = "Southwest";
1546
-		} elseif ($direction >= 247.5 && $direction < 270){
1546
+		} elseif ($direction >= 247.5 && $direction < 270) {
1547 1547
 			$temp_array['direction_degree'] = $direction;
1548 1548
 			$temp_array['direction_shortname'] = "WSW";
1549 1549
 			$temp_array['direction_fullname'] = "West-Southwest";
1550
-		} elseif ($direction >= 270 && $direction < 292.5){
1550
+		} elseif ($direction >= 270 && $direction < 292.5) {
1551 1551
 			$temp_array['direction_degree'] = $direction;
1552 1552
 			$temp_array['direction_shortname'] = "W";
1553 1553
 			$temp_array['direction_fullname'] = "West";
1554
-		} elseif ($direction >= 292.5 && $direction < 315){
1554
+		} elseif ($direction >= 292.5 && $direction < 315) {
1555 1555
 			$temp_array['direction_degree'] = $direction;
1556 1556
 			$temp_array['direction_shortname'] = "WNW";
1557 1557
 			$temp_array['direction_fullname'] = "West-Northwest";
1558
-		} elseif ($direction >= 315 && $direction < 337.5){
1558
+		} elseif ($direction >= 315 && $direction < 337.5) {
1559 1559
 			$temp_array['direction_degree'] = $direction;
1560 1560
 			$temp_array['direction_shortname'] = "NW";
1561 1561
 			$temp_array['direction_fullname'] = "Northwest";
1562
-		} elseif ($direction >= 337.5 && $direction < 360){
1562
+		} elseif ($direction >= 337.5 && $direction < 360) {
1563 1563
 			$temp_array['direction_degree'] = $direction;
1564 1564
 			$temp_array['direction_shortname'] = "NNW";
1565 1565
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1576,11 +1576,11 @@  discard block
 block discarded – undo
1576 1576
 	* @param Float $longitude longitute of the flight
1577 1577
 	* @return String the countrie
1578 1578
 	*/
1579
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1579
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1580 1580
 	{
1581 1581
 		global $globalDBdriver, $globalDebug;
1582
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1583
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1582
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1583
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1584 1584
 	
1585 1585
 		$Connection = new Connection($this->db);
1586 1586
 		if (!$Connection->tableExists('countries')) return '';
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
 	public function getCountryFromISO2($iso2)
1621 1621
 	{
1622 1622
 		global $globalDBdriver, $globalDebug;
1623
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1623
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1624 1624
 	
1625 1625
 		$Connection = new Connection($this->db);
1626 1626
 		if (!$Connection->tableExists('countries')) return '';
@@ -1649,11 +1649,11 @@  discard block
 block discarded – undo
1649 1649
 	* @return Array the vessel type list
1650 1650
 	*
1651 1651
 	*/
1652
-	public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1652
+	public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1653 1653
 	{
1654 1654
 		global $globalDBdriver;
1655
-		$filter_query = $this->getFilter($filters,true,true);
1656
-		$query  = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count 
1655
+		$filter_query = $this->getFilter($filters, true, true);
1656
+		$query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count 
1657 1657
 		    FROM tracker_output ".$filter_query." tracker_output.type  <> ''";
1658 1658
 		if ($olderthanmonths > 0) {
1659 1659
 			if ($globalDBdriver == 'mysql') {
@@ -1673,28 +1673,28 @@  discard block
 block discarded – undo
1673 1673
 		if ($year != '') {
1674 1674
 			if ($globalDBdriver == 'mysql') {
1675 1675
 				$query .= " AND YEAR(tracker_output.date) = :year";
1676
-				$query_values = array_merge($query_values,array(':year' => $year));
1676
+				$query_values = array_merge($query_values, array(':year' => $year));
1677 1677
 			} else {
1678 1678
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1679
-				$query_values = array_merge($query_values,array(':year' => $year));
1679
+				$query_values = array_merge($query_values, array(':year' => $year));
1680 1680
 			}
1681 1681
 		}
1682 1682
 		if ($month != '') {
1683 1683
 			if ($globalDBdriver == 'mysql') {
1684 1684
 				$query .= " AND MONTH(tracker_output.date) = :month";
1685
-				$query_values = array_merge($query_values,array(':month' => $month));
1685
+				$query_values = array_merge($query_values, array(':month' => $month));
1686 1686
 			} else {
1687 1687
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1688
-				$query_values = array_merge($query_values,array(':month' => $month));
1688
+				$query_values = array_merge($query_values, array(':month' => $month));
1689 1689
 			}
1690 1690
 		}
1691 1691
 		if ($day != '') {
1692 1692
 			if ($globalDBdriver == 'mysql') {
1693 1693
 				$query .= " AND DAY(tracker_output.date) = :day";
1694
-				$query_values = array_merge($query_values,array(':day' => $day));
1694
+				$query_values = array_merge($query_values, array(':day' => $day));
1695 1695
 			} else {
1696 1696
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
1697
-				$query_values = array_merge($query_values,array(':day' => $day));
1697
+				$query_values = array_merge($query_values, array(':day' => $day));
1698 1698
 			}
1699 1699
 		}
1700 1700
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
@@ -1703,7 +1703,7 @@  discard block
 block discarded – undo
1703 1703
 		$sth->execute($query_values);
1704 1704
 		$tracker_array = array();
1705 1705
 		$temp_array = array();
1706
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1706
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1707 1707
 		{
1708 1708
 			$temp_array['tracker_type'] = $row['tracker_type'];
1709 1709
 			$temp_array['tracker_type_count'] = $row['tracker_type_count'];
@@ -1738,7 +1738,7 @@  discard block
 block discarded – undo
1738 1738
 		
1739 1739
 		$bitly_data = json_decode($bitly_data);
1740 1740
 		$bitly_url = '';
1741
-		if ($bitly_data->status_txt = "OK"){
1741
+		if ($bitly_data->status_txt = "OK") {
1742 1742
 			$bitly_url = $bitly_data->data->url;
1743 1743
 		}
1744 1744
 
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
 
1749 1749
 	public function getOrderBy()
1750 1750
 	{
1751
-		$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"));
1751
+		$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"));
1752 1752
 		
1753 1753
 		return $orderby;
1754 1754
 		
Please login to merge, or discard this patch.
Braces   +160 added lines, -57 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 	public function __construct($dbc = null) {
11 11
 		$Connection = new Connection($dbc);
12 12
 		$this->db = $Connection->db();
13
-		if ($this->db === null) die('Error: No DB connection. (Tracker)');
13
+		if ($this->db === null) {
14
+			die('Error: No DB connection. (Tracker)');
15
+		}
14 16
 	}
15 17
 
16 18
 	/**
@@ -32,7 +34,9 @@  discard block
 block discarded – undo
32 34
 		if (isset($filter[0]['source'])) {
33 35
 			$filters = array_merge($filters,$filter);
34 36
 		}
35
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
37
+		if (is_array($globalFilter)) {
38
+			$filter = array_merge($filter,$globalFilter);
39
+		}
36 40
 		$filter_query_join = '';
37 41
 		$filter_query_where = '';
38 42
 		foreach($filters as $flt) {
@@ -71,8 +75,11 @@  discard block
 block discarded – undo
71 75
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
72 76
 			}
73 77
 		}
74
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
75
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78
+		if ($filter_query_where == '' && $where) {
79
+			$filter_query_where = ' WHERE';
80
+		} elseif ($filter_query_where != '' && $and) {
81
+			$filter_query_where .= ' AND';
82
+		}
76 83
 		if ($filter_query_where != '') {
77 84
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78 85
 		}
@@ -126,26 +133,43 @@  discard block
 block discarded – undo
126 133
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
127 134
 			} elseif (isset($row['spotter_archive_output_id'])) {
128 135
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
129
-			*/} 
130
-			elseif (isset($row['trackerid'])) {
136
+			*/} elseif (isset($row['trackerid'])) {
131 137
 				$temp_array['trackerid'] = $row['trackerid'];
132 138
 			} else {
133 139
 				$temp_array['trackerid'] = '';
134 140
 			}
135
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
136
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
137
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
141
+			if (isset($row['famtrackid'])) {
142
+				$temp_array['famtrackid'] = $row['famtrackid'];
143
+			}
144
+			if (isset($row['type'])) {
145
+				$temp_array['type'] = $row['type'];
146
+			}
147
+			if (isset($row['comment'])) {
148
+				$temp_array['comment'] = $row['comment'];
149
+			}
138 150
 			$temp_array['ident'] = $row['ident'];
139
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
140
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
141
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
142
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
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
+			}
160
+			if (isset($row['altitude'])) {
161
+				$temp_array['altitude'] = $row['altitude'];
162
+			}
143 163
 			if (isset($row['heading'])) {
144 164
 				$temp_array['heading'] = $row['heading'];
145 165
 				$heading_direction = $this->parseDirection($row['heading']);
146
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
166
+				if (isset($heading_direction[0]['direction_fullname'])) {
167
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
168
+				}
169
+			}
170
+			if (isset($row['ground_speed'])) {
171
+				$temp_array['ground_speed'] = $row['ground_speed'];
147 172
 			}
148
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
149 173
 			
150 174
 			if (isset($row['date'])) {
151 175
 				$dateArray = $this->parseDateString($row['date']);
@@ -188,13 +212,21 @@  discard block
 block discarded – undo
188 212
 			}
189 213
 			
190 214
 			$fromsource = NULL;
191
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
192
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
193
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
215
+			if (isset($row['source_name']) && $row['source_name'] != '') {
216
+				$temp_array['source_name'] = $row['source_name'];
217
+			}
218
+			if (isset($row['over_country']) && $row['over_country'] != '') {
219
+				$temp_array['over_country'] = $row['over_country'];
220
+			}
221
+			if (isset($row['distance']) && $row['distance'] != '') {
222
+				$temp_array['distance'] = $row['distance'];
223
+			}
194 224
 			$temp_array['query_number_rows'] = $num_rows;
195 225
 			$spotter_array[] = $temp_array;
196 226
 		}
197
-		if ($num_rows == 0) return array();
227
+		if ($num_rows == 0) {
228
+			return array();
229
+		}
198 230
 		$spotter_array[0]['query_number_rows'] = $num_rows;
199 231
 		return $spotter_array;
200 232
 	}	
@@ -225,8 +257,12 @@  discard block
 block discarded – undo
225 257
 			{
226 258
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
227 259
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
228
-			} else $limit_query = "";
229
-		} else $limit_query = "";
260
+			} else {
261
+				$limit_query = "";
262
+			}
263
+		} else {
264
+			$limit_query = "";
265
+		}
230 266
 		
231 267
 		if ($sort != "")
232 268
 		{
@@ -254,7 +290,9 @@  discard block
 block discarded – undo
254 290
 		global $global_query;
255 291
 		
256 292
 		date_default_timezone_set('UTC');
257
-		if ($id == '') return array();
293
+		if ($id == '') {
294
+			return array();
295
+		}
258 296
 		$additional_query = "tracker_output.famtrackid = :id";
259 297
 		$query_values = array(':id' => $id);
260 298
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -397,8 +435,11 @@  discard block
 block discarded – undo
397 435
 		$query .= " ORDER BY tracker_output.source_name ASC";
398 436
 
399 437
 		$sth = $this->db->prepare($query);
400
-		if (!empty($query_values)) $sth->execute($query_values);
401
-		else $sth->execute();
438
+		if (!empty($query_values)) {
439
+			$sth->execute($query_values);
440
+		} else {
441
+			$sth->execute();
442
+		}
402 443
 
403 444
 		$source_array = array();
404 445
 		$temp_array = array();
@@ -453,7 +494,9 @@  discard block
 block discarded – undo
453 494
 			date_default_timezone_set($globalTimezone);
454 495
 			$datetime = new DateTime();
455 496
 			$offset = $datetime->format('P');
456
-		} else $offset = '+00:00';
497
+		} else {
498
+			$offset = '+00:00';
499
+		}
457 500
 
458 501
 		if ($globalDBdriver == 'mysql') {
459 502
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -609,7 +652,9 @@  discard block
 block discarded – undo
609 652
 			{
610 653
 				return false;
611 654
 			}
612
-		} else $altitude = 0;
655
+		} else {
656
+			$altitude = 0;
657
+		}
613 658
 		
614 659
 		if ($heading != "")
615 660
 		{
@@ -648,8 +693,12 @@  discard block
 block discarded – undo
648 693
             		$latitude = 0;
649 694
             		$longitude = 0;
650 695
             	}
651
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
652
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
696
+                if ($heading == '' || $Common->isInteger($heading) === false) {
697
+                	$heading = 0;
698
+                }
699
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
700
+                	$groundspeed = 0;
701
+                }
653 702
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
654 703
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
655 704
 
@@ -758,7 +807,9 @@  discard block
 block discarded – undo
758 807
 		global $globalDBdriver, $globalArchive;
759 808
 		//$filter_query = $this->getFilter($filters,true,true);
760 809
 		$Connection= new Connection($this->db);
761
-		if (!$Connection->tableExists('countries')) return array();
810
+		if (!$Connection->tableExists('countries')) {
811
+			return array();
812
+		}
762 813
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
763 814
 			require_once('class.TrackerLive.php');
764 815
 			$TrackerLive = new TrackerLive($this->db);
@@ -801,7 +852,9 @@  discard block
 block discarded – undo
801 852
 			$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 ";
802 853
 		}
803 854
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
804
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
855
+		if ($limit) {
856
+			$query .= " LIMIT 10 OFFSET 0";
857
+		}
805 858
       
806 859
 		
807 860
 		$sth = $this->db->prepare($query);
@@ -834,12 +887,18 @@  discard block
 block discarded – undo
834 887
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
835 888
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
836 889
 		 if ($olderthanmonths > 0) {
837
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
838
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
890
+			if ($globalDBdriver == 'mysql') {
891
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
892
+			} else {
893
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
894
+			}
839 895
 		}
840 896
 		if ($sincedate != '') {
841
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
842
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
897
+			if ($globalDBdriver == 'mysql') {
898
+				$query .= " AND tracker_output.date > '".$sincedate."'";
899
+			} else {
900
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
901
+			}
843 902
 		}
844 903
 		$query_values = array();
845 904
 		if ($year != '') {
@@ -870,7 +929,9 @@  discard block
 block discarded – undo
870 929
 			}
871 930
 		}
872 931
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
873
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
932
+		if ($limit) {
933
+			$query .= " LIMIT 10 OFFSET 0";
934
+		}
874 935
       		
875 936
 		$sth = $this->db->prepare($query);
876 937
 		$sth->execute($query_values);
@@ -905,7 +966,9 @@  discard block
 block discarded – undo
905 966
 			date_default_timezone_set($globalTimezone);
906 967
 			$datetime = new DateTime();
907 968
 			$offset = $datetime->format('P');
908
-		} else $offset = '+00:00';
969
+		} else {
970
+			$offset = '+00:00';
971
+		}
909 972
 
910 973
 		if ($globalDBdriver == 'mysql') {
911 974
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -955,7 +1018,9 @@  discard block
 block discarded – undo
955 1018
 			date_default_timezone_set($globalTimezone);
956 1019
 			$datetime = new DateTime();
957 1020
 			$offset = $datetime->format('P');
958
-		} else $offset = '+00:00';
1021
+		} else {
1022
+			$offset = '+00:00';
1023
+		}
959 1024
 		$filter_query = $this->getFilter($filters,true,true);
960 1025
 		if ($globalDBdriver == 'mysql') {
961 1026
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1001,7 +1066,9 @@  discard block
 block discarded – undo
1001 1066
 			date_default_timezone_set($globalTimezone);
1002 1067
 			$datetime = new DateTime();
1003 1068
 			$offset = $datetime->format('P');
1004
-		} else $offset = '+00:00';
1069
+		} else {
1070
+			$offset = '+00:00';
1071
+		}
1005 1072
 		$filter_query = $this->getFilter($filters,true,true);
1006 1073
 		if ($globalDBdriver == 'mysql') {
1007 1074
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1049,7 +1116,9 @@  discard block
 block discarded – undo
1049 1116
 			date_default_timezone_set($globalTimezone);
1050 1117
 			$datetime = new DateTime();
1051 1118
 			$offset = $datetime->format('P');
1052
-		} else $offset = '+00:00';
1119
+		} else {
1120
+			$offset = '+00:00';
1121
+		}
1053 1122
 
1054 1123
 		if ($globalDBdriver == 'mysql') {
1055 1124
 			$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
@@ -1098,7 +1167,9 @@  discard block
 block discarded – undo
1098 1167
 			date_default_timezone_set($globalTimezone);
1099 1168
 			$datetime = new DateTime();
1100 1169
 			$offset = $datetime->format('P');
1101
-		} else $offset = '+00:00';
1170
+		} else {
1171
+			$offset = '+00:00';
1172
+		}
1102 1173
 		$filter_query = $this->getFilter($filters,true,true);
1103 1174
 		if ($globalDBdriver == 'mysql') {
1104 1175
 			$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
@@ -1147,7 +1218,9 @@  discard block
 block discarded – undo
1147 1218
 			date_default_timezone_set($globalTimezone);
1148 1219
 			$datetime = new DateTime();
1149 1220
 			$offset = $datetime->format('P');
1150
-		} else $offset = '+00:00';
1221
+		} else {
1222
+			$offset = '+00:00';
1223
+		}
1151 1224
 
1152 1225
 		$orderby_sql = '';
1153 1226
 		if ($orderby == "hour")
@@ -1216,7 +1289,9 @@  discard block
 block discarded – undo
1216 1289
 			date_default_timezone_set($globalTimezone);
1217 1290
 			$datetime = new DateTime($date);
1218 1291
 			$offset = $datetime->format('P');
1219
-		} else $offset = '+00:00';
1292
+		} else {
1293
+			$offset = '+00:00';
1294
+		}
1220 1295
 
1221 1296
 		if ($globalDBdriver == 'mysql') {
1222 1297
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1264,7 +1339,9 @@  discard block
 block discarded – undo
1264 1339
 			date_default_timezone_set($globalTimezone);
1265 1340
 			$datetime = new DateTime();
1266 1341
 			$offset = $datetime->format('P');
1267
-		} else $offset = '+00:00';
1342
+		} else {
1343
+			$offset = '+00:00';
1344
+		}
1268 1345
 
1269 1346
 		if ($globalDBdriver == 'mysql') {
1270 1347
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1329,8 +1406,11 @@  discard block
 block discarded – undo
1329 1406
 				$query_values = array_merge($query_values,array(':month' => $month));
1330 1407
 			}
1331 1408
 		}
1332
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1333
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1409
+		if (empty($query_values)) {
1410
+			$queryi .= $this->getFilter($filters);
1411
+		} else {
1412
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1413
+		}
1334 1414
 		
1335 1415
 		$sth = $this->db->prepare($queryi);
1336 1416
 		$sth->execute($query_values);
@@ -1367,8 +1447,11 @@  discard block
 block discarded – undo
1367 1447
 				$query_values = array_merge($query_values,array(':month' => $month));
1368 1448
 			}
1369 1449
 		}
1370
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1371
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1450
+		if (empty($query_values)) {
1451
+			$queryi .= $this->getFilter($filters);
1452
+		} else {
1453
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1454
+		}
1372 1455
 		
1373 1456
 		$sth = $this->db->prepare($queryi);
1374 1457
 		$sth->execute($query_values);
@@ -1390,7 +1473,9 @@  discard block
 block discarded – undo
1390 1473
 			date_default_timezone_set($globalTimezone);
1391 1474
 			$datetime = new DateTime();
1392 1475
 			$offset = $datetime->format('P');
1393
-		} else $offset = '+00:00';
1476
+		} else {
1477
+			$offset = '+00:00';
1478
+		}
1394 1479
 
1395 1480
 		if ($globalDBdriver == 'mysql') {
1396 1481
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1494,7 +1579,9 @@  discard block
 block discarded – undo
1494 1579
 	*/
1495 1580
 	public function parseDirection($direction = 0)
1496 1581
 	{
1497
-		if ($direction == '') $direction = 0;
1582
+		if ($direction == '') {
1583
+			$direction = 0;
1584
+		}
1498 1585
 		$direction_array = array();
1499 1586
 		$temp_array = array();
1500 1587
 
@@ -1583,7 +1670,9 @@  discard block
 block discarded – undo
1583 1670
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1584 1671
 	
1585 1672
 		$Connection = new Connection($this->db);
1586
-		if (!$Connection->tableExists('countries')) return '';
1673
+		if (!$Connection->tableExists('countries')) {
1674
+			return '';
1675
+		}
1587 1676
 	
1588 1677
 		try {
1589 1678
 			/*
@@ -1603,9 +1692,13 @@  discard block
 block discarded – undo
1603 1692
 			$sth->closeCursor();
1604 1693
 			if (count($row) > 0) {
1605 1694
 				return $row;
1606
-			} else return '';
1695
+			} else {
1696
+				return '';
1697
+			}
1607 1698
 		} catch (PDOException $e) {
1608
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1699
+			if (isset($globalDebug) && $globalDebug) {
1700
+				echo 'Error : '.$e->getMessage()."\n";
1701
+			}
1609 1702
 			return '';
1610 1703
 		}
1611 1704
 	
@@ -1623,7 +1716,9 @@  discard block
 block discarded – undo
1623 1716
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1624 1717
 	
1625 1718
 		$Connection = new Connection($this->db);
1626
-		if (!$Connection->tableExists('countries')) return '';
1719
+		if (!$Connection->tableExists('countries')) {
1720
+			return '';
1721
+		}
1627 1722
 	
1628 1723
 		try {
1629 1724
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1635,9 +1730,13 @@  discard block
 block discarded – undo
1635 1730
 			$sth->closeCursor();
1636 1731
 			if (count($row) > 0) {
1637 1732
 				return $row;
1638
-			} else return '';
1733
+			} else {
1734
+				return '';
1735
+			}
1639 1736
 		} catch (PDOException $e) {
1640
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1737
+			if (isset($globalDebug) && $globalDebug) {
1738
+				echo 'Error : '.$e->getMessage()."\n";
1739
+			}
1641 1740
 			return '';
1642 1741
 		}
1643 1742
 	
@@ -1698,7 +1797,9 @@  discard block
 block discarded – undo
1698 1797
 			}
1699 1798
 		}
1700 1799
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
1701
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1800
+		if ($limit) {
1801
+			$query .= " LIMIT 10 OFFSET 0";
1802
+		}
1702 1803
 		$sth = $this->db->prepare($query);
1703 1804
 		$sth->execute($query_values);
1704 1805
 		$tracker_array = array();
@@ -1725,7 +1826,9 @@  discard block
 block discarded – undo
1725 1826
 	{
1726 1827
 		global $globalBitlyAccessToken;
1727 1828
 		
1728
-		if ($globalBitlyAccessToken == '') return $url;
1829
+		if ($globalBitlyAccessToken == '') {
1830
+			return $url;
1831
+		}
1729 1832
         
1730 1833
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1731 1834
 		
Please login to merge, or discard this patch.
require/class.TrackerLive.php 4 patches
Doc Comments   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -759,10 +759,6 @@  discard block
 block discarded – undo
759 759
 	*
760 760
 	* @param String $famtrackid the ID from flightaware
761 761
 	* @param String $ident the flight ident
762
-	* @param String $aircraft_icao the aircraft type
763
-	* @param String $departure_airport_icao the departure airport
764
-	* @param String $arrival_airport_icao the arrival airport
765
-	* @return String success or false
766 762
 	*
767 763
 	*/
768 764
 	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
Please login to merge, or discard this patch.
Indentation   +193 added lines, -193 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
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	}
88 88
 
89 89
 	/**
90
-	* Gets all the spotter information based on the latest data entry
91
-	*
92
-	* @return Array the spotter information
93
-	*
94
-	*/
90
+	 * Gets all the spotter information based on the latest data entry
91
+	 *
92
+	 * @return Array the spotter information
93
+	 *
94
+	 */
95 95
 	public function getLiveTrackerData($limit = '', $sort = '', $filter = array())
96 96
 	{
97 97
 		global $globalDBdriver, $globalLiveInterval;
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 
135 135
 	/**
136
-	* Gets Minimal Live Spotter data
137
-	*
138
-	* @return Array the spotter information
139
-	*
140
-	*/
136
+	 * Gets Minimal Live Spotter data
137
+	 *
138
+	 * @return Array the spotter information
139
+	 *
140
+	 */
141 141
 	public function getMinLiveTrackerData($filter = array())
142 142
 	{
143 143
 		global $globalDBdriver, $globalLiveInterval;
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	}
172 172
 
173 173
 	/**
174
-	* Gets Minimal Live Spotter data since xx seconds
175
-	*
176
-	* @return Array the spotter information
177
-	*
178
-	*/
174
+	 * Gets Minimal Live Spotter data since xx seconds
175
+	 *
176
+	 * @return Array the spotter information
177
+	 *
178
+	 */
179 179
 	public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false)
180 180
 	{
181 181
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit;
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 	}
250 250
 
251 251
 	/**
252
-	* Gets number of latest data entry
253
-	*
254
-	* @return String number of entry
255
-	*
256
-	*/
252
+	 * Gets number of latest data entry
253
+	 *
254
+	 * @return String number of entry
255
+	 *
256
+	 */
257 257
 	public function getLiveTrackerCount($filter = array())
258 258
 	{
259 259
 		global $globalDBdriver, $globalLiveInterval;
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 	}
279 279
 
280 280
 	/**
281
-	* Gets all the spotter information based on the latest data entry and coord
282
-	*
283
-	* @return Array the spotter information
284
-	*
285
-	*/
281
+	 * Gets all the spotter information based on the latest data entry and coord
282
+	 *
283
+	 * @return Array the spotter information
284
+	 *
285
+	 */
286 286
 	public function getLiveTrackerDatabyCoord($coord, $filter = array())
287 287
 	{
288 288
 		global $globalDBdriver, $globalLiveInterval;
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 	}
307 307
 
308 308
 	/**
309
-	* Gets all the spotter information based on the latest data entry and coord
310
-	*
311
-	* @return Array the spotter information
312
-	*
313
-	*/
309
+	 * Gets all the spotter information based on the latest data entry and coord
310
+	 *
311
+	 * @return Array the spotter information
312
+	 *
313
+	 */
314 314
 	public function getMinLiveTrackerDatabyCoord($coord, $filter = array())
315 315
 	{
316 316
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -378,11 +378,11 @@  discard block
 block discarded – undo
378 378
 	}
379 379
 
380 380
 	/**
381
-	* Gets all the spotter information based on a user's latitude and longitude
382
-	*
383
-	* @return Array the spotter information
384
-	*
385
-	*/
381
+	 * Gets all the spotter information based on a user's latitude and longitude
382
+	 *
383
+	 * @return Array the spotter information
384
+	 *
385
+	 */
386 386
 	public function getLatestTrackerForLayar($lat, $lng, $radius, $interval)
387 387
 	{
388 388
 		$Tracker = new Tracker($this->db);
@@ -395,142 +395,142 @@  discard block
 block discarded – undo
395 395
 		if ($lng != '')
396 396
 		{
397 397
 			if (!is_numeric($lng))
398
-                        {
399
-                                return false;
400
-                        }
401
-                }
402
-
403
-                if ($radius != '')
404
-                {
405
-                        if (!is_numeric($radius))
406
-                        {
407
-                                return false;
408
-                        }
409
-                }
398
+						{
399
+								return false;
400
+						}
401
+				}
402
+
403
+				if ($radius != '')
404
+				{
405
+						if (!is_numeric($radius))
406
+						{
407
+								return false;
408
+						}
409
+				}
410 410
 		$additional_query = '';
411 411
 		if ($interval != '')
412
-                {
413
-                        if (!is_string($interval))
414
-                        {
415
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
416
-			        return false;
417
-                        } else {
418
-                if ($interval == '1m')
419
-                {
420
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
421
-                } else if ($interval == '15m'){
422
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
423
-                } 
424
-            }
425
-                } else {
426
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
427
-        }
428
-
429
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
412
+				{
413
+						if (!is_string($interval))
414
+						{
415
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
416
+					return false;
417
+						} else {
418
+				if ($interval == '1m')
419
+				{
420
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
421
+				} else if ($interval == '15m'){
422
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
423
+				} 
424
+			}
425
+				} else {
426
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
427
+		}
428
+
429
+				$query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
430 430
                    WHERE tracker_live.latitude <> '' 
431 431
                                    AND tracker_live.longitude <> '' 
432 432
                    ".$additional_query."
433 433
                    HAVING distance < :radius  
434 434
                                    ORDER BY distance";
435 435
 
436
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
436
+				$spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
437 437
 
438
-                return $spotter_array;
439
-        }
438
+				return $spotter_array;
439
+		}
440 440
 
441 441
     
442
-        /**
443
-	* Gets all the spotter information based on a particular callsign
444
-	*
445
-	* @return Array the spotter information
446
-	*
447
-	*/
442
+		/**
443
+		 * Gets all the spotter information based on a particular callsign
444
+		 *
445
+		 * @return Array the spotter information
446
+		 *
447
+		 */
448 448
 	public function getLastLiveTrackerDataByIdent($ident)
449 449
 	{
450 450
 		$Tracker = new Tracker($this->db);
451 451
 		date_default_timezone_set('UTC');
452 452
 
453 453
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
454
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
454
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
455 455
 
456 456
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
457 457
 
458 458
 		return $spotter_array;
459 459
 	}
460 460
 
461
-        /**
462
-	* Gets all the spotter information based on a particular callsign
463
-	*
464
-	* @return Array the spotter information
465
-	*
466
-	*/
461
+		/**
462
+		 * Gets all the spotter information based on a particular callsign
463
+		 *
464
+		 * @return Array the spotter information
465
+		 *
466
+		 */
467 467
 	public function getDateLiveTrackerDataByIdent($ident,$date)
468 468
 	{
469 469
 		$Tracker = new Tracker($this->db);
470 470
 		date_default_timezone_set('UTC');
471 471
 
472 472
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
473
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
473
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
474 474
 
475
-                $date = date('c',$date);
475
+				$date = date('c',$date);
476 476
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
477 477
 
478 478
 		return $spotter_array;
479 479
 	}
480 480
 
481
-        /**
482
-	* Gets last spotter information based on a particular callsign
483
-	*
484
-	* @return Array the spotter information
485
-	*
486
-	*/
481
+		/**
482
+		 * Gets last spotter information based on a particular callsign
483
+		 *
484
+		 * @return Array the spotter information
485
+		 *
486
+		 */
487 487
 	public function getLastLiveTrackerDataById($id)
488 488
 	{
489 489
 		$Tracker = new Tracker($this->db);
490 490
 		date_default_timezone_set('UTC');
491 491
 
492 492
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
493
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
493
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
494 494
 
495 495
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
496 496
 
497 497
 		return $spotter_array;
498 498
 	}
499 499
 
500
-        /**
501
-	* Gets last spotter information based on a particular callsign
502
-	*
503
-	* @return Array the spotter information
504
-	*
505
-	*/
500
+		/**
501
+		 * Gets last spotter information based on a particular callsign
502
+		 *
503
+		 * @return Array the spotter information
504
+		 *
505
+		 */
506 506
 	public function getDateLiveTrackerDataById($id,$date)
507 507
 	{
508 508
 		$Tracker = new Tracker($this->db);
509 509
 		date_default_timezone_set('UTC');
510 510
 
511 511
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
512
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
-                $date = date('c',$date);
512
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
+				$date = date('c',$date);
514 514
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
515 515
 
516 516
 		return $spotter_array;
517 517
 	}
518 518
 
519
-        /**
520
-	* Gets altitude information based on a particular callsign
521
-	*
522
-	* @return Array the spotter information
523
-	*
524
-	*/
519
+		/**
520
+		 * Gets altitude information based on a particular callsign
521
+		 *
522
+		 * @return Array the spotter information
523
+		 *
524
+		 */
525 525
 	public function getAltitudeLiveTrackerDataByIdent($ident)
526 526
 	{
527 527
 
528 528
 		date_default_timezone_set('UTC');
529 529
 
530 530
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
531
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
531
+				$query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
532 532
 
533
-    		try {
533
+			try {
534 534
 			
535 535
 			$sth = $this->db->prepare($query);
536 536
 			$sth->execute(array(':ident' => $ident));
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
 		return $spotter_array;
544 544
 	}
545 545
 
546
-        /**
547
-	* Gets all the spotter information based on a particular id
548
-	*
549
-	* @return Array the spotter information
550
-	*
551
-	*/
546
+		/**
547
+		 * Gets all the spotter information based on a particular id
548
+		 *
549
+		 * @return Array the spotter information
550
+		 *
551
+		 */
552 552
 	public function getAllLiveTrackerDataById($id,$liveinterval = false)
553 553
 	{
554 554
 		global $globalDBdriver, $globalLiveInterval;
@@ -576,18 +576,18 @@  discard block
 block discarded – undo
576 576
 		return $spotter_array;
577 577
 	}
578 578
 
579
-        /**
580
-	* Gets all the spotter information based on a particular ident
581
-	*
582
-	* @return Array the spotter information
583
-	*
584
-	*/
579
+		/**
580
+		 * Gets all the spotter information based on a particular ident
581
+		 *
582
+		 * @return Array the spotter information
583
+		 *
584
+		 */
585 585
 	public function getAllLiveTrackerDataByIdent($ident)
586 586
 	{
587 587
 		date_default_timezone_set('UTC');
588 588
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
589 589
 		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
590
-    		try {
590
+			try {
591 591
 			
592 592
 			$sth = $this->db->prepare($query);
593 593
 			$sth->execute(array(':ident' => $ident));
@@ -601,23 +601,23 @@  discard block
 block discarded – undo
601 601
 
602 602
 
603 603
 	/**
604
-	* Deletes all info in the table
605
-	*
606
-	* @return String success or false
607
-	*
608
-	*/
604
+	 * Deletes all info in the table
605
+	 *
606
+	 * @return String success or false
607
+	 *
608
+	 */
609 609
 	public function deleteLiveTrackerData()
610 610
 	{
611 611
 		global $globalDBdriver;
612 612
 		if ($globalDBdriver == 'mysql') {
613 613
 			//$query  = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date";
614 614
 			$query  = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date';
615
-            		//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
615
+					//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
616 616
 		} else {
617 617
 			$query  = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date";
618 618
 		}
619 619
         
620
-    		try {
620
+			try {
621 621
 			
622 622
 			$sth = $this->db->prepare($query);
623 623
 			$sth->execute();
@@ -629,18 +629,18 @@  discard block
 block discarded – undo
629 629
 	}
630 630
 
631 631
 	/**
632
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
633
-	*
634
-	* @return String success or false
635
-	*
636
-	*/
632
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
633
+	 *
634
+	 * @return String success or false
635
+	 *
636
+	 */
637 637
 	public function deleteLiveTrackerDataNotUpdated()
638 638
 	{
639 639
 		global $globalDBdriver, $globalDebug;
640 640
 		if ($globalDBdriver == 'mysql') {
641 641
 			//$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0';
642
-    			$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
643
-    			try {
642
+				$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
643
+				try {
644 644
 				
645 645
 				$sth = $this->db->prepare($query);
646 646
 				$sth->execute();
@@ -648,8 +648,8 @@  discard block
 block discarded – undo
648 648
 				return "error";
649 649
 			}
650 650
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
651
-                        $i = 0;
652
-                        $j =0;
651
+						$i = 0;
652
+						$j =0;
653 653
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
654 654
 			foreach($all as $row)
655 655
 			{
@@ -657,20 +657,20 @@  discard block
 block discarded – undo
657 657
 				$j++;
658 658
 				if ($j == 30) {
659 659
 					if ($globalDebug) echo ".";
660
-				    	try {
660
+						try {
661 661
 						
662 662
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
663 663
 						$sth->execute();
664 664
 					} catch(PDOException $e) {
665 665
 						return "error";
666 666
 					}
667
-                                	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
668
-                                	$j = 0;
667
+									$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
668
+									$j = 0;
669 669
 				}
670 670
 				$query_delete .= "'".$row['famtrackid']."',";
671 671
 			}
672 672
 			if ($i > 0) {
673
-    				try {
673
+					try {
674 674
 					
675 675
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
676 676
 					$sth->execute();
@@ -681,9 +681,9 @@  discard block
 block discarded – undo
681 681
 			return "success";
682 682
 		} elseif ($globalDBdriver == 'pgsql') {
683 683
 			//$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0";
684
-    			//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
685
-    			$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
686
-    			try {
684
+				//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
685
+				$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
686
+				try {
687 687
 				
688 688
 				$sth = $this->db->prepare($query);
689 689
 				$sth->execute();
@@ -727,17 +727,17 @@  discard block
 block discarded – undo
727 727
 	}
728 728
 
729 729
 	/**
730
-	* Deletes all info in the table for an ident
731
-	*
732
-	* @return String success or false
733
-	*
734
-	*/
730
+	 * Deletes all info in the table for an ident
731
+	 *
732
+	 * @return String success or false
733
+	 *
734
+	 */
735 735
 	public function deleteLiveTrackerDataByIdent($ident)
736 736
 	{
737 737
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
738 738
 		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
739 739
         
740
-    		try {
740
+			try {
741 741
 			
742 742
 			$sth = $this->db->prepare($query);
743 743
 			$sth->execute(array(':ident' => $ident));
@@ -749,17 +749,17 @@  discard block
 block discarded – undo
749 749
 	}
750 750
 
751 751
 	/**
752
-	* Deletes all info in the table for an id
753
-	*
754
-	* @return String success or false
755
-	*
756
-	*/
752
+	 * Deletes all info in the table for an id
753
+	 *
754
+	 * @return String success or false
755
+	 *
756
+	 */
757 757
 	public function deleteLiveTrackerDataById($id)
758 758
 	{
759 759
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
760 760
 		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
761 761
         
762
-    		try {
762
+			try {
763 763
 			
764 764
 			$sth = $this->db->prepare($query);
765 765
 			$sth->execute(array(':id' => $id));
@@ -772,11 +772,11 @@  discard block
 block discarded – undo
772 772
 
773 773
 
774 774
 	/**
775
-	* Gets the aircraft ident within the last hour
776
-	*
777
-	* @return String the ident
778
-	*
779
-	*/
775
+	 * Gets the aircraft ident within the last hour
776
+	 *
777
+	 * @return String the ident
778
+	 *
779
+	 */
780 780
 	public function getIdentFromLastHour($ident)
781 781
 	{
782 782
 		global $globalDBdriver, $globalTimezone;
@@ -802,14 +802,14 @@  discard block
 block discarded – undo
802 802
 			$ident_result = $row['ident'];
803 803
 		}
804 804
 		return $ident_result;
805
-        }
805
+		}
806 806
 
807 807
 	/**
808
-	* Check recent aircraft
809
-	*
810
-	* @return String the ident
811
-	*
812
-	*/
808
+	 * Check recent aircraft
809
+	 *
810
+	 * @return String the ident
811
+	 *
812
+	 */
813 813
 	public function checkIdentRecent($ident)
814 814
 	{
815 815
 		global $globalDBdriver, $globalTimezone;
@@ -835,14 +835,14 @@  discard block
 block discarded – undo
835 835
 			$ident_result = $row['famtrackid'];
836 836
 		}
837 837
 		return $ident_result;
838
-        }
838
+		}
839 839
 
840 840
 	/**
841
-	* Check recent aircraft by id
842
-	*
843
-	* @return String the ident
844
-	*
845
-	*/
841
+	 * Check recent aircraft by id
842
+	 *
843
+	 * @return String the ident
844
+	 *
845
+	 */
846 846
 	public function checkIdRecent($id)
847 847
 	{
848 848
 		global $globalDBdriver, $globalTimezone;
@@ -868,19 +868,19 @@  discard block
 block discarded – undo
868 868
 			$ident_result = $row['famtrackid'];
869 869
 		}
870 870
 		return $ident_result;
871
-        }
871
+		}
872 872
 
873 873
 	/**
874
-	* Adds a new spotter data
875
-	*
876
-	* @param String $famtrackid the ID from flightaware
877
-	* @param String $ident the flight ident
878
-	* @param String $aircraft_icao the aircraft type
879
-	* @param String $departure_airport_icao the departure airport
880
-	* @param String $arrival_airport_icao the arrival airport
881
-	* @return String success or false
882
-	*
883
-	*/
874
+	 * Adds a new spotter data
875
+	 *
876
+	 * @param String $famtrackid the ID from flightaware
877
+	 * @param String $ident the flight ident
878
+	 * @param String $aircraft_icao the aircraft type
879
+	 * @param String $departure_airport_icao the departure airport
880
+	 * @param String $arrival_airport_icao the arrival airport
881
+	 * @return String success or false
882
+	 *
883
+	 */
884 884
 	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
885 885
 	{
886 886
 		global $globalURL, $globalArchive, $globalDebug;
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
954 954
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
955 955
 
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
956
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
958 958
             	
959 959
 		$query = '';
960 960
 		if ($globalArchive) {
@@ -972,15 +972,15 @@  discard block
 block discarded – undo
972 972
 		} catch(PDOException $e) {
973 973
 			return "error : ".$e->getMessage();
974 974
 		}
975
-                /*
975
+				/*
976 976
                 echo 'putinarchive : '.$putinarchive."\n";
977 977
                 echo 'noarchive : '.$noarchive."\n";
978 978
                 */
979 979
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
980
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
981
-		    $TrackerArchive = new TrackerArchive($this->db);
982
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
983
-		    if ($globalDebug) echo $result.')';
980
+			if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
981
+			$TrackerArchive = new TrackerArchive($this->db);
982
+			$result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
983
+			if ($globalDebug) echo $result.')';
984 984
 		}
985 985
 
986 986
 		return "success";
Please login to merge, or discard this patch.
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
39
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
41
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
73 73
 				}
74 74
 			}
75
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
75
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
76 76
 		}
77 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
79 79
 		}
80 80
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81 81
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
82 82
 		if ($filter_query_where != '') {
83
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
84 84
 		}
85 85
 		$filter_query = $filter_query_join.$filter_query_where;
86 86
 		return $filter_query;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 		if ($limit != '')
104 104
 		{
105 105
 			$limit_array = explode(',', $limit);
106
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
107
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
107
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
108 108
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
109 109
 			{
110 110
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		} else {
128 128
 			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
129 129
 		}
130
-		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
130
+		$spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true);
131 131
 
132 132
 		return $spotter_array;
133 133
 	}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		global $globalDBdriver, $globalLiveInterval;
144 144
 		date_default_timezone_set('UTC');
145 145
 
146
-		$filter_query = $this->getFilter($filter,true,true);
146
+		$filter_query = $this->getFilter($filter, true, true);
147 147
 
148 148
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
149 149
 		if ($globalDBdriver == 'mysql') {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute();
164
-		} catch(PDOException $e) {
164
+		} catch (PDOException $e) {
165 165
 			echo $e->getMessage();
166 166
 			die;
167 167
 		}
@@ -176,25 +176,25 @@  discard block
 block discarded – undo
176 176
 	* @return Array the spotter information
177 177
 	*
178 178
 	*/
179
-	public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false)
179
+	public function getMinLastLiveTrackerData($coord, $filter = array(), $limit = false)
180 180
 	{
181 181
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit;
182 182
 		date_default_timezone_set('UTC');
183 183
 		$usecoord = false;
184 184
 		if (is_array($coord) && !empty($coord)) {
185
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
186
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
187
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
188
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
185
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
186
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
187
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
188
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
189 189
 			$usecoord = true;
190 190
 		}
191
-		$filter_query = $this->getFilter($filter,true,true);
191
+		$filter_query = $this->getFilter($filter, true, true);
192 192
 
193 193
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194 194
 		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
195 195
 		if ($globalDBdriver == 'mysql') {
196 196
 			if (isset($globalArchive) && $globalArchive) {
197
-				$query  = "SELECT * FROM (
197
+				$query = "SELECT * FROM (
198 198
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 199
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200 200
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			}
217 217
 		} else {
218 218
 			if (isset($globalArchive) && $globalArchive) {
219
-				$query  = "SELECT * FROM (
219
+				$query = "SELECT * FROM (
220 220
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 221
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222 222
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		try {
241 241
 			$sth = $this->db->prepare($query);
242 242
 			$sth->execute();
243
-		} catch(PDOException $e) {
243
+		} catch (PDOException $e) {
244 244
 			echo $e->getMessage();
245 245
 			die;
246 246
 		}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	public function getLiveTrackerCount($filter = array())
258 258
 	{
259 259
 		global $globalDBdriver, $globalLiveInterval;
260
-		$filter_query = $this->getFilter($filter,true,true);
260
+		$filter_query = $this->getFilter($filter, true, true);
261 261
 
262 262
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
263 263
 		if ($globalDBdriver == 'mysql') {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		try {
269 269
 			$sth = $this->db->prepare($query);
270 270
 			$sth->execute();
271
-		} catch(PDOException $e) {
271
+		} catch (PDOException $e) {
272 272
 			echo $e->getMessage();
273 273
 			die;
274 274
 		}
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 		$filter_query = $this->getFilter($filter);
292 292
 
293 293
 		if (is_array($coord)) {
294
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
295
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
294
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
295
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
296
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
297
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
298 298
 		} else return array();
299 299
 		if ($globalDBdriver == 'mysql') {
300 300
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 317
 		$Tracker = new Tracker($this->db);
318 318
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
319
-		$filter_query = $this->getFilter($filter,true,true);
319
+		$filter_query = $this->getFilter($filter, true, true);
320 320
 
321 321
 		if (is_array($coord)) {
322
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
323
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
322
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
323
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
324
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
325
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
326 326
 		} else return array();
327 327
 		/*
328 328
 		if ($globalDBdriver == 'mysql') {
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 		*/
337 337
 		if ($globalDBdriver == 'mysql') {
338 338
 			if (isset($globalArchive) && $globalArchive === TRUE) {
339
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
339
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
340 340
 				    FROM tracker_live 
341 341
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= tracker_live.date 
342 342
 				    AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
343 343
 				    AND tracker_live.latitude <> 0 AND tracker_live.longitude <> 0';
344 344
 			} else {
345
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
345
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
346 346
 				    FROM tracker_live 
347 347
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
348 348
 					FROM tracker_live l 
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
 			}
355 355
 		} else {
356 356
 			if (isset($globalArchive) && $globalArchive === TRUE) {
357
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
357
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
358 358
 				    FROM tracker_live 
359 359
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date 
360 360
 				    AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
361 361
 				    AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
362 362
 				    AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'";
363 363
 			} else {
364
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
364
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
365 365
 				    FROM tracker_live 
366 366
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
367 367
 					FROM tracker_live l 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                 if ($interval == '1m')
419 419
                 {
420 420
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
421
-                } else if ($interval == '15m'){
421
+                } else if ($interval == '15m') {
422 422
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
423 423
                 } 
424 424
             }
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
427 427
         }
428 428
 
429
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
429
+                $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
430 430
                    WHERE tracker_live.latitude <> '' 
431 431
                                    AND tracker_live.longitude <> '' 
432 432
                    ".$additional_query."
433 433
                    HAVING distance < :radius  
434 434
                                    ORDER BY distance";
435 435
 
436
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
436
+                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
437 437
 
438 438
                 return $spotter_array;
439 439
         }
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
 		date_default_timezone_set('UTC');
452 452
 
453 453
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
454
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
454
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
455 455
 
456
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
456
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true);
457 457
 
458 458
 		return $spotter_array;
459 459
 	}
@@ -464,16 +464,16 @@  discard block
 block discarded – undo
464 464
 	* @return Array the spotter information
465 465
 	*
466 466
 	*/
467
-	public function getDateLiveTrackerDataByIdent($ident,$date)
467
+	public function getDateLiveTrackerDataByIdent($ident, $date)
468 468
 	{
469 469
 		$Tracker = new Tracker($this->db);
470 470
 		date_default_timezone_set('UTC');
471 471
 
472 472
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
473
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
473
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
474 474
 
475
-                $date = date('c',$date);
476
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
475
+                $date = date('c', $date);
476
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
477 477
 
478 478
 		return $spotter_array;
479 479
 	}
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
 		date_default_timezone_set('UTC');
491 491
 
492 492
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
493
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
493
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
494 494
 
495
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
495
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true);
496 496
 
497 497
 		return $spotter_array;
498 498
 	}
@@ -503,15 +503,15 @@  discard block
 block discarded – undo
503 503
 	* @return Array the spotter information
504 504
 	*
505 505
 	*/
506
-	public function getDateLiveTrackerDataById($id,$date)
506
+	public function getDateLiveTrackerDataById($id, $date)
507 507
 	{
508 508
 		$Tracker = new Tracker($this->db);
509 509
 		date_default_timezone_set('UTC');
510 510
 
511 511
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
512
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
-                $date = date('c',$date);
514
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
512
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
+                $date = date('c', $date);
514
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
515 515
 
516 516
 		return $spotter_array;
517 517
 	}
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
 		date_default_timezone_set('UTC');
529 529
 
530 530
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
531
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
531
+                $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
532 532
 
533 533
     		try {
534 534
 			
535 535
 			$sth = $this->db->prepare($query);
536 536
 			$sth->execute(array(':ident' => $ident));
537
-		} catch(PDOException $e) {
537
+		} catch (PDOException $e) {
538 538
 			echo $e->getMessage();
539 539
 			die;
540 540
 		}
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	* @return Array the spotter information
550 550
 	*
551 551
 	*/
552
-	public function getAllLiveTrackerDataById($id,$liveinterval = false)
552
+	public function getAllLiveTrackerDataById($id, $liveinterval = false)
553 553
 	{
554 554
 		global $globalDBdriver, $globalLiveInterval;
555 555
 		date_default_timezone_set('UTC');
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 		try {
569 569
 			$sth = $this->db->prepare($query);
570 570
 			$sth->execute(array(':id' => $id));
571
-		} catch(PDOException $e) {
571
+		} catch (PDOException $e) {
572 572
 			echo $e->getMessage();
573 573
 			die;
574 574
 		}
@@ -586,12 +586,12 @@  discard block
 block discarded – undo
586 586
 	{
587 587
 		date_default_timezone_set('UTC');
588 588
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
589
-		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
589
+		$query = self::$global_query.' WHERE tracker_live.ident = :ident';
590 590
     		try {
591 591
 			
592 592
 			$sth = $this->db->prepare($query);
593 593
 			$sth->execute(array(':ident' => $ident));
594
-		} catch(PDOException $e) {
594
+		} catch (PDOException $e) {
595 595
 			echo $e->getMessage();
596 596
 			die;
597 597
 		}
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 			
622 622
 			$sth = $this->db->prepare($query);
623 623
 			$sth->execute();
624
-		} catch(PDOException $e) {
624
+		} catch (PDOException $e) {
625 625
 			return "error";
626 626
 		}
627 627
 
@@ -644,14 +644,14 @@  discard block
 block discarded – undo
644 644
 				
645 645
 				$sth = $this->db->prepare($query);
646 646
 				$sth->execute();
647
-			} catch(PDOException $e) {
647
+			} catch (PDOException $e) {
648 648
 				return "error";
649 649
 			}
650 650
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
651 651
                         $i = 0;
652
-                        $j =0;
652
+                        $j = 0;
653 653
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
654
-			foreach($all as $row)
654
+			foreach ($all as $row)
655 655
 			{
656 656
 				$i++;
657 657
 				$j++;
@@ -659,9 +659,9 @@  discard block
 block discarded – undo
659 659
 					if ($globalDebug) echo ".";
660 660
 				    	try {
661 661
 						
662
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
662
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
663 663
 						$sth->execute();
664
-					} catch(PDOException $e) {
664
+					} catch (PDOException $e) {
665 665
 						return "error";
666 666
 					}
667 667
                                 	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
 			if ($i > 0) {
673 673
     				try {
674 674
 					
675
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
675
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
676 676
 					$sth->execute();
677
-				} catch(PDOException $e) {
677
+				} catch (PDOException $e) {
678 678
 					return "error";
679 679
 				}
680 680
 			}
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 				
688 688
 				$sth = $this->db->prepare($query);
689 689
 				$sth->execute();
690
-			} catch(PDOException $e) {
690
+			} catch (PDOException $e) {
691 691
 				return "error";
692 692
 			}
693 693
 /*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
@@ -735,13 +735,13 @@  discard block
 block discarded – undo
735 735
 	public function deleteLiveTrackerDataByIdent($ident)
736 736
 	{
737 737
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
738
-		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
738
+		$query = 'DELETE FROM tracker_live WHERE ident = :ident';
739 739
         
740 740
     		try {
741 741
 			
742 742
 			$sth = $this->db->prepare($query);
743 743
 			$sth->execute(array(':ident' => $ident));
744
-		} catch(PDOException $e) {
744
+		} catch (PDOException $e) {
745 745
 			return "error";
746 746
 		}
747 747
 
@@ -757,13 +757,13 @@  discard block
 block discarded – undo
757 757
 	public function deleteLiveTrackerDataById($id)
758 758
 	{
759 759
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
760
-		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
760
+		$query = 'DELETE FROM tracker_live WHERE famtrackid = :id';
761 761
         
762 762
     		try {
763 763
 			
764 764
 			$sth = $this->db->prepare($query);
765 765
 			$sth->execute(array(':id' => $id));
766
-		} catch(PDOException $e) {
766
+		} catch (PDOException $e) {
767 767
 			return "error";
768 768
 		}
769 769
 
@@ -781,13 +781,13 @@  discard block
 block discarded – undo
781 781
 	{
782 782
 		global $globalDBdriver, $globalTimezone;
783 783
 		if ($globalDBdriver == 'mysql') {
784
-			$query  = 'SELECT tracker_live.ident FROM tracker_live 
784
+			$query = 'SELECT tracker_live.ident FROM tracker_live 
785 785
 				WHERE tracker_live.ident = :ident 
786 786
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
787 787
 				AND tracker_live.date < UTC_TIMESTAMP()';
788 788
 			$query_data = array(':ident' => $ident);
789 789
 		} else {
790
-			$query  = "SELECT tracker_live.ident FROM tracker_live 
790
+			$query = "SELECT tracker_live.ident FROM tracker_live 
791 791
 				WHERE tracker_live.ident = :ident 
792 792
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
793 793
 				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -796,8 +796,8 @@  discard block
 block discarded – undo
796 796
 		
797 797
 		$sth = $this->db->prepare($query);
798 798
 		$sth->execute($query_data);
799
-		$ident_result='';
800
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
799
+		$ident_result = '';
800
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
801 801
 		{
802 802
 			$ident_result = $row['ident'];
803 803
 		}
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	{
815 815
 		global $globalDBdriver, $globalTimezone;
816 816
 		if ($globalDBdriver == 'mysql') {
817
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
817
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
818 818
 				WHERE tracker_live.ident = :ident 
819 819
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
820 820
 //				AND tracker_live.date < UTC_TIMESTAMP()";
821 821
 			$query_data = array(':ident' => $ident);
822 822
 		} else {
823
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
823
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
824 824
 				WHERE tracker_live.ident = :ident 
825 825
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
826 826
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
 		
830 830
 		$sth = $this->db->prepare($query);
831 831
 		$sth->execute($query_data);
832
-		$ident_result='';
833
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
832
+		$ident_result = '';
833
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
834 834
 		{
835 835
 			$ident_result = $row['famtrackid'];
836 836
 		}
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
 	{
848 848
 		global $globalDBdriver, $globalTimezone;
849 849
 		if ($globalDBdriver == 'mysql') {
850
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
850
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
851 851
 				WHERE tracker_live.famtrackid = :id 
852 852
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
853 853
 //				AND tracker_live.date < UTC_TIMESTAMP()";
854 854
 			$query_data = array(':id' => $id);
855 855
 		} else {
856
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
856
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
857 857
 				WHERE tracker_live.famtrackid = :id 
858 858
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
859 859
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 		
863 863
 		$sth = $this->db->prepare($query);
864 864
 		$sth->execute($query_data);
865
-		$ident_result='';
866
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
865
+		$ident_result = '';
866
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
867 867
 		{
868 868
 			$ident_result = $row['famtrackid'];
869 869
 		}
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	* @return String success or false
882 882
 	*
883 883
 	*/
884
-	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
884
+	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
885 885
 	{
886 886
 		global $globalURL, $globalArchive, $globalDebug;
887 887
 		$Common = new Common();
@@ -940,21 +940,21 @@  discard block
 block discarded – undo
940 940
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
941 941
 
942 942
         
943
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
944
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
945
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
946
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
947
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
948
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
949
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
950
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
951
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
952
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
953
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
954
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
955
-
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
943
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
944
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
945
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
946
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
947
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
948
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
949
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
950
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
951
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
952
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
953
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
954
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
955
+
956
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
957
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
958 958
             	
959 959
 		$query = '';
960 960
 		if ($globalArchive) {
@@ -964,12 +964,12 @@  discard block
 block discarded – undo
964 964
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
965 965
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
966 966
 
967
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
967
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
968 968
 		try {
969 969
 			$sth = $this->db->prepare($query);
970 970
 			$sth->execute($query_values);
971 971
 			$sth->closeCursor();
972
-		} catch(PDOException $e) {
972
+		} catch (PDOException $e) {
973 973
 			return "error : ".$e->getMessage();
974 974
 		}
975 975
                 /*
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
980 980
 		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
981 981
 		    $TrackerArchive = new TrackerArchive($this->db);
982
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
982
+		    $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country);
983 983
 		    if ($globalDebug) echo $result.')';
984 984
 		}
985 985
 
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 
990 990
 	public function getOrderBy()
991 991
 	{
992
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
992
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
993 993
 		return $orderby;
994 994
 	}
995 995
 
Please login to merge, or discard this patch.
Braces   +110 added lines, -37 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (TrackerLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (TrackerLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -120,7 +127,9 @@  discard block
 block discarded – undo
120 127
 			}
121 128
 		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
126 135
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
151 162
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -190,50 +201,74 @@  discard block
 block discarded – undo
190 201
 		}
191 202
 		$filter_query = $this->getFilter($filter,true,true);
192 203
 
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
-		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
207
+		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') {
208
+			$globalMap3DTrackersLimit = '300';
209
+		}
195 210
 		if ($globalDBdriver == 'mysql') {
196 211
 			if (isset($globalArchive) && $globalArchive) {
197 212
 				$query  = "SELECT * FROM (
198 213
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 214
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
215
+				if ($usecoord) {
216
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
217
+				}
201 218
 				$query .= "UNION
202 219
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
203 220
 					FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
204
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
221
+				if ($usecoord) {
222
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
223
+				}
205 224
 				$query .= ") AS tracker
206 225
 				    WHERE latitude <> '0' AND longitude <> '0' 
207 226
 				    ORDER BY famtrackid, date";
208
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
227
+				if ($limit) {
228
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
229
+				}
209 230
 			} else {
210 231
 				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
211 232
 				    FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
212
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
233
+				if ($usecoord) {
234
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
235
+				}
213 236
 				$query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
214 237
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
215
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
238
+				if ($limit) {
239
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
240
+				}
216 241
 			}
217 242
 		} else {
218 243
 			if (isset($globalArchive) && $globalArchive) {
219 244
 				$query  = "SELECT * FROM (
220 245
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 246
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
247
+				if ($usecoord) {
248
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
223 250
 				$query .= "UNION
224 251
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
225 252
 					FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date";
226
-				if ($usecoord) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
253
+				if ($usecoord) {
254
+					$query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
255
+				}
227 256
 				$query .= ") AS tracker
228 257
 				    WHERE latitude <> '0' AND longitude <> '0' 
229 258
 				    ORDER BY famtrackid, date";
230
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
259
+				if ($limit) {
260
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
261
+				}
231 262
 			} else {
232 263
 				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
233 264
 				    FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ";
234
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
265
+				if ($usecoord) {
266
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
267
+				}
235 268
 				$query .= "ORDER BY tracker_live.famtrackid, tracker_live.date";
236
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
269
+				if ($limit) {
270
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
271
+				}
237 272
 			}
238 273
 		}
239 274
 
@@ -259,7 +294,9 @@  discard block
 block discarded – undo
259 294
 		global $globalDBdriver, $globalLiveInterval;
260 295
 		$filter_query = $this->getFilter($filter,true,true);
261 296
 
262
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
297
+		if (!isset($globalLiveInterval)) {
298
+			$globalLiveInterval = '200';
299
+		}
263 300
 		if ($globalDBdriver == 'mysql') {
264 301
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
265 302
 		} else {
@@ -287,7 +324,9 @@  discard block
 block discarded – undo
287 324
 	{
288 325
 		global $globalDBdriver, $globalLiveInterval;
289 326
 		$Tracker = new Tracker($this->db);
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
327
+		if (!isset($globalLiveInterval)) {
328
+			$globalLiveInterval = '200';
329
+		}
291 330
 		$filter_query = $this->getFilter($filter);
292 331
 
293 332
 		if (is_array($coord)) {
@@ -295,7 +334,9 @@  discard block
 block discarded – undo
295 334
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296 335
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297 336
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
298
-		} else return array();
337
+		} else {
338
+			return array();
339
+		}
299 340
 		if ($globalDBdriver == 'mysql') {
300 341
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
301 342
 		} else {
@@ -315,7 +356,9 @@  discard block
 block discarded – undo
315 356
 	{
316 357
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 358
 		$Tracker = new Tracker($this->db);
318
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
+		if (!isset($globalLiveInterval)) {
360
+			$globalLiveInterval = '200';
361
+		}
319 362
 		$filter_query = $this->getFilter($filter,true,true);
320 363
 
321 364
 		if (is_array($coord)) {
@@ -323,7 +366,9 @@  discard block
 block discarded – undo
323 366
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324 367
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325 368
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-		} else return array();
369
+		} else {
370
+			return array();
371
+		}
327 372
 		/*
328 373
 		if ($globalDBdriver == 'mysql') {
329 374
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
@@ -557,11 +602,15 @@  discard block
 block discarded – undo
557 602
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
558 603
 		if ($globalDBdriver == 'mysql') {
559 604
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
560
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
605
+			if ($liveinterval) {
606
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
607
+			}
561 608
 			$query .= ' ORDER BY date';
562 609
 		} else {
563 610
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
564
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
611
+			if ($liveinterval) {
612
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
613
+			}
565 614
 			$query .= ' ORDER BY date';
566 615
 		}
567 616
 
@@ -656,7 +705,9 @@  discard block
 block discarded – undo
656 705
 				$i++;
657 706
 				$j++;
658 707
 				if ($j == 30) {
659
-					if ($globalDebug) echo ".";
708
+					if ($globalDebug) {
709
+						echo ".";
710
+					}
660 711
 				    	try {
661 712
 						
662 713
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -903,7 +954,9 @@  discard block
 block discarded – undo
903 954
 			{
904 955
 				return false;
905 956
 			}
906
-		} else return '';
957
+		} else {
958
+			return '';
959
+		}
907 960
 
908 961
 		if ($longitude != '')
909 962
 		{
@@ -911,7 +964,9 @@  discard block
 block discarded – undo
911 964
 			{
912 965
 				return false;
913 966
 			}
914
-		} else return '';
967
+		} else {
968
+			return '';
969
+		}
915 970
 
916 971
 		if ($altitude != '')
917 972
 		{
@@ -919,7 +974,9 @@  discard block
 block discarded – undo
919 974
 			{
920 975
 				return false;
921 976
 			}
922
-		} else $altitude = 0;
977
+		} else {
978
+			$altitude = 0;
979
+		}
923 980
 
924 981
 		if ($heading != '')
925 982
 		{
@@ -927,7 +984,9 @@  discard block
 block discarded – undo
927 984
 			{
928 985
 				return false;
929 986
 			}
930
-		} else $heading = 0;
987
+		} else {
988
+			$heading = 0;
989
+		}
931 990
 
932 991
 		if ($groundspeed != '')
933 992
 		{
@@ -935,9 +994,13 @@  discard block
 block discarded – undo
935 994
 			{
936 995
 				return false;
937 996
 			}
938
-		} else $groundspeed = 0;
997
+		} else {
998
+			$groundspeed = 0;
999
+		}
939 1000
 		date_default_timezone_set('UTC');
940
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1001
+		if ($date == '') {
1002
+			$date = date("Y-m-d H:i:s", time());
1003
+		}
941 1004
 
942 1005
         
943 1006
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -953,12 +1016,18 @@  discard block
 block discarded – undo
953 1016
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
954 1017
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
955 1018
 
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1019
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1020
+            		$groundspeed = 0;
1021
+            	}
1022
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1023
+            		$heading = 0;
1024
+            	}
958 1025
             	
959 1026
 		$query = '';
960 1027
 		if ($globalArchive) {
961
-			if ($globalDebug) echo '-- Delete previous data -- ';
1028
+			if ($globalDebug) {
1029
+				echo '-- Delete previous data -- ';
1030
+			}
962 1031
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
963 1032
 		}
964 1033
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -977,10 +1046,14 @@  discard block
 block discarded – undo
977 1046
                 echo 'noarchive : '.$noarchive."\n";
978 1047
                 */
979 1048
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
980
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
1049
+		    if ($globalDebug) {
1050
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
1051
+		    }
981 1052
 		    $TrackerArchive = new TrackerArchive($this->db);
982 1053
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
983
-		    if ($globalDebug) echo $result.')';
1054
+		    if ($globalDebug) {
1055
+		    	echo $result.')';
1056
+		    }
984 1057
 		}
985 1058
 
986 1059
 		return "success";
Please login to merge, or discard this patch.
js/map-aircraft.2d.js.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 if (!isset($globalJsonCompress)) $compress = true;
7 7
 else $compress = $globalJsonCompress;
8 8
 
9
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
10
-if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
9
+if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
10
+if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
11 11
 ?>
12 12
 
13 13
 
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 	};
177 177
 	archive.update = function (props) {
178 178
 		if (typeof props != 'undefined') {
179
-			//this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
180
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
179
+			//this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
180
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
181 181
 		} else {
182
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
182
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
183 183
 		}
184 184
 
185 185
 	};
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 <?php
341 341
 		} else {
342 342
 ?>
343
-					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
343
+					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
344 344
 					return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
345 345
 <?php
346 346
 		}
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 							/*
357 357
 							shadowUrl: iconURLShadowpath,
358 358
 							shadowSize: [<?php print $globalAircraftSize; ?>, <?php print $globalAircraftSize; ?>],
359
-							shadowAnchor: [<?php print ($globalAircraftSize/2)+1; ?>, <?php print $globalAircraftSize; ?>]
359
+							shadowAnchor: [<?php print ($globalAircraftSize/2) + 1; ?>, <?php print $globalAircraftSize; ?>]
360 360
 							*/
361 361
 						})
362 362
 					})
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 <?php
383 383
 		} else {
384 384
 ?>
385
-						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
385
+						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
386 386
 						return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
387 387
 <?php
388 388
 		}
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 <?php
423 423
 		} else {
424 424
 ?>
425
-							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
425
+							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
426 426
 							return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
427 427
 <?php
428 428
 		}
Please login to merge, or discard this patch.
Braces   +66 added lines, -17 removed lines patch added patch discarded remove patch
@@ -3,11 +3,18 @@  discard block
 block discarded – undo
3 3
 require_once('../require/class.Language.php'); 
4 4
 
5 5
 // Compressed GeoJson is used if true
6
-if (!isset($globalJsonCompress)) $compress = true;
7
-else $compress = $globalJsonCompress;
6
+if (!isset($globalJsonCompress)) {
7
+	$compress = true;
8
+} else {
9
+	$compress = $globalJsonCompress;
10
+}
8 11
 
9
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
10
-if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
12
+if (isset($_GET['ident'])) {
13
+	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
14
+}
15
+if (isset($_GET['flightaware_id'])) {
16
+	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
17
+}
11 18
 ?>
12 19
 
13 20
 
@@ -72,9 +79,12 @@  discard block
 block discarded – undo
72 79
 
73 80
 function update_airportsLayer() {
74 81
 <?php
75
-	if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom'];
76
-	else $getZoom = '7';
77
-?>
82
+	if (isset($_COOKIE['AirportZoom'])) {
83
+		$getZoom = $_COOKIE['AirportZoom'];
84
+	} else {
85
+		$getZoom = '7';
86
+	}
87
+	?>
78 88
 	if (typeof airportsLayer != 'undefined') {
79 89
 		if (map.hasLayer(airportsLayer) == true) {
80 90
 			map.removeLayer(airportsLayer);
@@ -320,9 +330,13 @@  discard block
 block discarded – undo
320 330
 					if (callsign != ""){ markerLabel += callsign; }
321 331
 					if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; }
322 332
 <?php
323
-	if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor'];
324
-	elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor;
325
-	else $IconColor = '1a3151';
333
+	if (isset($_COOKIE['IconColor'])) {
334
+		$IconColor = $_COOKIE['IconColor'];
335
+	} elseif (isset($globalAircraftIconColor)) {
336
+		$IconColor = $globalAircraftIconColor;
337
+	} else {
338
+		$IconColor = '1a3151';
339
+	}
326 340
 	if (!isset($ident) && !isset($flightaware_id)) {
327 341
 ?>
328 342
 					//info_update(feature.properties.fc);
@@ -370,7 +384,12 @@  discard block
 block discarded – undo
370 384
 <?php
371 385
 		} else {
372 386
 ?>
373
-					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
387
+					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
388
+	print $archiveupdatetime*1000;
389
+} else {
390
+	print $globalMapRefresh*1000+20000;
391
+}
392
+?>+feature.properties.sqt*1000);
374 393
 					return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
375 394
 <?php
376 395
 		}
@@ -419,7 +438,12 @@  discard block
 block discarded – undo
419 438
 <?php
420 439
 		} else {
421 440
 ?>
422
-						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
441
+						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
442
+	print $archiveupdatetime*1000;
443
+} else {
444
+	print $globalMapRefresh*1000+20000;
445
+}
446
+?>+feature.properties.sqt*1000);
423 447
 						return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
424 448
 <?php
425 449
 		}
@@ -466,7 +490,12 @@  discard block
 block discarded – undo
466 490
 <?php
467 491
 		} else {
468 492
 ?>
469
-							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
493
+							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
494
+	print $archiveupdatetime*1000;
495
+} else {
496
+	print $globalMapRefresh*1000+20000;
497
+}
498
+?>+feature.properties.sqt*1000);
470 499
 							return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
471 500
 <?php
472 501
 		}
@@ -820,13 +849,23 @@  discard block
 block discarded – undo
820 849
 	if (isset($archive) && $archive) {
821 850
 ?>
822 851
 	//then load it again every 30 seconds
823
-	//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
852
+	//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
853
+	print ($globalMapRefresh*1000)/2;
854
+} else {
855
+	print '15000';
856
+}
857
+?>);
824 858
 	reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>);
825 859
 <?php
826 860
 	} else {
827 861
 ?>
828 862
 	//then load it again every 30 seconds
829
-	reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
863
+	reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
864
+	print $globalMapRefresh*1000;
865
+} else {
866
+	print '30000';
867
+}
868
+?>);
830 869
 	var currentdate = new Date();
831 870
 	var currentyear = new Date().getFullYear();
832 871
 	var begindate = new Date(Date.UTC(currentyear,11,24,2,0,0,0));
@@ -838,7 +877,12 @@  discard block
 block discarded – undo
838 877
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
839 878
 ?>
840 879
 	update_polarLayer();
841
-	setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
880
+	setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) {
881
+	print $globalMapRefresh*1000*2;
882
+} else {
883
+	print '60000';
884
+}
885
+?>);
842 886
 <?php
843 887
 		}
844 888
 ?>
@@ -853,7 +897,12 @@  discard block
 block discarded – undo
853 897
 	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
854 898
 ?>
855 899
 	update_atcLayer();
856
-	setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
900
+	setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) {
901
+	print $globalMapRefresh*1000*2;
902
+} else {
903
+	print '60000';
904
+}
905
+?>);
857 906
 <?php
858 907
 	}
859 908
 ?>
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -662,9 +662,9 @@
 block discarded – undo
662 662
 //	var timeline = new Cesium.Timeline(viewer);
663 663
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
664 664
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
665
-	//this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
666
-	$(".archivebox").html('<h4><?php echo str_replace("'","\'",_("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
667
-	//		this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
665
+	//this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
666
+	$(".archivebox").html('<h4><?php echo str_replace("'", "\'", _("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
667
+	//		this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
668 668
 
669 669
 }
670 670
 
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -209,21 +209,21 @@  discard block
 block discarded – undo
209 209
 			var entityid = entity.id;
210 210
 			var lastupdateentity = entity.properties.valueOf('lastupdate')._lastupdate._value;
211 211
 			<?php 
212
-			    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
212
+				if (isset($globalMapUseBbox) && $globalMapUseBbox) {
213 213
 			?>
214 214
 			if (lastupdateentity != lastupdate) {
215 215
 				viewer.dataSources.get(dsn).entities.remove(entity);
216 216
 				czmlds.entities.removeById(entityid);
217 217
 			}
218 218
 			<?php
219
-			    } else {
219
+				} else {
220 220
 			?>
221 221
 			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
222 222
 				viewer.dataSources.get(dsn).entities.remove(entity);
223 223
 				czmlds.entities.removeById(entityid);
224 224
 			}
225 225
 			<?php
226
-			    }
226
+				}
227 227
 			?>
228 228
 		}
229 229
 	}
@@ -629,12 +629,12 @@  discard block
 block discarded – undo
629 629
 	update_airportsLayer();
630 630
 }
631 631
 <?php
632
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
632
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
633 633
 ?>
634 634
 update_atcLayer();
635 635
 setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
636 636
 <?php
637
-    }
637
+	}
638 638
 ?>
639 639
 
640 640
 function iconColor(color) {
Please login to merge, or discard this patch.
Braces   +24 added lines, -4 removed lines patch added patch discarded remove patch
@@ -218,7 +218,12 @@  discard block
 block discarded – undo
218 218
 			<?php
219 219
 			    } else {
220 220
 			?>
221
-			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
221
+			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
222
+	print $globalMapRefresh*2000;
223
+} else {
224
+	print '60000';
225
+}
226
+?>)) {
222 227
 				viewer.dataSources.get(dsn).entities.remove(entity);
223 228
 				czmlds.entities.removeById(entityid);
224 229
 			}
@@ -502,7 +507,12 @@  discard block
 block discarded – undo
502 507
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
503 508
 ?>
504 509
 update_polarLayer();
505
-setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
510
+setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) {
511
+	print $globalMapRefresh*1000*2;
512
+} else {
513
+	print '60000';
514
+}
515
+?>);
506 516
 <?php
507 517
 		}
508 518
 ?>
@@ -613,7 +623,12 @@  discard block
 block discarded – undo
613 623
 				}
614 624
 			}
615 625
 		}
616
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
626
+	,<?php if (isset($globalMapRefresh)) {
627
+	print $globalMapRefresh*1000;
628
+} else {
629
+	print '30000';
630
+}
631
+?>);
617 632
 } else {
618 633
 	//var widget = new Cesium.CesiumWidget('archivebox');
619 634
 //	var timeline = new Cesium.Timeline(viewer);
@@ -632,7 +647,12 @@  discard block
 block discarded – undo
632 647
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
633 648
 ?>
634 649
 update_atcLayer();
635
-setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
650
+setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) {
651
+	print $globalMapRefresh*1000*2;
652
+} else {
653
+	print '60000';
654
+}
655
+?>);
636 656
 <?php
637 657
     }
638 658
 ?>
Please login to merge, or discard this patch.
marine-data.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
 
10 10
 $from_archive = false;
11 11
 if (isset($_GET['ident'])) {
12
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
13 13
 	if (isset($_GET['currenttime'])) {
14
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
14
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
15 15
 		$currenttime = round($currenttime/1000);
16
-		$spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident,$currenttime);
16
+		$spotter_array = $MarineLive->getDateLiveMarineDataByIdent($ident, $currenttime);
17 17
 		
18 18
 		if (empty($spotter_array)) {
19 19
 			$from_archive = true;
20
-			$spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident,$currenttime);
20
+			$spotter_array = $MarineArchive->getDateArchiveMarineDataByIdent($ident, $currenttime);
21 21
 		}
22 22
 		
23 23
 	} else {
@@ -31,16 +31,16 @@  discard block
 block discarded – undo
31 31
 	}
32 32
 }
33 33
 if (isset($_GET['fammarine_id'])) {
34
-	$fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING);
34
+	$fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING);
35 35
 	if (isset($_GET['currenttime'])) {
36
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
36
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
37 37
 		$currenttime = round($currenttime/1000);
38
-		$spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id,$currenttime);
38
+		$spotter_array = $MarineLive->getDateLiveMarineDataById($fammarine_id, $currenttime);
39 39
 		
40 40
 		if (empty($spotter_array)) {
41 41
 			$from_archive = true;
42 42
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
43
-			$spotter_array = $MarineArchive->getDateArchiveMarineDataById($flightaware_id,$currenttime);
43
+			$spotter_array = $MarineArchive->getDateArchiveMarineDataById($flightaware_id, $currenttime);
44 44
 		}
45 45
 		
46 46
 	} else {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
65
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
66 66
 	} else $image = $spotter_item['image_thumbnail'];
67 67
 
68 68
 }
Please login to merge, or discard this patch.
tracker-data.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 print '<div class="details">';
79 79
 print '<div><span>'._("Altitude").'</span>';
80 80
 if (isset($globalGroundAltitude) && $globalGroundAltitude) {
81
-    try {
81
+	try {
82 82
 	$groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
83
-    } catch(Exception $e) {
84
-    }
83
+	} catch(Exception $e) {
84
+	}
85 85
 }
86 86
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
87 87
 	print $spotter_item['altitude'].' feet (FL'.$spotter_item['altitude'].')';
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 	print round($spotter_item['altitude']*0.3048).' m (FL'.round($spotter_item['altitude']/100).')';
90 90
 }
91 91
 if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*0.3048) {
92
-    print '<br>';
93
-    print '<span>'._("Ground Altitude").'</span>';
94
-    if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
92
+	print '<br>';
93
+	print '<span>'._("Ground Altitude").'</span>';
94
+	if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
95 95
 	print round($groundAltitude*3.28084).' feet';
96
-    } else {
96
+	} else {
97 97
 	print round($groundAltitude).' m';
98
-    }
99
-    print '</i>';
98
+	}
99
+	print '</i>';
100 100
 }
101 101
 print '</div>';
102 102
 print '<div><span>'._("Speed").'</span>';
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 $from_archive = false;
13 13
 if (isset($_GET['ident'])) {
14
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
14
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
15 15
 	if (isset($_GET['currenttime'])) {
16
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
16
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
17 17
 		$currenttime = round($currenttime/1000);
18
-		$spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident,$currenttime);
18
+		$spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident, $currenttime);
19 19
 		if (empty($spotter_array)) {
20 20
 			$from_archive = true;
21
-			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident,$currenttime);
21
+			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident, $currenttime);
22 22
 		}
23 23
 		
24 24
 	} else {
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 	}
31 31
 }
32 32
 if (isset($_GET['famtrackid'])) {
33
-	$famtrackid = urldecode(filter_input(INPUT_GET,'famtrackid',FILTER_SANITIZE_STRING));
33
+	$famtrackid = urldecode(filter_input(INPUT_GET, 'famtrackid', FILTER_SANITIZE_STRING));
34 34
 	if (isset($_GET['currenttime'])) {
35
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
35
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
36 36
 		$currenttime = round($currenttime/1000);
37
-		$spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid,$currenttime);
37
+		$spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid, $currenttime);
38 38
 		
39 39
 		if (empty($spotter_array)) {
40 40
 			$from_archive = true;
41 41
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
42
-			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($famtrackid,$currenttime);
42
+			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($famtrackid, $currenttime);
43 43
 		}
44 44
 		
45 45
 	} else {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
60 60
 {
61 61
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
62
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
62
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
63 63
 	} else $image = $spotter_item['image_thumbnail'];
64 64
 
65 65
 }
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 print '<div><span>'._("Altitude").'</span>';
80 80
 if (isset($globalGroundAltitude) && $globalGroundAltitude) {
81 81
     try {
82
-	$groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
83
-    } catch(Exception $e) {
82
+	$groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']);
83
+    } catch (Exception $e) {
84 84
     }
85 85
 }
86 86
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
Please login to merge, or discard this patch.
require/class.AIS.php 4 patches
Doc Comments   +25 added lines patch added patch discarded remove patch
@@ -68,6 +68,10 @@  discard block
 block discarded – undo
68 68
        't', 'u', 'v', 'w' // 119
69 69
     ); // char 64
70 70
     */
71
+
72
+	/**
73
+	 * @param integer $ascii
74
+	 */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73 77
 		if ($ascii < 48) { }
@@ -93,6 +97,10 @@  discard block
 block discarded – undo
93 97
 		return(substr($bin, -6)); 
94 98
 	}
95 99
 
100
+	/**
101
+	 * @param integer $_start
102
+	 * @param integer $_size
103
+	 */
96 104
 	private function binchar($_str, $_start, $_size) {
97 105
 		//  ' ' --- '?', // 0x20 - 0x3F
98 106
 		//  '@' --- '_', // 0x40 - 0x5F
@@ -118,6 +126,10 @@  discard block
 block discarded – undo
118 126
 	}
119 127
 
120 128
 	// function for decoding the AIS Message ITU Payload
129
+
130
+	/**
131
+	 * @param string $_aisdata
132
+	 */
121 133
 	private function decode_ais($_aisdata) {
122 134
 		$ro = new stdClass(); // return object
123 135
 		$ro->cls = 0; // AIS class undefined, also indicate unparsed msg
@@ -351,6 +363,12 @@  discard block
 block discarded – undo
351 363
 		elseif ($code == 99) return 'Other Type, no additional information';
352 364
 	}
353 365
 
366
+	/**
367
+	 * @param string $_itu
368
+	 * @param integer $_len
369
+	 * @param integer $_filler
370
+	 * @param string $aux
371
+	 */
354 372
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
355 373
 		global $port; // tcpip port...
356 374
 		
@@ -371,6 +389,10 @@  discard block
 block discarded – undo
371 389
 
372 390
 	// char* - AIS \r terminated string
373 391
 	// TCP based streams which send messages in full can use this instead of calling process_ais_buf
392
+
393
+	/**
394
+	 * @param string $rawdata
395
+	 */
374 396
 	public function process_ais_raw($rawdata, $aux = '') { // return int
375 397
 		static $num_seq; // 1 to 9
376 398
 		static $seq; // 1 to 9
@@ -589,6 +611,9 @@  discard block
 block discarded – undo
589 611
 		return $result;
590 612
 	}
591 613
 
614
+	/**
615
+	 * @param string $mmsi
616
+	 */
592 617
 	public function mmsitype($mmsi) {
593 618
 		if (strlen($mmsi) == 9) {
594 619
 			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		return ($dec);
58 58
 	}
59 59
 	
60
-    /*
60
+	/*
61 61
     $ais_map64 = array(
62 62
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48
63 63
        ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C',
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 		//  ' ' --- '?', // 0x20 - 0x3F
98 98
 		//  '@' --- '_', // 0x40 - 0x5F
99 99
 		$ais_chars = array(
100
-		    '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
-		    'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
-		    'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
-		    '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
-		    '(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
-		    '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
-		    '<', '=', '>', '?'
100
+			'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
+			'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
+			'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
+			'^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
+			'(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
+			'2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
+			'<', '=', '>', '?'
107 107
 		);
108 108
 		// "
109 109
 		$rv = '';
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 				}
420 420
 				if ($num_seq > 1) { // for multipart messages
421 421
 					if ($cmsg_sid != $msg_sid // different msg_sid
422
-					    || $msg_sid == -1 // invalid initial msg_sid
423
-					    || ($seq - $pseq) != 1 // not insequence
422
+						|| $msg_sid == -1 // invalid initial msg_sid
423
+						|| ($seq - $pseq) != 1 // not insequence
424 424
 					) {  // invalid for multipart message
425 425
 						$msg_sid = -1;
426 426
 						$cmsg_sid = -1;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 				$itu = $itu.$pcs[5]; // get itu message
434 434
 				$filler += (int)$pcs[6][0]; // get filler
435 435
 				if ($num_seq == 1 // valid single message
436
-				    || $num_seq == $pseq // valid multi-part message
436
+					|| $num_seq == $pseq // valid multi-part message
437 437
 				) {
438 438
 					if ($num_seq != 1) { // test
439 439
 						//echo $rawdata;
@@ -516,13 +516,13 @@  discard block
 block discarded – undo
516 516
 		else $pad = '';
517 517
 		$rv = '';
518 518
 		$ais_chars = array(
519
-		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
520
-		    'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
521
-		    'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
522
-		    '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
523
-		    '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
524
-		    '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
525
-		    '<'=>60, '='=>61, '>'=>62, '?'=>63
519
+			'@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
520
+			'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
521
+			'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
522
+			'^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
523
+			'('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
524
+			'2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
525
+			'<'=>60, '='=>61, '>'=>62, '?'=>63
526 526
 		);
527 527
 		// "
528 528
 		$_a = str_split($name);
Please login to merge, or discard this patch.
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
 
30 30
 	private function make_latf($temp) { // unsigned long 
31 31
 		$flat = 0.0; // float
32
-		$temp = $temp & 0x07FFFFFF;
33
-		if ($temp & 0x04000000) {
34
-			$temp = $temp ^ 0x07FFFFFF;
32
+		$temp = $temp&0x07FFFFFF;
33
+		if ($temp&0x04000000) {
34
+			$temp = $temp^0x07FFFFFF;
35 35
 			$temp += 1;
36
-			$flat = (float)($temp / (60.0 * 10000.0));
36
+			$flat = (float) ($temp/(60.0*10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else $flat = (float) ($temp/(60.0*10000.0));
39 39
 		return $flat; // float
40 40
 	}
41 41
 
42 42
 	private function make_lonf($temp) { // unsigned long
43 43
 		$flon = 0.0; // float
44
-		$temp = $temp & 0x0FFFFFFF;
45
-		if ($temp & 0x08000000) {
46
-			$temp = $temp ^ 0x0FFFFFFF;
44
+		$temp = $temp&0x0FFFFFFF;
45
+		if ($temp&0x08000000) {
46
+			$temp = $temp^0x0FFFFFFF;
47 47
 			$temp += 1;
48
-			$flon = (float)($temp / (60.0 * 10000.0));
48
+			$flon = (float) ($temp/(60.0*10000.0));
49 49
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
50
+		} else $flon = (float) ($temp/(60.0*10000.0));
51 51
 		return $flon;
52 52
 	}
53 53
 
54 54
 	private function ascii_2_dec($chr) {
55
-		$dec=ord($chr);//get decimal ascii code
56
-		$hex=dechex($dec);//convert decimal to hex
55
+		$dec = ord($chr); //get decimal ascii code
56
+		$hex = dechex($dec); //convert decimal to hex
57 57
 		return ($dec);
58 58
 	}
59 59
 	
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 		//only process in the following range: 48-87, 96-119
73 73
 		if ($ascii < 48) { }
74 74
 		else {
75
-			if($ascii>119) { }
75
+			if ($ascii > 119) { }
76 76
 			else {
77
-				if ($ascii>87 && $ascii<96) ;
77
+				if ($ascii > 87 && $ascii < 96);
78 78
 				else {
79
-					$ascii=$ascii+40;
80
-					if ($ascii>128){
81
-						$ascii=$ascii+32;
79
+					$ascii = $ascii + 40;
80
+					if ($ascii > 128) {
81
+						$ascii = $ascii + 32;
82 82
 					} else {
83
-						$ascii=$ascii+40;
83
+						$ascii = $ascii + 40;
84 84
 					}
85 85
 				}
86 86
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	}
90 90
 
91 91
 	private function dec_2_6bit($dec) {
92
-		$bin=decbin($dec);
92
+		$bin = decbin($dec);
93 93
 		return(substr($bin, -6)); 
94 94
 	}
95 95
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 		);
108 108
 		// "
109 109
 		$rv = '';
110
-		if ($_size % 6 == 0) {
111
-			$len = $_size / 6;
112
-			for ($i=0; $i<$len; $i++) {
113
-				$offset = $i * 6;
114
-				$rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ];
110
+		if ($_size%6 == 0) {
111
+			$len = $_size/6;
112
+			for ($i = 0; $i < $len; $i++) {
113
+				$offset = $i*6;
114
+				$rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))];
115 115
 			}
116 116
 		}
117 117
 		return $rv;
@@ -138,93 +138,93 @@  discard block
 block discarded – undo
138 138
 		$ro->eta_hour = '';
139 139
 		$ro->eta_minute = '';
140 140
 		$ro->ts = time();
141
-		$ro->id = bindec(substr($_aisdata,0,6));
142
-		$ro->mmsi = bindec(substr($_aisdata,8,30));
141
+		$ro->id = bindec(substr($_aisdata, 0, 6));
142
+		$ro->mmsi = bindec(substr($_aisdata, 8, 30));
143 143
 		if ($ro->id >= 1 && $ro->id <= 3) {
144
-			$ro->cog = bindec(substr($_aisdata,116,12))/10;
145
-			$ro->sog = bindec(substr($_aisdata,50,10))/10;
146
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
147
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
144
+			$ro->cog = bindec(substr($_aisdata, 116, 12))/10;
145
+			$ro->sog = bindec(substr($_aisdata, 50, 10))/10;
146
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
147
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
148 148
 			$ro->cls = 1; // class A
149 149
 		} else if ($ro->id == 4) {
150
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28)));
151
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27)));
150
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28)));
151
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27)));
152 152
 			$ro->cls = 1; // class A
153 153
 		} else if ($ro->id == 5) {
154
-			$ro->imo = bindec(substr($_aisdata,40,30));
155
-			$ro->callsign = $this->binchar($_aisdata,70,42);
156
-			$ro->name = $this->binchar($_aisdata,112,120);
157
-			$ro->typeid = bindec(substr($_aisdata,232,8));
154
+			$ro->imo = bindec(substr($_aisdata, 40, 30));
155
+			$ro->callsign = $this->binchar($_aisdata, 70, 42);
156
+			$ro->name = $this->binchar($_aisdata, 112, 120);
157
+			$ro->typeid = bindec(substr($_aisdata, 232, 8));
158 158
 			$ro->type = $this->getShipType($ro->typeid);
159 159
 			//$ro->to_bow = bindec(substr($_aisdata,240,9));
160 160
 			//$ro->to_stern = bindec(substr($_aisdata,249,9));
161 161
 			//$ro->to_port = bindec(substr($_aisdata,258,6));
162 162
 			//$ro->to_starboard = bindec(substr($_aisdata,264,6));
163
-			$ro->eta_month = bindec(substr($_aisdata,274,4));
164
-			$ro->eta_day = bindec(substr($_aisdata,278,5));
165
-			$ro->eta_hour = bindec(substr($_aisdata,283,5));
166
-			$ro->eta_minute = bindec(substr($_aisdata,288,6));
163
+			$ro->eta_month = bindec(substr($_aisdata, 274, 4));
164
+			$ro->eta_day = bindec(substr($_aisdata, 278, 5));
165
+			$ro->eta_hour = bindec(substr($_aisdata, 283, 5));
166
+			$ro->eta_minute = bindec(substr($_aisdata, 288, 6));
167 167
 			//$ro->draught = bindec(substr($_aisdata,294,8));
168
-			$ro->destination = $this->binchar($_aisdata,302,120);
168
+			$ro->destination = $this->binchar($_aisdata, 302, 120);
169 169
 			$ro->cls = 1; // class A
170 170
 		} else if ($ro->id == 9) {
171 171
 			// Search and Rescue aircraft position report
172 172
 		} else if ($ro->id == 18) {
173
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
174
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
175
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177
-			$ro->heading = bindec(substr($_aisdata,124,9));
173
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
174
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
175
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28)));
176
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27)));
177
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
178 178
 			if ($ro->heading == 511) $ro->heading = '';
179 179
 			$ro->cls = 2; // class B
180 180
 		} else if ($ro->id == 19) {
181
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
182
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
183
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
184
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
185
-			$ro->name = $this->binchar($_aisdata,143,120);
181
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
182
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
183
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
184
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
185
+			$ro->name = $this->binchar($_aisdata, 143, 120);
186 186
 			$ro->cls = 2; // class B
187
-			$ro->heading = bindec(substr($_aisdata,124,9));
187
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
188 188
 			if ($ro->heading == 511) $ro->heading = '';
189
-			$ro->typeid = bindec(substr($_aisdata,263,8));
189
+			$ro->typeid = bindec(substr($_aisdata, 263, 8));
190 190
 			$ro->type = $this->getShipType($ro->typeid);
191 191
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
192 192
 			//$ro->to_stern = bindec(substr($_aisdata,280,9));
193 193
 			//$ro->to_port = bindec(substr($_aisdata,289,6));
194 194
 			//$ro->to_starboard = bindec(substr($_aisdata,295,6));
195 195
 		} else if ($ro->id == 21) {
196
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28)));
197
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27)));
198
-			$ro->name = $this->binchar($_aisdata,43,120);
196
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28)));
197
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27)));
198
+			$ro->name = $this->binchar($_aisdata, 43, 120);
199 199
 			//$ro->to_bow = bindec(substr($_aisdata,219,9));
200 200
 			//$ro->to_stern = bindec(substr($_aisdata,228,9));
201 201
 			//$ro->to_port = bindec(substr($_aisdata,237,6));
202 202
 			//$ro->to_starboard = bindec(substr($_aisdata,243,6));
203 203
 			$ro->cls = 2; // class B
204 204
 		} else if ($ro->id == 24) {
205
-			$pn = bindec(substr($_aisdata,38,2));
205
+			$pn = bindec(substr($_aisdata, 38, 2));
206 206
 			if ($pn == 0) {
207
-				$ro->name = $this->binchar($_aisdata,40,120);
207
+				$ro->name = $this->binchar($_aisdata, 40, 120);
208 208
 			}
209
-			$ro->typeid = bindec(substr($_aisdata,40,8));
209
+			$ro->typeid = bindec(substr($_aisdata, 40, 8));
210 210
 			$ro->type = $this->getShipType($ro->typeid);
211
-			$ro->callsign = $this->binchar($_aisdata,90,42);
211
+			$ro->callsign = $this->binchar($_aisdata, 90, 42);
212 212
 			//$ro->to_bow = bindec(substr($_aisdata,132,9));
213 213
 			//$ro->to_stern = bindec(substr($_aisdata,141,9));
214 214
 			//$ro->to_port = bindec(substr($_aisdata,150,6));
215 215
 			//$ro->to_starboard = bindec(substr($_aisdata,156,6));
216 216
 			$ro->cls = 2; // class B
217 217
 		} else if ($ro->id == 27) {
218
-			$ro->cog = bindec(substr($_aisdata,85,9));
218
+			$ro->cog = bindec(substr($_aisdata, 85, 9));
219 219
 			if ($ro->cog == 511) $ro->cog = 0.0;
220
-			$ro->sog = bindec(substr($_aisdata,79,6));
220
+			$ro->sog = bindec(substr($_aisdata, 79, 6));
221 221
 			if ($ro->sog == 63) $ro->sog = 0.0;
222
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
222
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10);
223
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10);
224 224
 			$ro->cls = 1; // class A
225 225
 		
226 226
 		}
227
-		$ro->statusid = bindec(substr($_aisdata,38,4));
227
+		$ro->statusid = bindec(substr($_aisdata, 38, 4));
228 228
 		$ro->status = $this->getStatus($ro->statusid);
229 229
 		//var_dump($ro); // dump results here for demo purpose
230 230
 		return $ro;
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 		global $port; // tcpip port...
356 356
 		
357 357
 		static $debug_counter = 0;
358
-		$aisdata168='';//six bit array of ascii characters
358
+		$aisdata168 = ''; //six bit array of ascii characters
359 359
 		$ais_nmea_array = str_split($_itu); // convert to an array
360 360
 		foreach ($ais_nmea_array as $value) {
361 361
 			$dec = $this->ascii_2_dec($value);
362 362
 			$bit8 = $this->asciidec_2_8bit($dec);
363 363
 			$bit6 = $this->dec_2_6bit($bit8);
364 364
 			//echo $value ."-" .$bit6 ."";
365
-			$aisdata168 .=$bit6;
365
+			$aisdata168 .= $bit6;
366 366
 		}
367 367
 		//echo $aisdata168 . "<br/>";
368 368
 		//return $this->decode_ais($aisdata168, $aux);
@@ -385,24 +385,24 @@  discard block
 block discarded – undo
385 385
 		// calculate checksum after ! till *
386 386
 		// assume 1st ! is valid
387 387
 		// find * ensure that it is at correct position
388
-		$end = strrpos ( $rawdata , '*' );
388
+		$end = strrpos($rawdata, '*');
389 389
 		if ($end === FALSE) return -1; // check for NULLS!!!
390
-		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
392
-		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
394
-		if ( $chksum == $dcs ) { // NMEA checksum pass
390
+		$cs = substr($rawdata, $end + 1);
391
+		if (strlen($cs) != 2) return -1; // correct cs length
392
+		$dcs = (int) hexdec($cs);
393
+		for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum
394
+		if ($chksum == $dcs) { // NMEA checksum pass
395 395
 			$pcs = explode(',', $rawdata);
396 396
 			// !AI??? identifier
397 397
 			if (!isset($pcs[1])) {
398 398
 				echo "ERROR,INVALID_DATA ".time()." $rawdata\n";
399 399
 				return -1;
400 400
 			}
401
-			$num_seq = (int)$pcs[1]; // number of sequences
402
-			$seq = (int)$pcs[2]; // get sequence
401
+			$num_seq = (int) $pcs[1]; // number of sequences
402
+			$seq = (int) $pcs[2]; // get sequence
403 403
 			// get msg sequence id
404 404
 			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
405
-			else $msg_sid = (int)$pcs[3]; // multipart message
405
+			else $msg_sid = (int) $pcs[3]; // multipart message
406 406
 			$ais_ch = $pcs[4]; // get AIS channel
407 407
 			// message sequence checking
408 408
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 					}
436 436
 				}
437 437
 				$itu = $itu.$pcs[5]; // get itu message
438
-				$filler += (int)$pcs[6][0]; // get filler
438
+				$filler += (int) $pcs[6][0]; // get filler
439 439
 				if ($num_seq == 1 // valid single message
440 440
 				    || $num_seq == $pseq // valid multi-part message
441 441
 				) {
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
 		$cbuf = $cbuf.$ibuf;
456 456
 		$last_pos = 0;
457 457
 		$result = new stdClass();
458
-		while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) {
458
+		while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) {
459 459
 		//while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) {
460 460
 			//DEBUG echo $cbuf;
461
-			if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim?
461
+			if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim?
462 462
 				$tst = substr($cbuf, $start - 3, ($end - $start + 3));
463 463
 				//DEBUG echo "[$start $end $tst]\n";
464
-				$result = $this->process_ais_raw( $tst, "" );
464
+				$result = $this->process_ais_raw($tst, "");
465 465
 				$last_pos = $end + 1;
466 466
 			} else break;
467 467
 		}
@@ -473,41 +473,41 @@  discard block
 block discarded – undo
473 473
 	// incoming data from serial or IP comms
474 474
 	public function process_ais_line($cbuf) {
475 475
 		$result = new stdClass();
476
-		$start = strpos($cbuf,"VDM");
476
+		$start = strpos($cbuf, "VDM");
477 477
 		$tst = substr($cbuf, $start - 3);
478
-		$result = $this->process_ais_raw( $tst, "" );
478
+		$result = $this->process_ais_raw($tst, "");
479 479
 		return $result;
480 480
 	}
481 481
 
482 482
 	/* AIS Encoding
483 483
 	*/
484
-	private function mk_ais_lat( $lat ) {
484
+	private function mk_ais_lat($lat) {
485 485
 		//$lat = 1.2569;
486
-		if ($lat<0.0) {
486
+		if ($lat < 0.0) {
487 487
 			$lat = -$lat;
488
-			$neg=true;
489
-		} else $neg=false;
488
+			$neg = true;
489
+		} else $neg = false;
490 490
 		$latd = 0x00000000;
491
-		$latd = intval ($lat * 600000.0);
492
-		if ($neg==true) {
491
+		$latd = intval($lat*600000.0);
492
+		if ($neg == true) {
493 493
 			$latd = ~$latd;
494
-			$latd+=1;
494
+			$latd += 1;
495 495
 			$latd &= 0x07FFFFFF;
496 496
 		}
497 497
 		return $latd;
498 498
 	}
499 499
 
500
-	private function mk_ais_lon( $lon ) {
500
+	private function mk_ais_lon($lon) {
501 501
 		//$lon = 103.851;
502
-		if ($lon<0.0) {
502
+		if ($lon < 0.0) {
503 503
 			$lon = -$lon;
504
-			$neg=true;
505
-		} else $neg=false;
504
+			$neg = true;
505
+		} else $neg = false;
506 506
 		$lond = 0x00000000;
507
-		$lond = intval ($lon * 600000.0);
508
-		if ($neg==true) {
507
+		$lond = intval($lon*600000.0);
508
+		if ($neg == true) {
509 509
 			$lond = ~$lond;
510
-			$lond+=1;
510
+			$lond += 1;
511 511
 			$lond &= 0x0FFFFFFF;
512 512
 		}
513 513
 		return $lond;
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
 
516 516
 	private function char2bin($name, $max_len) {
517 517
 		$len = strlen($name);
518
-		if ($len > $max_len) $name = substr($name,0,$max_len);
519
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
518
+		if ($len > $max_len) $name = substr($name, 0, $max_len);
519
+		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6);
520 520
 		else $pad = '';
521 521
 		$rv = '';
522 522
 		$ais_chars = array(
@@ -533,26 +533,26 @@  discard block
 block discarded – undo
533 533
 		if ($_a) foreach ($_a as $_1) {
534 534
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
535 535
 			else $dec = 0;
536
-			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
536
+			$bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT);
537 537
 			$rv .= $bin;
538 538
 			//echo "$_1 $dec ($bin)<br/>";
539 539
 		}
540 540
 		return $rv.$pad;
541 541
 	}
542 542
 
543
-	private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') {
543
+	private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') {
544 544
 		$len_bit = strlen($_enc);
545
-		$rem6 = $len_bit % 6;
545
+		$rem6 = $len_bit%6;
546 546
 		$pad6_len = 0;
547 547
 		if ($rem6) $pad6_len = 6 - $rem6;
548 548
 		//echo  $pad6_len.'<br>';
549 549
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
550
-		$len_enc = strlen($_enc) / 6;
550
+		$len_enc = strlen($_enc)/6;
551 551
 		//echo $_enc.' '.$len_enc.'<br/>';
552 552
 		$itu = '';
553
-		for ($i=0; $i<$len_enc; $i++) {
554
-			$offset = $i * 6;
555
-			$dec = bindec(substr($_enc,$offset,6));
553
+		for ($i = 0; $i < $len_enc; $i++) {
554
+			$offset = $i*6;
555
+			$dec = bindec(substr($_enc, $offset, 6));
556 556
 			if ($dec < 40) $dec += 48;
557 557
 			else $dec += 56;
558 558
 			//echo chr($dec)." $dec<br/>";
@@ -562,15 +562,15 @@  discard block
 block discarded – undo
562 562
 		$chksum = 0;
563 563
 		$itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0";
564 564
 		$len_itu = strlen($itu);
565
-		for ($i=0; $i<$len_itu; $i++) {
566
-			$chksum ^= ord( $itu[$i] );
565
+		for ($i = 0; $i < $len_itu; $i++) {
566
+			$chksum ^= ord($itu[$i]);
567 567
 		}
568
-		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
569
-		$lsb = $chksum & 0x0F;
570
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
568
+		$hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
569
+		$lsb = $chksum&0x0F;
570
+		if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb];
571 571
 		else $lsbc = '0';
572
-		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
573
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
572
+		$msb = (($chksum&0xF0) >> 4)&0x0F;
573
+		if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb];
574 574
 		else $msbc = '0';
575 575
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
576 576
 		return $itu;
@@ -595,14 +595,14 @@  discard block
 block discarded – undo
595 595
 
596 596
 	public function mmsitype($mmsi) {
597 597
 		if (strlen($mmsi) == 9) {
598
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
599
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
600
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
601
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
602
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
603
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
604
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
605
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
598
+			if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
599
+			elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device';
600
+			elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
601
+			elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft';
602
+			elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship';
603
+			elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation';
604
+			elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations';
605
+			elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships';
606 606
 			else return 'Ship';
607 607
 		}
608 608
 
@@ -613,19 +613,19 @@  discard block
 block discarded – undo
613 613
 		global $globalDebug;
614 614
 		$result = array();
615 615
 		$data = new stdClass();
616
-		$start = strpos($buffer,"VDM");
616
+		$start = strpos($buffer, "VDM");
617 617
 		$tst = substr($buffer, $start - 3);
618
-		$data = $this->process_ais_raw( $tst, "" );
618
+		$data = $this->process_ais_raw($tst, "");
619 619
 		if (!is_object($data)) {
620 620
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
621 621
 			return array();
622 622
 		}
623 623
 		if ($data->lon != 0) $result['longitude'] = $data->lon;
624 624
 		if ($data->lat != 0) $result['latitude'] = $data->lat;
625
-		$result['ident'] = trim(str_replace('@','',$data->name));
625
+		$result['ident'] = trim(str_replace('@', '', $data->name));
626 626
 		$result['timestamp'] = $data->ts;
627 627
 		$result['mmsi'] = $data->mmsi;
628
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
628
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
629 629
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
630 630
 		if ($data->sog != -1.0) $result['speed'] = $data->sog;
631 631
 		if ($data->heading !== '') $result['heading'] = $data->heading;
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
 		if ($data->type !== '') $result['type'] = $data->type;
636 636
 		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
637 637
 		if ($data->imo !== '') $result['imo'] = $data->imo;
638
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
638
+		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign));
639 639
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
640
-			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
640
+			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
641 641
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
642 642
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
643
-			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
643
+			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
644 644
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
645 645
 		}
646 646
 		if ($data->destination != '') {
647
-			$dest = trim(str_replace('@','',$data->destination));
647
+			$dest = trim(str_replace('@', '', $data->destination));
648 648
 			if ($dest != '') $result['destination'] = $dest;
649 649
 		}
650 650
 		$result['all'] = (array) $data;
Please login to merge, or discard this patch.
Braces   +331 added lines, -143 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 			$temp += 1;
36 36
 			$flat = (float)($temp / (60.0 * 10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else {
39
+			$flat = (float)($temp / (60.0 * 10000.0));
40
+		}
39 41
 		return $flat; // float
40 42
 	}
41 43
 
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 			$temp += 1;
48 50
 			$flon = (float)($temp / (60.0 * 10000.0));
49 51
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
52
+		} else {
53
+			$flon = (float)($temp / (60.0 * 10000.0));
54
+		}
51 55
 		return $flon;
52 56
 	}
53 57
 
@@ -70,10 +74,8 @@  discard block
 block discarded – undo
70 74
     */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73
-		if ($ascii < 48) { }
74
-		else {
75
-			if($ascii>119) { }
76
-			else {
77
+		if ($ascii < 48) { } else {
78
+			if($ascii>119) { } else {
77 79
 				if ($ascii>87 && $ascii<96) ;
78 80
 				else {
79 81
 					$ascii=$ascii+40;
@@ -175,7 +177,9 @@  discard block
 block discarded – undo
175 177
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176 178
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177 179
 			$ro->heading = bindec(substr($_aisdata,124,9));
178
-			if ($ro->heading == 511) $ro->heading = '';
180
+			if ($ro->heading == 511) {
181
+				$ro->heading = '';
182
+			}
179 183
 			$ro->cls = 2; // class B
180 184
 		} else if ($ro->id == 19) {
181 185
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -185,7 +189,9 @@  discard block
 block discarded – undo
185 189
 			$ro->name = $this->binchar($_aisdata,143,120);
186 190
 			$ro->cls = 2; // class B
187 191
 			$ro->heading = bindec(substr($_aisdata,124,9));
188
-			if ($ro->heading == 511) $ro->heading = '';
192
+			if ($ro->heading == 511) {
193
+				$ro->heading = '';
194
+			}
189 195
 			$ro->typeid = bindec(substr($_aisdata,263,8));
190 196
 			$ro->type = $this->getShipType($ro->typeid);
191 197
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -216,9 +222,13 @@  discard block
 block discarded – undo
216 222
 			$ro->cls = 2; // class B
217 223
 		} else if ($ro->id == 27) {
218 224
 			$ro->cog = bindec(substr($_aisdata,85,9));
219
-			if ($ro->cog == 511) $ro->cog = 0.0;
225
+			if ($ro->cog == 511) {
226
+				$ro->cog = 0.0;
227
+			}
220 228
 			$ro->sog = bindec(substr($_aisdata,79,6));
221
-			if ($ro->sog == 63) $ro->sog = 0.0;
229
+			if ($ro->sog == 63) {
230
+				$ro->sog = 0.0;
231
+			}
222 232
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223 233
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
224 234
 			$ro->cls = 1; // class A
@@ -267,88 +277,171 @@  discard block
 block discarded – undo
267 277
 	}
268 278
 	
269 279
 	public function getShipType($code) {
270
-		if ($code == 0) return 'Not available (default)';
271
-		elseif ($code >= 1 && $code <= 19) return 'Reserved for future use';
272
-		elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type';
273
-		elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A';
274
-		elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B';
275
-		elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C';
276
-		elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D';
277
-		elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use';
278
-		elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use';
279
-		elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use';
280
-		elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use';
281
-		elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use';
282
-		elseif ($code == 30) return 'Fishing';
283
-		elseif ($code == 31) return 'Towing';
284
-		elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m';
285
-		elseif ($code == 33) return 'Dredging or underwater ops';
286
-		elseif ($code == 34) return 'Diving ops';
287
-		elseif ($code == 35) return 'Military ops';
288
-		elseif ($code == 36) return 'Sailing';
289
-		elseif ($code == 37) return 'Pleasure Craft';
290
-		elseif ($code == 38) return 'Reserved';
291
-		elseif ($code == 39) return 'Reserved';
292
-		elseif ($code == 40) return 'High speed craft (HSC), all ships of this type';
293
-		elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A';
294
-		elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B';
295
-		elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C';
296
-		elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D';
297
-		elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use';
298
-		elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use';
299
-		elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use';
300
-		elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use';
301
-		elseif ($code == 49) return 'High speed craft (HSC), No additional information';
302
-		elseif ($code == 50) return 'Pilot Vessel';
303
-		elseif ($code == 51) return 'Search and Rescue vessel';
304
-		elseif ($code == 52) return 'Tug';
305
-		elseif ($code == 53) return 'Port Tender';
306
-		elseif ($code == 54) return 'Anti-pollution equipment';
307
-		elseif ($code == 55) return 'Law Enforcement';
308
-		elseif ($code == 56) return 'Spare - Local Vessel';
309
-		elseif ($code == 57) return 'Spare - Local Vessel';
310
-		elseif ($code == 58) return 'Medical Transport';
311
-		elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18';
312
-		elseif ($code == 60) return 'Passenger, all ships of this type';
313
-		elseif ($code == 61) return 'Passenger, Hazardous category A';
314
-		elseif ($code == 62) return 'Passenger, Hazardous category B';
315
-		elseif ($code == 63) return 'Passenger, Hazardous category C';
316
-		elseif ($code == 64) return 'Passenger, Hazardous category D';
317
-		elseif ($code == 65) return 'Passenger, Reserved for future use';
318
-		elseif ($code == 66) return 'Passenger, Reserved for future use';
319
-		elseif ($code == 67) return 'Passenger, Reserved for future use';
320
-		elseif ($code == 68) return 'Passenger, Reserved for future use';
321
-		elseif ($code == 69) return 'Passenger, No additional information';
322
-		elseif ($code == 70) return 'Cargo, all ships of this type';
323
-		elseif ($code == 71) return 'Cargo, Hazardous category A';
324
-		elseif ($code == 72) return 'Cargo, Hazardous category B';
325
-		elseif ($code == 73) return 'Cargo, Hazardous category C';
326
-		elseif ($code == 74) return 'Cargo, Hazardous category D';
327
-		elseif ($code == 75) return 'Cargo, Reserved for future use';
328
-		elseif ($code == 76) return 'Cargo, Reserved for future use';
329
-		elseif ($code == 77) return 'Cargo, Reserved for future use';
330
-		elseif ($code == 78) return 'Cargo, Reserved for future use';
331
-		elseif ($code == 79) return 'Cargo, No additional information';
332
-		elseif ($code == 80) return 'Tanker, all ships of this type';
333
-		elseif ($code == 81) return 'Tanker, Hazardous category A';
334
-		elseif ($code == 82) return 'Tanker, Hazardous category B';
335
-		elseif ($code == 83) return 'Tanker, Hazardous category C';
336
-		elseif ($code == 84) return 'Tanker, Hazardous category D';
337
-		elseif ($code == 85) return 'Tanker, Reserved for future use';
338
-		elseif ($code == 86) return 'Tanker, Reserved for future use';
339
-		elseif ($code == 87) return 'Tanker, Reserved for future use';
340
-		elseif ($code == 88) return 'Tanker, Reserved for future use';
341
-		elseif ($code == 89) return 'Tanker, No additional information';
342
-		elseif ($code == 90) return 'Other Type, all ships of this type';
343
-		elseif ($code == 91) return 'Other Type, Hazardous category A';
344
-		elseif ($code == 92) return 'Other Type, Hazardous category B';
345
-		elseif ($code == 93) return 'Other Type, Hazardous category C';
346
-		elseif ($code == 94) return 'Other Type, Hazardous category D';
347
-		elseif ($code == 95) return 'Other Type, Reserved for future use';
348
-		elseif ($code == 96) return 'Other Type, Reserved for future use';
349
-		elseif ($code == 97) return 'Other Type, Reserved for future use';
350
-		elseif ($code == 98) return 'Other Type, Reserved for future use';
351
-		elseif ($code == 99) return 'Other Type, no additional information';
280
+		if ($code == 0) {
281
+			return 'Not available (default)';
282
+		} elseif ($code >= 1 && $code <= 19) {
283
+			return 'Reserved for future use';
284
+		} elseif ($code == 20) {
285
+			return 'Wing in ground (WIG), all ships of this type';
286
+		} elseif ($code == 21) {
287
+			return 'Wing in ground (WIG), Hazardous category A';
288
+		} elseif ($code == 22) {
289
+			return 'Wing in ground (WIG), Hazardous category B';
290
+		} elseif ($code == 23) {
291
+			return 'Wing in ground (WIG), Hazardous category C';
292
+		} elseif ($code == 24) {
293
+			return 'Wing in ground (WIG), Hazardous category D';
294
+		} elseif ($code == 25) {
295
+			return 'Wing in ground (WIG), Reserved for future use';
296
+		} elseif ($code == 26) {
297
+			return 'Wing in ground (WIG), Reserved for future use';
298
+		} elseif ($code == 27) {
299
+			return 'Wing in ground (WIG), Reserved for future use';
300
+		} elseif ($code == 28) {
301
+			return 'Wing in ground (WIG), Reserved for future use';
302
+		} elseif ($code == 29) {
303
+			return 'Wing in ground (WIG), Reserved for future use';
304
+		} elseif ($code == 30) {
305
+			return 'Fishing';
306
+		} elseif ($code == 31) {
307
+			return 'Towing';
308
+		} elseif ($code == 32) {
309
+			return 'Towing: length exceeds 200m or breadth exceeds 25m';
310
+		} elseif ($code == 33) {
311
+			return 'Dredging or underwater ops';
312
+		} elseif ($code == 34) {
313
+			return 'Diving ops';
314
+		} elseif ($code == 35) {
315
+			return 'Military ops';
316
+		} elseif ($code == 36) {
317
+			return 'Sailing';
318
+		} elseif ($code == 37) {
319
+			return 'Pleasure Craft';
320
+		} elseif ($code == 38) {
321
+			return 'Reserved';
322
+		} elseif ($code == 39) {
323
+			return 'Reserved';
324
+		} elseif ($code == 40) {
325
+			return 'High speed craft (HSC), all ships of this type';
326
+		} elseif ($code == 41) {
327
+			return 'High speed craft (HSC), Hazardous category A';
328
+		} elseif ($code == 42) {
329
+			return 'High speed craft (HSC), Hazardous category B';
330
+		} elseif ($code == 43) {
331
+			return 'High speed craft (HSC), Hazardous category C';
332
+		} elseif ($code == 44) {
333
+			return 'High speed craft (HSC), Hazardous category D';
334
+		} elseif ($code == 45) {
335
+			return 'High speed craft (HSC), Reserved for future use';
336
+		} elseif ($code == 46) {
337
+			return 'High speed craft (HSC), Reserved for future use';
338
+		} elseif ($code == 47) {
339
+			return 'High speed craft (HSC), Reserved for future use';
340
+		} elseif ($code == 48) {
341
+			return 'High speed craft (HSC), Reserved for future use';
342
+		} elseif ($code == 49) {
343
+			return 'High speed craft (HSC), No additional information';
344
+		} elseif ($code == 50) {
345
+			return 'Pilot Vessel';
346
+		} elseif ($code == 51) {
347
+			return 'Search and Rescue vessel';
348
+		} elseif ($code == 52) {
349
+			return 'Tug';
350
+		} elseif ($code == 53) {
351
+			return 'Port Tender';
352
+		} elseif ($code == 54) {
353
+			return 'Anti-pollution equipment';
354
+		} elseif ($code == 55) {
355
+			return 'Law Enforcement';
356
+		} elseif ($code == 56) {
357
+			return 'Spare - Local Vessel';
358
+		} elseif ($code == 57) {
359
+			return 'Spare - Local Vessel';
360
+		} elseif ($code == 58) {
361
+			return 'Medical Transport';
362
+		} elseif ($code == 59) {
363
+			return 'Noncombatant ship according to RR Resolution No. 18';
364
+		} elseif ($code == 60) {
365
+			return 'Passenger, all ships of this type';
366
+		} elseif ($code == 61) {
367
+			return 'Passenger, Hazardous category A';
368
+		} elseif ($code == 62) {
369
+			return 'Passenger, Hazardous category B';
370
+		} elseif ($code == 63) {
371
+			return 'Passenger, Hazardous category C';
372
+		} elseif ($code == 64) {
373
+			return 'Passenger, Hazardous category D';
374
+		} elseif ($code == 65) {
375
+			return 'Passenger, Reserved for future use';
376
+		} elseif ($code == 66) {
377
+			return 'Passenger, Reserved for future use';
378
+		} elseif ($code == 67) {
379
+			return 'Passenger, Reserved for future use';
380
+		} elseif ($code == 68) {
381
+			return 'Passenger, Reserved for future use';
382
+		} elseif ($code == 69) {
383
+			return 'Passenger, No additional information';
384
+		} elseif ($code == 70) {
385
+			return 'Cargo, all ships of this type';
386
+		} elseif ($code == 71) {
387
+			return 'Cargo, Hazardous category A';
388
+		} elseif ($code == 72) {
389
+			return 'Cargo, Hazardous category B';
390
+		} elseif ($code == 73) {
391
+			return 'Cargo, Hazardous category C';
392
+		} elseif ($code == 74) {
393
+			return 'Cargo, Hazardous category D';
394
+		} elseif ($code == 75) {
395
+			return 'Cargo, Reserved for future use';
396
+		} elseif ($code == 76) {
397
+			return 'Cargo, Reserved for future use';
398
+		} elseif ($code == 77) {
399
+			return 'Cargo, Reserved for future use';
400
+		} elseif ($code == 78) {
401
+			return 'Cargo, Reserved for future use';
402
+		} elseif ($code == 79) {
403
+			return 'Cargo, No additional information';
404
+		} elseif ($code == 80) {
405
+			return 'Tanker, all ships of this type';
406
+		} elseif ($code == 81) {
407
+			return 'Tanker, Hazardous category A';
408
+		} elseif ($code == 82) {
409
+			return 'Tanker, Hazardous category B';
410
+		} elseif ($code == 83) {
411
+			return 'Tanker, Hazardous category C';
412
+		} elseif ($code == 84) {
413
+			return 'Tanker, Hazardous category D';
414
+		} elseif ($code == 85) {
415
+			return 'Tanker, Reserved for future use';
416
+		} elseif ($code == 86) {
417
+			return 'Tanker, Reserved for future use';
418
+		} elseif ($code == 87) {
419
+			return 'Tanker, Reserved for future use';
420
+		} elseif ($code == 88) {
421
+			return 'Tanker, Reserved for future use';
422
+		} elseif ($code == 89) {
423
+			return 'Tanker, No additional information';
424
+		} elseif ($code == 90) {
425
+			return 'Other Type, all ships of this type';
426
+		} elseif ($code == 91) {
427
+			return 'Other Type, Hazardous category A';
428
+		} elseif ($code == 92) {
429
+			return 'Other Type, Hazardous category B';
430
+		} elseif ($code == 93) {
431
+			return 'Other Type, Hazardous category C';
432
+		} elseif ($code == 94) {
433
+			return 'Other Type, Hazardous category D';
434
+		} elseif ($code == 95) {
435
+			return 'Other Type, Reserved for future use';
436
+		} elseif ($code == 96) {
437
+			return 'Other Type, Reserved for future use';
438
+		} elseif ($code == 97) {
439
+			return 'Other Type, Reserved for future use';
440
+		} elseif ($code == 98) {
441
+			return 'Other Type, Reserved for future use';
442
+		} elseif ($code == 99) {
443
+			return 'Other Type, no additional information';
444
+		}
352 445
 	}
353 446
 
354 447
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -386,11 +479,20 @@  discard block
 block discarded – undo
386 479
 		// assume 1st ! is valid
387 480
 		// find * ensure that it is at correct position
388 481
 		$end = strrpos ( $rawdata , '*' );
389
-		if ($end === FALSE) return -1; // check for NULLS!!!
482
+		if ($end === FALSE) {
483
+			return -1;
484
+		}
485
+		// check for NULLS!!!
390 486
 		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
487
+		if ( strlen($cs) != 2 ) {
488
+			return -1;
489
+		}
490
+		// correct cs length
392 491
 		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
492
+		for ( $alias=1; $alias<$end; $alias++) {
493
+			$chksum ^= ord( $rawdata[$alias] );
494
+		}
495
+		// perform XOR for NMEA checksum
394 496
 		if ( $chksum == $dcs ) { // NMEA checksum pass
395 497
 			$pcs = explode(',', $rawdata);
396 498
 			// !AI??? identifier
@@ -401,8 +503,14 @@  discard block
 block discarded – undo
401 503
 			$num_seq = (int)$pcs[1]; // number of sequences
402 504
 			$seq = (int)$pcs[2]; // get sequence
403 505
 			// get msg sequence id
404
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
405
-			else $msg_sid = (int)$pcs[3]; // multipart message
506
+			if ($pcs[3] == '') {
507
+				$msg_sid = -1;
508
+			}
509
+			// non-multipart message, set to -1
510
+			else {
511
+				$msg_sid = (int)$pcs[3];
512
+			}
513
+			// multipart message
406 514
 			$ais_ch = $pcs[4]; // get AIS channel
407 515
 			// message sequence checking
408 516
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -463,10 +571,18 @@  discard block
 block discarded – undo
463 571
 				//DEBUG echo "[$start $end $tst]\n";
464 572
 				$result = $this->process_ais_raw( $tst, "" );
465 573
 				$last_pos = $end + 1;
466
-			} else break;
574
+			} else {
575
+				break;
576
+			}
467 577
 		}
468
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
469
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
578
+		if ($last_pos > 0) {
579
+			$cbuf = substr($cbuf, $last_pos);
580
+		}
581
+		// move...
582
+		if (strlen($cbuf) > 1024) {
583
+			$cbuf = "";
584
+		}
585
+		// prevent overflow simple mode...
470 586
 		return $result;
471 587
 	}
472 588
 
@@ -486,7 +602,9 @@  discard block
 block discarded – undo
486 602
 		if ($lat<0.0) {
487 603
 			$lat = -$lat;
488 604
 			$neg=true;
489
-		} else $neg=false;
605
+		} else {
606
+			$neg=false;
607
+		}
490 608
 		$latd = 0x00000000;
491 609
 		$latd = intval ($lat * 600000.0);
492 610
 		if ($neg==true) {
@@ -502,7 +620,9 @@  discard block
 block discarded – undo
502 620
 		if ($lon<0.0) {
503 621
 			$lon = -$lon;
504 622
 			$neg=true;
505
-		} else $neg=false;
623
+		} else {
624
+			$neg=false;
625
+		}
506 626
 		$lond = 0x00000000;
507 627
 		$lond = intval ($lon * 600000.0);
508 628
 		if ($neg==true) {
@@ -515,9 +635,14 @@  discard block
 block discarded – undo
515 635
 
516 636
 	private function char2bin($name, $max_len) {
517 637
 		$len = strlen($name);
518
-		if ($len > $max_len) $name = substr($name,0,$max_len);
519
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
520
-		else $pad = '';
638
+		if ($len > $max_len) {
639
+			$name = substr($name,0,$max_len);
640
+		}
641
+		if ($len < $max_len) {
642
+			$pad = str_repeat('0', ($max_len - $len) * 6);
643
+		} else {
644
+			$pad = '';
645
+		}
521 646
 		$rv = '';
522 647
 		$ais_chars = array(
523 648
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -530,9 +655,12 @@  discard block
 block discarded – undo
530 655
 		);
531 656
 		// "
532 657
 		$_a = str_split($name);
533
-		if ($_a) foreach ($_a as $_1) {
658
+		if ($_a) {
659
+			foreach ($_a as $_1) {
534 660
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
535
-			else $dec = 0;
661
+		} else {
662
+				$dec = 0;
663
+			}
536 664
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
537 665
 			$rv .= $bin;
538 666
 			//echo "$_1 $dec ($bin)<br/>";
@@ -544,7 +672,9 @@  discard block
 block discarded – undo
544 672
 		$len_bit = strlen($_enc);
545 673
 		$rem6 = $len_bit % 6;
546 674
 		$pad6_len = 0;
547
-		if ($rem6) $pad6_len = 6 - $rem6;
675
+		if ($rem6) {
676
+			$pad6_len = 6 - $rem6;
677
+		}
548 678
 		//echo  $pad6_len.'<br>';
549 679
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
550 680
 		$len_enc = strlen($_enc) / 6;
@@ -553,8 +683,11 @@  discard block
 block discarded – undo
553 683
 		for ($i=0; $i<$len_enc; $i++) {
554 684
 			$offset = $i * 6;
555 685
 			$dec = bindec(substr($_enc,$offset,6));
556
-			if ($dec < 40) $dec += 48;
557
-			else $dec += 56;
686
+			if ($dec < 40) {
687
+				$dec += 48;
688
+			} else {
689
+				$dec += 56;
690
+			}
558 691
 			//echo chr($dec)." $dec<br/>";
559 692
 			$itu .= chr($dec);
560 693
 		}
@@ -567,25 +700,41 @@  discard block
 block discarded – undo
567 700
 		}
568 701
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
569 702
 		$lsb = $chksum & 0x0F;
570
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
571
-		else $lsbc = '0';
703
+		if ($lsb >=0 && $lsb <= 15 ) {
704
+			$lsbc = $hex_arr[$lsb];
705
+		} else {
706
+			$lsbc = '0';
707
+		}
572 708
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
573
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
574
-		else $msbc = '0';
709
+		if ($msb >=0 && $msb <= 15 ) {
710
+			$msbc = $hex_arr[$msb];
711
+		} else {
712
+			$msbc = '0';
713
+		}
575 714
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
576 715
 		return $itu;
577 716
 	}
578 717
 
579 718
 	public function parse($buffer) {
580 719
 		$data = $this->process_ais_buf($buffer);
581
-		if (!is_object($data)) return array();
582
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
583
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
720
+		if (!is_object($data)) {
721
+			return array();
722
+		}
723
+		if ($data->lon != 0) {
724
+			$result['longitude'] = $data->lon;
725
+		}
726
+		if ($data->lat != 0) {
727
+			$result['latitude'] = $data->lat;
728
+		}
584 729
 		$result['ident'] = trim($data->name);
585 730
 		$result['timestamp'] = $data->ts;
586 731
 		$result['mmsi'] = $data->mmsi;
587
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
588
-		if ($data->cog != 0) $result['heading'] = $data->cog;
732
+		if ($data->sog != -1.0) {
733
+			$result['speed'] = $data->sog;
734
+		}
735
+		if ($data->cog != 0) {
736
+			$result['heading'] = $data->cog;
737
+		}
589 738
 		/*
590 739
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
591 740
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -595,15 +744,25 @@  discard block
 block discarded – undo
595 744
 
596 745
 	public function mmsitype($mmsi) {
597 746
 		if (strlen($mmsi) == 9) {
598
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
599
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
600
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
601
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
602
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
603
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
604
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
605
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
606
-			else return 'Ship';
747
+			if (substr($mmsi,0,3) == '974') {
748
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
749
+			} elseif (substr($mmsi,0,3) == '972') {
750
+				return 'MOB (Man Overboard) device';
751
+			} elseif (substr($mmsi,0,3) == '970') {
752
+				return 'AIS SART (Search and Rescue Transmitter)';
753
+			} elseif (substr($mmsi,0,3) == '111') {
754
+				return 'SAR (Search and Rescue) aircraft';
755
+			} elseif (substr($mmsi,0,2) == '98') {
756
+				return 'Auxiliary craft associated with a parent ship';
757
+			} elseif (substr($mmsi,0,2) == '99') {
758
+				return 'Aids to Navigation';
759
+			} elseif (substr($mmsi,0,2) == '00') {
760
+				return 'Coastal stations';
761
+			} elseif (substr($mmsi,0,1) == '0') {
762
+				return 'Group of ships';
763
+			} else {
764
+				return 'Ship';
765
+			}
607 766
 		}
608 767
 
609 768
 	
@@ -620,32 +779,61 @@  discard block
 block discarded – undo
620 779
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
621 780
 			return array();
622 781
 		}
623
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
624
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
782
+		if ($data->lon != 0) {
783
+			$result['longitude'] = $data->lon;
784
+		}
785
+		if ($data->lat != 0) {
786
+			$result['latitude'] = $data->lat;
787
+		}
625 788
 		$result['ident'] = trim(str_replace('@','',$data->name));
626 789
 		$result['timestamp'] = $data->ts;
627 790
 		$result['mmsi'] = $data->mmsi;
628
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
791
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
792
+			$result['mmsi'] = '3'.$result['mmsi'];
793
+		}
629 794
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
630
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
631
-		if ($data->heading !== '') $result['heading'] = $data->heading;
632
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
633
-		if ($data->status != '') $result['status'] = $data->status;
634
-		if ($data->statusid !== '') $result['statusid'] = $data->statusid;
635
-		if ($data->type !== '') $result['type'] = $data->type;
636
-		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
637
-		if ($data->imo !== '') $result['imo'] = $data->imo;
638
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
795
+		if ($data->sog != -1.0) {
796
+			$result['speed'] = $data->sog;
797
+		}
798
+		if ($data->heading !== '') {
799
+			$result['heading'] = $data->heading;
800
+		} elseif ($data->cog != 0) {
801
+			$result['heading'] = $data->cog;
802
+		}
803
+		if ($data->status != '') {
804
+			$result['status'] = $data->status;
805
+		}
806
+		if ($data->statusid !== '') {
807
+			$result['statusid'] = $data->statusid;
808
+		}
809
+		if ($data->type !== '') {
810
+			$result['type'] = $data->type;
811
+		}
812
+		if ($data->typeid !== '') {
813
+			$result['typeid'] = $data->typeid;
814
+		}
815
+		if ($data->imo !== '') {
816
+			$result['imo'] = $data->imo;
817
+		}
818
+		if ($data->callsign !== '') {
819
+			$result['callsign'] = trim(str_replace('@','',$data->callsign));
820
+		}
639 821
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
640 822
 			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
641
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
823
+			if ($eta_ts != '') {
824
+				$result['eta_ts'] = $eta_ts;
825
+			}
642 826
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
643 827
 			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
644
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
828
+			if ($eta_ts != '') {
829
+				$result['eta_ts'] = $eta_ts;
830
+			}
645 831
 		}
646 832
 		if ($data->destination != '') {
647 833
 			$dest = trim(str_replace('@','',$data->destination));
648
-			if ($dest != '') $result['destination'] = $dest;
834
+			if ($dest != '') {
835
+				$result['destination'] = $dest;
836
+			}
649 837
 		}
650 838
 		$result['all'] = (array) $data;
651 839
 		/*
Please login to merge, or discard this patch.
accident.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
4 4
 if ($date == '') $date = date('Y-m-d');
5 5
 header('Location: '.$globalURL.'/accident/'.$date);
6 6
 ?>
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/accident/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
statistics-fatalities-year.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 print '<div id="chart" class="chart" width="100%"></div><script>';
20 20
 $year_data = '';
21 21
 $year_cnt = '';
22
-foreach($date_array as $year_item)
22
+foreach ($date_array as $year_item)
23 23
 {
24 24
 	$year_data .= '"'.$year_item['year'].'-01-01",';
25 25
 	$year_cnt .= $year_item['count'].',';
26 26
 }
27 27
 $year_data = "['x',".substr($year_data, 0, -1)."]";
28
-$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
28
+$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
29 29
 print 'c3.generate({
30 30
     bindto: "#chart",
31 31
     data: { x: "x",
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 
36 36
 if (!empty($date_array))
37 37
 {
38
-	foreach($date_array as $key => $row) {
38
+	foreach ($date_array as $key => $row) {
39 39
 		$years[$key] = $row['year'];
40 40
 		$counts[$key] = $row['count'];
41 41
 	}
42 42
 	//array_multisort($years,SORT_DESC,$date_array);
43
-	array_multisort($counts,SORT_DESC,$date_array);
43
+	array_multisort($counts, SORT_DESC, $date_array);
44 44
 	print '<div class="table-responsive">';
45 45
 	print '<table class="common-date table-striped">';
46 46
 	print '<thead>';
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	print '</thead>';
51 51
 	print '<tbody>';
52 52
 	$i = 1;
53
-	foreach($date_array as $date_item)
53
+	foreach ($date_array as $date_item)
54 54
 	{
55 55
 		print '<tr>';
56 56
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.