Completed
Push — master ( 7bb360...c01d59 )
by Yannick
22:07
created
require/class.Marine.php 3 patches
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	/**
14
-	* Get SQL query part for filter used
15
-	* @param Array $filter the filter
16
-	* @return Array the SQL part
17
-	*/
14
+	 * Get SQL query part for filter used
15
+	 * @param Array $filter the filter
16
+	 * @return Array the SQL part
17
+	 */
18 18
 	
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	}
79 79
 
80 80
 	/**
81
-	* Executes the SQL statements to get the spotter information
82
-	*
83
-	* @param String $query the SQL query
84
-	* @param Array $params parameter of the query
85
-	* @param String $limitQuery the limit query
86
-	* @return Array the spotter information
87
-	*
88
-	*/
81
+	 * Executes the SQL statements to get the spotter information
82
+	 *
83
+	 * @param String $query the SQL query
84
+	 * @param Array $params parameter of the query
85
+	 * @param String $limitQuery the limit query
86
+	 * @return Array the spotter information
87
+	 *
88
+	 */
89 89
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	
214 214
 	
215 215
 	/**
216
-	* Gets all the spotter information based on the latest data entry
217
-	*
218
-	* @return Array the spotter information
219
-	*
220
-	*/
216
+	 * Gets all the spotter information based on the latest data entry
217
+	 *
218
+	 * @return Array the spotter information
219
+	 *
220
+	 */
221 221
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
222 222
 	{
223 223
 		global $global_query;
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 	}
267 267
 
268 268
 	/**
269
-	* Gets all the spotter information based on the callsign
270
-	*
271
-	* @return Array the spotter information
272
-	*
273
-	*/
269
+	 * Gets all the spotter information based on the callsign
270
+	 *
271
+	 * @return Array the spotter information
272
+	 *
273
+	 */
274 274
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
275 275
 	{
276 276
 		global $global_query;
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
 
382 382
 
383 383
 	/**
384
-	* Gets all source name
385
-	*
386
-	* @param String type format of source
387
-	* @return Array list of source name
388
-	*
389
-	*/
384
+	 * Gets all source name
385
+	 *
386
+	 * @param String type format of source
387
+	 * @return Array list of source name
388
+	 *
389
+	 */
390 390
 	public function getAllSourceName($type = '',$filters = array())
391 391
 	{
392 392
 		$filter_query = $this->getFilter($filters,true,true);
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 
417 417
 
418 418
 	/**
419
-	* Gets a list of all idents/callsigns
420
-	*
421
-	* @return Array list of ident/callsign names
422
-	*
423
-	*/
419
+	 * Gets a list of all idents/callsigns
420
+	 *
421
+	 * @return Array list of ident/callsign names
422
+	 *
423
+	 */
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426 426
 		$filter_query = $this->getFilter($filters,true,true);
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
 	}
445 445
 
446 446
 	/**
447
-	* Gets all info from a mmsi
448
-	*
449
-	* @return Array list of mmsi info
450
-	*
451
-	*/
447
+	 * Gets all info from a mmsi
448
+	 *
449
+	 * @return Array list of mmsi info
450
+	 *
451
+	 */
452 452
 	public function getIdentity($mmsi)
453 453
 	{
454 454
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -505,18 +505,18 @@  discard block
 block discarded – undo
505 505
 	
506 506
 	
507 507
 	/**
508
-	* Update ident tracker data
509
-	*
510
-	* @param String $fammarine_id the ID
511
-	* @param String $ident the marine ident
512
-	* @return String success or false
513
-	*
514
-	*/	
508
+	 * Update ident tracker data
509
+	 *
510
+	 * @param String $fammarine_id the ID
511
+	 * @param String $ident the marine ident
512
+	 * @return String success or false
513
+	 *
514
+	 */	
515 515
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
516 516
 	{
517 517
 
518 518
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
519
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
519
+				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
520 520
 
521 521
 		try {
522 522
 			$sth = $this->db->prepare($query);
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
 	}
531 531
 
532 532
 	/**
533
-	* Update Status data
534
-	*
535
-	* @param String $fammarine_id the ID
536
-	* @param String $status_id the marine status id
537
-	* @param String $status the marine status
538
-	* @return String success or false
539
-	*
540
-	*/	
533
+	 * Update Status data
534
+	 *
535
+	 * @param String $fammarine_id the ID
536
+	 * @param String $status_id the marine status id
537
+	 * @param String $status the marine status
538
+	 * @return String success or false
539
+	 *
540
+	 */	
541 541
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
542 542
 	{
543 543
 
544 544
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
545
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
545
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
546 546
 
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
@@ -555,17 +555,17 @@  discard block
 block discarded – undo
555 555
 
556 556
 	}
557 557
 	/**
558
-	* Update latest marine data
559
-	*
560
-	* @param String $fammarine_id the ID
561
-	* @param String $ident the marine ident
562
-	* @return String success or false
563
-	*
564
-	*/	
558
+	 * Update latest marine data
559
+	 *
560
+	 * @param String $fammarine_id the ID
561
+	 * @param String $ident the marine ident
562
+	 * @return String success or false
563
+	 *
564
+	 */	
565 565
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
566 566
 	{
567 567
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
568
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
568
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
@@ -579,30 +579,30 @@  discard block
 block discarded – undo
579 579
 	}
580 580
 
581 581
 	/**
582
-	* Adds a new spotter data
583
-	*
584
-	* @param String $fammarine_id the ID
585
-	* @param String $ident the marine ident
586
-	* @param String $departure_airport_icao the departure airport
587
-	* @param String $arrival_airport_icao the arrival airport
588
-	* @param String $latitude latitude of flight
589
-	* @param String $longitude latitude of flight
590
-	* @param String $waypoints waypoints of flight
591
-	* @param String $heading heading of flight
592
-	* @param String $groundspeed speed of flight
593
-	* @param String $date date of flight
594
-	* @param String $departure_airport_time departure time of flight
595
-	* @param String $arrival_airport_time arrival time of flight
596
-	* @param String $squawk squawk code of flight
597
-	* @param String $route_stop route stop of flight
598
-	* @param String $highlight highlight or not
599
-	* @param String $ModeS ModesS code of flight
600
-	* @param String $registration registration code of flight
601
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
602
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
603
-	* @param String $verticalrate vertival rate of flight
604
-	* @return String success or false
605
-	*/
582
+	 * Adds a new spotter data
583
+	 *
584
+	 * @param String $fammarine_id the ID
585
+	 * @param String $ident the marine ident
586
+	 * @param String $departure_airport_icao the departure airport
587
+	 * @param String $arrival_airport_icao the arrival airport
588
+	 * @param String $latitude latitude of flight
589
+	 * @param String $longitude latitude of flight
590
+	 * @param String $waypoints waypoints of flight
591
+	 * @param String $heading heading of flight
592
+	 * @param String $groundspeed speed of flight
593
+	 * @param String $date date of flight
594
+	 * @param String $departure_airport_time departure time of flight
595
+	 * @param String $arrival_airport_time arrival time of flight
596
+	 * @param String $squawk squawk code of flight
597
+	 * @param String $route_stop route stop of flight
598
+	 * @param String $highlight highlight or not
599
+	 * @param String $ModeS ModesS code of flight
600
+	 * @param String $registration registration code of flight
601
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
602
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
603
+	 * @param String $verticalrate vertival rate of flight
604
+	 * @return String success or false
605
+	 */
606 606
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
607 607
 	{
608 608
 		global $globalURL, $globalMarineImageFetch;
@@ -699,13 +699,13 @@  discard block
 block discarded – undo
699 699
 			unset($Image);
700 700
 		}
701 701
 		
702
-                if ($latitude == '' && $longitude == '') {
703
-            		$latitude = 0;
704
-            		$longitude = 0;
705
-            	}
706
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
-                if ($arrival_date == '') $arrival_date = NULL;
702
+				if ($latitude == '' && $longitude == '') {
703
+					$latitude = 0;
704
+					$longitude = 0;
705
+				}
706
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
+				if ($arrival_date == '') $arrival_date = NULL;
709 709
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 710
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 711
 
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 			$sth->execute($query_values);
717 717
 			$this->db = null;
718 718
 		} catch (PDOException $e) {
719
-		    return "error : ".$e->getMessage();
719
+			return "error : ".$e->getMessage();
720 720
 		}
721 721
 		
722 722
 		return "success";
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
 	
726 726
   
727 727
 	/**
728
-	* Gets the aircraft ident within the last hour
729
-	*
730
-	* @return String the ident
731
-	*
732
-	*/
728
+	 * Gets the aircraft ident within the last hour
729
+	 *
730
+	 * @return String the ident
731
+	 *
732
+	 */
733 733
 	public function getIdentFromLastHour($ident)
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
746 746
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
747 747
 			$query_data = array(':ident' => $ident);
748
-    		}
748
+			}
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-    		$ident_result='';
752
+			$ident_result='';
753 753
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['ident'];
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 	
761 761
 	
762 762
 	/**
763
-	* Gets the aircraft data from the last 20 seconds
764
-	*
765
-	* @return Array the spotter data
766
-	*
767
-	*/
763
+	 * Gets the aircraft data from the last 20 seconds
764
+	 *
765
+	 * @return Array the spotter data
766
+	 *
767
+	 */
768 768
 	public function getRealTimeData($q = '')
769 769
 	{
770 770
 		global $globalDBdriver;
@@ -802,11 +802,11 @@  discard block
 block discarded – undo
802 802
 	
803 803
 
804 804
 	/**
805
-	* Gets all number of flight over countries
806
-	*
807
-	* @return Array the airline country list
808
-	*
809
-	*/
805
+	 * Gets all number of flight over countries
806
+	 *
807
+	 * @return Array the airline country list
808
+	 *
809
+	 */
810 810
 
811 811
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
812 812
 	{
@@ -879,11 +879,11 @@  discard block
 block discarded – undo
879 879
 	
880 880
 	
881 881
 	/**
882
-	* Gets all callsigns that have flown over
883
-	*
884
-	* @return Array the callsign list
885
-	*
886
-	*/
882
+	 * Gets all callsigns that have flown over
883
+	 *
884
+	 * @return Array the callsign list
885
+	 *
886
+	 */
887 887
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
888 888
 	{
889 889
 		global $globalDBdriver;
@@ -950,11 +950,11 @@  discard block
 block discarded – undo
950 950
 
951 951
 
952 952
 	/**
953
-	* Counts all dates
954
-	*
955
-	* @return Array the date list
956
-	*
957
-	*/
953
+	 * Counts all dates
954
+	 *
955
+	 * @return Array the date list
956
+	 *
957
+	 */
958 958
 	public function countAllDates($filters = array())
959 959
 	{
960 960
 		global $globalTimezone, $globalDBdriver;
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
 	
1001 1001
 	
1002 1002
 	/**
1003
-	* Counts all dates during the last 7 days
1004
-	*
1005
-	* @return Array the date list
1006
-	*
1007
-	*/
1003
+	 * Counts all dates during the last 7 days
1004
+	 *
1005
+	 * @return Array the date list
1006
+	 *
1007
+	 */
1008 1008
 	public function countAllDatesLast7Days($filters = array())
1009 1009
 	{
1010 1010
 		global $globalTimezone, $globalDBdriver;
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 			$query .= " GROUP BY date_name 
1027 1027
 								ORDER BY date_name ASC";
1028 1028
 			$query_data = array(':offset' => $offset);
1029
-    		}
1029
+			}
1030 1030
 		
1031 1031
 		$sth = $this->db->prepare($query);
1032 1032
 		$sth->execute($query_data);
@@ -1046,11 +1046,11 @@  discard block
 block discarded – undo
1046 1046
 	}
1047 1047
 
1048 1048
 	/**
1049
-	* Counts all dates during the last month
1050
-	*
1051
-	* @return Array the date list
1052
-	*
1053
-	*/
1049
+	 * Counts all dates during the last month
1050
+	 *
1051
+	 * @return Array the date list
1052
+	 *
1053
+	 */
1054 1054
 	public function countAllDatesLastMonth($filters = array())
1055 1055
 	{
1056 1056
 		global $globalTimezone, $globalDBdriver;
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 			$query .= " GROUP BY date_name 
1073 1073
 								ORDER BY date_name ASC";
1074 1074
 			$query_data = array(':offset' => $offset);
1075
-    		}
1075
+			}
1076 1076
 		
1077 1077
 		$sth = $this->db->prepare($query);
1078 1078
 		$sth->execute($query_data);
@@ -1094,11 +1094,11 @@  discard block
 block discarded – undo
1094 1094
 
1095 1095
 
1096 1096
 	/**
1097
-	* Counts all month
1098
-	*
1099
-	* @return Array the month list
1100
-	*
1101
-	*/
1097
+	 * Counts all month
1098
+	 *
1099
+	 * @return Array the month list
1100
+	 *
1101
+	 */
1102 1102
 	public function countAllMonths($filters = array())
1103 1103
 	{
1104 1104
 		global $globalTimezone, $globalDBdriver;
@@ -1143,11 +1143,11 @@  discard block
 block discarded – undo
1143 1143
 	
1144 1144
 
1145 1145
 	/**
1146
-	* Counts all dates during the last year
1147
-	*
1148
-	* @return Array the date list
1149
-	*
1150
-	*/
1146
+	 * Counts all dates during the last year
1147
+	 *
1148
+	 * @return Array the date list
1149
+	 *
1150
+	 */
1151 1151
 	public function countAllMonthsLastYear($filters)
1152 1152
 	{
1153 1153
 		global $globalTimezone, $globalDBdriver;
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 			$query .= " GROUP BY year_name, month_name
1170 1170
 								ORDER BY year_name, month_name ASC";
1171 1171
 			$query_data = array(':offset' => $offset);
1172
-    		}
1172
+			}
1173 1173
 		
1174 1174
 		$sth = $this->db->prepare($query);
1175 1175
 		$sth->execute($query_data);
@@ -1192,11 +1192,11 @@  discard block
 block discarded – undo
1192 1192
 	
1193 1193
 	
1194 1194
 	/**
1195
-	* Counts all hours
1196
-	*
1197
-	* @return Array the hour list
1198
-	*
1199
-	*/
1195
+	 * Counts all hours
1196
+	 *
1197
+	 * @return Array the hour list
1198
+	 *
1199
+	 */
1200 1200
 	public function countAllHours($orderby,$filters = array())
1201 1201
 	{
1202 1202
 		global $globalTimezone, $globalDBdriver;
@@ -1259,11 +1259,11 @@  discard block
 block discarded – undo
1259 1259
 	
1260 1260
 	
1261 1261
 	/**
1262
-	* Counts all hours by date
1263
-	*
1264
-	* @return Array the hour list
1265
-	*
1266
-	*/
1262
+	 * Counts all hours by date
1263
+	 *
1264
+	 * @return Array the hour list
1265
+	 *
1266
+	 */
1267 1267
 	public function countAllHoursByDate($date, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
@@ -1307,11 +1307,11 @@  discard block
 block discarded – undo
1307 1307
 	
1308 1308
 	
1309 1309
 	/**
1310
-	* Counts all hours by a ident/callsign
1311
-	*
1312
-	* @return Array the hour list
1313
-	*
1314
-	*/
1310
+	 * Counts all hours by a ident/callsign
1311
+	 *
1312
+	 * @return Array the hour list
1313
+	 *
1314
+	 */
1315 1315
 	public function countAllHoursByIdent($ident, $filters = array())
1316 1316
 	{
1317 1317
 		global $globalTimezone, $globalDBdriver;
@@ -1356,11 +1356,11 @@  discard block
 block discarded – undo
1356 1356
 	
1357 1357
 	
1358 1358
 	/**
1359
-	* Counts all flights that have flown over
1360
-	*
1361
-	* @return Integer the number of flights
1362
-	*
1363
-	*/
1359
+	 * Counts all flights that have flown over
1360
+	 *
1361
+	 * @return Integer the number of flights
1362
+	 *
1363
+	 */
1364 1364
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1365 1365
 	{
1366 1366
 		global $globalDBdriver;
@@ -1396,11 +1396,11 @@  discard block
 block discarded – undo
1396 1396
 	
1397 1397
   
1398 1398
 	/**
1399
-	* Counts all hours of today
1400
-	*
1401
-	* @return Array the hour list
1402
-	*
1403
-	*/
1399
+	 * Counts all hours of today
1400
+	 *
1401
+	 * @return Array the hour list
1402
+	 *
1403
+	 */
1404 1404
 	public function countAllHoursFromToday($filters = array())
1405 1405
 	{
1406 1406
 		global $globalTimezone, $globalDBdriver;
@@ -1440,12 +1440,12 @@  discard block
 block discarded – undo
1440 1440
 	}
1441 1441
     
1442 1442
     
1443
-     /**
1444
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1445
-	*
1446
-	* @return Integer the Barrie Spotter ID
1443
+	 /**
1444
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1445
+	  *
1446
+	  * @return Integer the Barrie Spotter ID
1447 1447
 q	*
1448
-	*/
1448
+	  */
1449 1449
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1450 1450
 	{
1451 1451
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1466,13 +1466,13 @@  discard block
 block discarded – undo
1466 1466
   
1467 1467
  
1468 1468
 	/**
1469
-	* Parses a date string
1470
-	*
1471
-	* @param String $dateString the date string
1472
-	* @param String $timezone the timezone of a user
1473
-	* @return Array the time information
1474
-	*
1475
-	*/
1469
+	 * Parses a date string
1470
+	 *
1471
+	 * @param String $dateString the date string
1472
+	 * @param String $timezone the timezone of a user
1473
+	 * @return Array the time information
1474
+	 *
1475
+	 */
1476 1476
 	public function parseDateString($dateString, $timezone = '')
1477 1477
 	{
1478 1478
 		$time_array = array();
@@ -1505,12 +1505,12 @@  discard block
 block discarded – undo
1505 1505
 	}
1506 1506
 	
1507 1507
 	/**
1508
-	* Parses the direction degrees to working
1509
-	*
1510
-	* @param Float $direction the direction in degrees
1511
-	* @return Array the direction information
1512
-	*
1513
-	*/
1508
+	 * Parses the direction degrees to working
1509
+	 *
1510
+	 * @param Float $direction the direction in degrees
1511
+	 * @return Array the direction information
1512
+	 *
1513
+	 */
1514 1514
 	public function parseDirection($direction = 0)
1515 1515
 	{
1516 1516
 		if ($direction == '') $direction = 0;
@@ -1589,12 +1589,12 @@  discard block
 block discarded – undo
1589 1589
 	
1590 1590
 	
1591 1591
 	/**
1592
-	* Gets Country from latitude/longitude
1593
-	*
1594
-	* @param Float $latitude latitute of the flight
1595
-	* @param Float $longitude longitute of the flight
1596
-	* @return String the countrie
1597
-	*/
1592
+	 * Gets Country from latitude/longitude
1593
+	 *
1594
+	 * @param Float $latitude latitute of the flight
1595
+	 * @param Float $longitude longitute of the flight
1596
+	 * @return String the countrie
1597
+	 */
1598 1598
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1599 1599
 	{
1600 1600
 		global $globalDBdriver, $globalDebug;
@@ -1631,11 +1631,11 @@  discard block
 block discarded – undo
1631 1631
 	}
1632 1632
 
1633 1633
 	/**
1634
-	* Gets Country from iso2
1635
-	*
1636
-	* @param String $iso2 ISO2 country code
1637
-	* @return String the countrie
1638
-	*/
1634
+	 * Gets Country from iso2
1635
+	 *
1636
+	 * @param String $iso2 ISO2 country code
1637
+	 * @return String the countrie
1638
+	 */
1639 1639
 	public function getCountryFromISO2($iso2)
1640 1640
 	{
1641 1641
 		global $globalDBdriver, $globalDebug;
@@ -1664,12 +1664,12 @@  discard block
 block discarded – undo
1664 1664
 
1665 1665
 	
1666 1666
 	/**
1667
-	* Gets the short url from bit.ly
1668
-	*
1669
-	* @param String $url the full url
1670
-	* @return String the bit.ly url
1671
-	*
1672
-	*/
1667
+	 * Gets the short url from bit.ly
1668
+	 *
1669
+	 * @param String $url the full url
1670
+	 * @return String the bit.ly url
1671
+	 *
1672
+	 */
1673 1673
 	public function getBitlyURL($url)
1674 1674
 	{
1675 1675
 		global $globalBitlyAccessToken;
@@ -1696,11 +1696,11 @@  discard block
 block discarded – undo
1696 1696
 
1697 1697
 	
1698 1698
 	/**
1699
-	* Gets all vessels types that have flown over
1700
-	*
1701
-	* @return Array the vessel type list
1702
-	*
1703
-	*/
1699
+	 * Gets all vessels types that have flown over
1700
+	 *
1701
+	 * @return Array the vessel type list
1702
+	 *
1703
+	 */
1704 1704
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1705 1705
 	{
1706 1706
 		global $globalDBdriver;
Please login to merge, or discard this patch.
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @return Array the SQL part
17 17
 	*/
18 18
 	
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72 72
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73 73
 		if ($filter_query_where != '') {
74
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
74
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
75 75
 		}
76 76
 		$filter_query = $filter_query_join.$filter_query_where;
77 77
 		return $filter_query;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	* @return Array the spotter information
87 87
 	*
88 88
 	*/
89
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
89
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
92 92
 		if (!is_string($query))
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 			$sth = $this->db->prepare($query.$limitQuery);
107 107
 			$sth->execute($params);
108 108
 		} catch (PDOException $e) {
109
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
109
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
110 110
 			exit();
111 111
 		}
112 112
 		
113 113
 		$num_rows = 0;
114 114
 		$spotter_array = array();
115
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
115
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
116 116
 		{
117 117
 			$num_rows++;
118 118
 			$temp_array = array();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 			}
145 145
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 146
 
147
-			if($temp_array['mmsi'] != "")
147
+			if ($temp_array['mmsi'] != "")
148 148
 			{
149 149
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
150
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
151 151
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
152 152
 				unset($Image);
153 153
 				if (count($image_array) > 0) {
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 				{
184 184
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
185 185
 				} else {
186
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
186
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
187 187
 				}
188 188
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
189
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
190
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
189
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
190
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
191 191
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
192 192
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
193 193
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
194 194
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
195
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
196
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
195
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
196
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
197 197
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
198 198
 					}
199 199
 				}
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		if ($limit != "")
227 227
 		{
228 228
 			$limit_array = explode(",", $limit);
229
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
230
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
229
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
230
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
231 231
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
232 232
 			{
233 233
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 		} else {
242 242
 			$orderby_query = " ORDER BY marine_output.date DESC";
243 243
 		}
244
-		$query  = $global_query.$filter_query." ".$orderby_query;
245
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
244
+		$query = $global_query.$filter_query." ".$orderby_query;
245
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
246 246
 		return $spotter_array;
247 247
 	}
248 248
     
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 		if ($id == '') return array();
261 261
 		$additional_query = "marine_output.fammarine_id = :id";
262 262
 		$query_values = array(':id' => $id);
263
-		$query  = $global_query." WHERE ".$additional_query." ";
264
-		$spotter_array = $this->getDataFromDB($query,$query_values);
263
+		$query = $global_query." WHERE ".$additional_query." ";
264
+		$spotter_array = $this->getDataFromDB($query, $query_values);
265 265
 		return $spotter_array;
266 266
 	}
267 267
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$query_values = array();
281 281
 		$limit_query = '';
282 282
 		$additional_query = '';
283
-		$filter_query = $this->getFilter($filter,true,true);
283
+		$filter_query = $this->getFilter($filter, true, true);
284 284
 		if ($ident != "")
285 285
 		{
286 286
 			if (!is_string($ident))
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 		{
297 297
 			$limit_array = explode(",", $limit);
298 298
 			
299
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
300
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
299
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
300
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
301 301
 			
302 302
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
303 303
 			{
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		return $spotter_array;
322 322
 	}
323 323
 	
324
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
324
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
325 325
 	{
326 326
 		global $global_query, $globalTimezone, $globalDBdriver;
327 327
 		
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		$limit_query = '';
330 330
 		$additional_query = '';
331 331
 
332
-		$filter_query = $this->getFilter($filter,true,true);
332
+		$filter_query = $this->getFilter($filter, true, true);
333 333
 		
334 334
 		if ($date != "")
335 335
 		{
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 		{
356 356
 			$limit_array = explode(",", $limit);
357 357
 			
358
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
359
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
358
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
359
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
360 360
 			
361 361
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
362 362
 			{
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	* @return Array list of source name
388 388
 	*
389 389
 	*/
390
-	public function getAllSourceName($type = '',$filters = array())
390
+	public function getAllSourceName($type = '', $filters = array())
391 391
 	{
392
-		$filter_query = $this->getFilter($filters,true,true);
392
+		$filter_query = $this->getFilter($filters, true, true);
393 393
 		$query_values = array();
394
-		$query  = "SELECT DISTINCT marine_output.source_name 
394
+		$query = "SELECT DISTINCT marine_output.source_name 
395 395
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
396 396
 		if ($type != '') {
397 397
 			$query_values = array(':type' => $type);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		$source_array = array();
407 407
 		$temp_array = array();
408 408
 		
409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
410 410
 		{
411 411
 			$temp_array['source_name'] = $row['source_name'];
412 412
 			$source_array[] = $temp_array;
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 	*/
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426
-		$filter_query = $this->getFilter($filters,true,true);
427
-		$query  = "SELECT DISTINCT marine_output.ident
426
+		$filter_query = $this->getFilter($filters, true, true);
427
+		$query = "SELECT DISTINCT marine_output.ident
428 428
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
429 429
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
430 430
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		$ident_array = array();
435 435
 		$temp_array = array();
436 436
 		
437
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
437
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
438 438
 		{
439 439
 			$temp_array['ident'] = $row['ident'];
440 440
 			$ident_array[] = $temp_array;
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	*/
452 452
 	public function getIdentity($mmsi)
453 453
 	{
454
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
454
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
455 455
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
456 456
 		$sth = $this->db->prepare($query);
457 457
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 		} else $offset = '+00:00';
477 477
 
478 478
 		if ($globalDBdriver == 'mysql') {
479
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
479
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
480 480
 								FROM marine_output
481 481
 								WHERE marine_output.date <> '' 
482 482
 								ORDER BY marine_output.date ASC LIMIT 0,200";
483 483
 		} else {
484
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
484
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
485 485
 								FROM marine_output
486 486
 								WHERE marine_output.date <> '' 
487 487
 								ORDER BY marine_output.date ASC LIMIT 0,200";
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		$date_array = array();
494 494
 		$temp_array = array();
495 495
 		
496
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
496
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
497 497
 		{
498 498
 			$temp_array['date'] = $row['date'];
499 499
 
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	* @return String success or false
513 513
 	*
514 514
 	*/	
515
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
515
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
516 516
 	{
517 517
 
518 518
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
519
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
519
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
520 520
 
521 521
 		try {
522 522
 			$sth = $this->db->prepare($query);
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
 	* @return String success or false
539 539
 	*
540 540
 	*/	
541
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
541
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
542 542
 	{
543 543
 
544 544
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
545
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
545
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
546 546
 
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
566 566
 	{
567 567
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
568
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
568
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	* @param String $verticalrate vertival rate of flight
604 604
 	* @return String success or false
605 605
 	*/
606
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
606
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '')
607 607
 	{
608 608
 		global $globalURL, $globalMarineImageFetch;
609 609
 		
@@ -670,31 +670,31 @@  discard block
 block discarded – undo
670 670
 		}
671 671
 
672 672
     
673
-		if ($date == "" || strtotime($date) < time()-20*60)
673
+		if ($date == "" || strtotime($date) < time() - 20*60)
674 674
 		{
675 675
 			$date = date("Y-m-d H:i:s", time());
676 676
 		}
677 677
 
678
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
679
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
680
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
681
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
682
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
683
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
684
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
685
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
686
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
687
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
688
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
689
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
690
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
691
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
678
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
679
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
681
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
682
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
683
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
684
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
685
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
686
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
687
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
688
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
689
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
690
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
691
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
692 692
 	
693 693
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
694 694
 			$Image = new Image($this->db);
695
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
695
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
696 696
 			if (!isset($image_array[0]['mmsi'])) {
697
-				$Image->addMarineImage($mmsi,$imo,$ident);
697
+				$Image->addMarineImage($mmsi, $imo, $ident);
698 698
 			}
699 699
 			unset($Image);
700 700
 		}
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707 707
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708 708
                 if ($arrival_date == '') $arrival_date = NULL;
709
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
709
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 710
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 711
 
712
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
712
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
713 713
 		try {
714 714
 		        
715 715
 			$sth = $this->db->prepare($query);
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
736 736
 		if ($globalDBdriver == 'mysql') {
737
-			$query  = "SELECT marine_output.ident FROM marine_output 
737
+			$query = "SELECT marine_output.ident FROM marine_output 
738 738
 								WHERE marine_output.ident = :ident 
739 739
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
740 740
 								AND marine_output.date < UTC_TIMESTAMP()";
741 741
 			$query_data = array(':ident' => $ident);
742 742
 		} else {
743
-			$query  = "SELECT marine_output.ident FROM marine_output 
743
+			$query = "SELECT marine_output.ident FROM marine_output 
744 744
 								WHERE marine_output.ident = :ident 
745 745
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
746 746
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-    		$ident_result='';
753
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
752
+    		$ident_result = '';
753
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['ident'];
756 756
 		}
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 				return false;
777 777
 			} else {
778 778
 				$q_array = explode(" ", $q);
779
-				foreach ($q_array as $q_item){
780
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
779
+				foreach ($q_array as $q_item) {
780
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
781 781
 					$additional_query .= " AND (";
782 782
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
783 783
 					$additional_query .= ")";
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
 			}
786 786
 		}
787 787
 		if ($globalDBdriver == 'mysql') {
788
-			$query  = "SELECT marine_output.* FROM marine_output 
788
+			$query = "SELECT marine_output.* FROM marine_output 
789 789
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
790 790
 				AND marine_output.date < UTC_TIMESTAMP()";
791 791
 		} else {
792
-			$query  = "SELECT marine_output.* FROM marine_output 
792
+			$query = "SELECT marine_output.* FROM marine_output 
793 793
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
794 794
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
795 795
 		}
@@ -808,16 +808,16 @@  discard block
 block discarded – undo
808 808
 	*
809 809
 	*/
810 810
 
811
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
811
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
812 812
 	{
813 813
 		global $globalDBdriver, $globalArchive;
814 814
 		//$filter_query = $this->getFilter($filters,true,true);
815
-		$Connection= new Connection($this->db);
815
+		$Connection = new Connection($this->db);
816 816
 		if (!$Connection->tableExists('countries')) return array();
817 817
 		require_once('class.SpotterLive.php');
818 818
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 819
 			$MarineLive = new MarineLive();
820
-			$filter_query = $MarineLive->getFilter($filters,true,true);
820
+			$filter_query = $MarineLive->getFilter($filters, true, true);
821 821
 			$filter_query .= ' over_country IS NOT NULL';
822 822
 			if ($olderthanmonths > 0) {
823 823
 				if ($globalDBdriver == 'mysql') {
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 		} else {
838 838
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
839 839
 			$MarineArchive = new MarineArchive();
840
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
840
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
841 841
 			$filter_query .= ' over_country IS NOT NULL';
842 842
 			if ($olderthanmonths > 0) {
843 843
 				if ($globalDBdriver == 'mysql') {
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		$flight_array = array();
866 866
 		$temp_array = array();
867 867
         
868
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
868
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
869 869
 		{
870 870
 			$temp_array['flight_count'] = $row['nb'];
871 871
 			$temp_array['flight_country'] = $row['name'];
@@ -884,11 +884,11 @@  discard block
 block discarded – undo
884 884
 	* @return Array the callsign list
885 885
 	*
886 886
 	*/
887
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
887
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
888 888
 	{
889 889
 		global $globalDBdriver;
890
-		$filter_query = $this->getFilter($filters,true,true);
891
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
890
+		$filter_query = $this->getFilter($filters, true, true);
891
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
892 892
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
893 893
 		 if ($olderthanmonths > 0) {
894 894
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -902,28 +902,28 @@  discard block
 block discarded – undo
902 902
 		if ($year != '') {
903 903
 			if ($globalDBdriver == 'mysql') {
904 904
 				$query .= " AND YEAR(marine_output.date) = :year";
905
-				$query_values = array_merge($query_values,array(':year' => $year));
905
+				$query_values = array_merge($query_values, array(':year' => $year));
906 906
 			} else {
907 907
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
908
-				$query_values = array_merge($query_values,array(':year' => $year));
908
+				$query_values = array_merge($query_values, array(':year' => $year));
909 909
 			}
910 910
 		}
911 911
 		if ($month != '') {
912 912
 			if ($globalDBdriver == 'mysql') {
913 913
 				$query .= " AND MONTH(marine_output.date) = :month";
914
-				$query_values = array_merge($query_values,array(':month' => $month));
914
+				$query_values = array_merge($query_values, array(':month' => $month));
915 915
 			} else {
916 916
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
917
-				$query_values = array_merge($query_values,array(':month' => $month));
917
+				$query_values = array_merge($query_values, array(':month' => $month));
918 918
 			}
919 919
 		}
920 920
 		if ($day != '') {
921 921
 			if ($globalDBdriver == 'mysql') {
922 922
 				$query .= " AND DAY(marine_output.date) = :day";
923
-				$query_values = array_merge($query_values,array(':day' => $day));
923
+				$query_values = array_merge($query_values, array(':day' => $day));
924 924
 			} else {
925 925
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
926
-				$query_values = array_merge($query_values,array(':day' => $day));
926
+				$query_values = array_merge($query_values, array(':day' => $day));
927 927
 			}
928 928
 		}
929 929
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 		$callsign_array = array();
936 936
 		$temp_array = array();
937 937
         
938
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
938
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
939 939
 		{
940 940
 			$temp_array['callsign_icao'] = $row['ident'];
941 941
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 		$date_array = array();
988 988
 		$temp_array = array();
989 989
         
990
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
990
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
991 991
 		{
992 992
 			$temp_array['date_name'] = $row['date_name'];
993 993
 			$temp_array['date_count'] = $row['date_count'];
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
 			$datetime = new DateTime();
1014 1014
 			$offset = $datetime->format('P');
1015 1015
 		} else $offset = '+00:00';
1016
-		$filter_query = $this->getFilter($filters,true,true);
1016
+		$filter_query = $this->getFilter($filters, true, true);
1017 1017
 		if ($globalDBdriver == 'mysql') {
1018 1018
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1019 1019
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 		$date_array = array();
1035 1035
 		$temp_array = array();
1036 1036
         
1037
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1037
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1038 1038
 		{
1039 1039
 			$temp_array['date_name'] = $row['date_name'];
1040 1040
 			$temp_array['date_count'] = $row['date_count'];
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 			$datetime = new DateTime();
1060 1060
 			$offset = $datetime->format('P');
1061 1061
 		} else $offset = '+00:00';
1062
-		$filter_query = $this->getFilter($filters,true,true);
1062
+		$filter_query = $this->getFilter($filters, true, true);
1063 1063
 		if ($globalDBdriver == 'mysql') {
1064 1064
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1065 1065
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 		$date_array = array();
1081 1081
 		$temp_array = array();
1082 1082
         
1083
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1083
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1084 1084
 		{
1085 1085
 			$temp_array['date_name'] = $row['date_name'];
1086 1086
 			$temp_array['date_count'] = $row['date_count'];
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 		$date_array = array();
1128 1128
 		$temp_array = array();
1129 1129
         
1130
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1130
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1131 1131
 		{
1132 1132
 			$temp_array['month_name'] = $row['month_name'];
1133 1133
 			$temp_array['year_name'] = $row['year_name'];
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 			$datetime = new DateTime();
1157 1157
 			$offset = $datetime->format('P');
1158 1158
 		} else $offset = '+00:00';
1159
-		$filter_query = $this->getFilter($filters,true,true);
1159
+		$filter_query = $this->getFilter($filters, true, true);
1160 1160
 		if ($globalDBdriver == 'mysql') {
1161 1161
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1162 1162
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		$date_array = array();
1178 1178
 		$temp_array = array();
1179 1179
         
1180
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1180
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1181 1181
 		{
1182 1182
 			$temp_array['year_name'] = $row['year_name'];
1183 1183
 			$temp_array['month_name'] = $row['month_name'];
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 	* @return Array the hour list
1198 1198
 	*
1199 1199
 	*/
1200
-	public function countAllHours($orderby,$filters = array())
1200
+	public function countAllHours($orderby, $filters = array())
1201 1201
 	{
1202 1202
 		global $globalTimezone, $globalDBdriver;
1203 1203
 		if ($globalTimezone != '') {
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 		$hour_array = array();
1246 1246
 		$temp_array = array();
1247 1247
         
1248
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1248
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1249 1249
 		{
1250 1250
 			$temp_array['hour_name'] = $row['hour_name'];
1251 1251
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 	public function countAllHoursByDate($date, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
1270
-		$filter_query = $this->getFilter($filters,true,true);
1271
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1270
+		$filter_query = $this->getFilter($filters, true, true);
1271
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1272 1272
 		if ($globalTimezone != '') {
1273 1273
 			date_default_timezone_set($globalTimezone);
1274 1274
 			$datetime = new DateTime($date);
@@ -1276,12 +1276,12 @@  discard block
 block discarded – undo
1276 1276
 		} else $offset = '+00:00';
1277 1277
 
1278 1278
 		if ($globalDBdriver == 'mysql') {
1279
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1279
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1280 1280
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1281 1281
 								GROUP BY hour_name 
1282 1282
 								ORDER BY hour_name ASC";
1283 1283
 		} else {
1284
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1284
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1285 1285
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1286 1286
 								GROUP BY hour_name 
1287 1287
 								ORDER BY hour_name ASC";
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 		$hour_array = array();
1294 1294
 		$temp_array = array();
1295 1295
         
1296
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1296
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1297 1297
 		{
1298 1298
 			$temp_array['hour_name'] = $row['hour_name'];
1299 1299
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 	public function countAllHoursByIdent($ident, $filters = array())
1316 1316
 	{
1317 1317
 		global $globalTimezone, $globalDBdriver;
1318
-		$filter_query = $this->getFilter($filters,true,true);
1319
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1318
+		$filter_query = $this->getFilter($filters, true, true);
1319
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1320 1320
 		if ($globalTimezone != '') {
1321 1321
 			date_default_timezone_set($globalTimezone);
1322 1322
 			$datetime = new DateTime();
@@ -1324,12 +1324,12 @@  discard block
 block discarded – undo
1324 1324
 		} else $offset = '+00:00';
1325 1325
 
1326 1326
 		if ($globalDBdriver == 'mysql') {
1327
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1327
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1328 1328
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1329 1329
 								GROUP BY hour_name 
1330 1330
 								ORDER BY hour_name ASC";
1331 1331
 		} else {
1332
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1332
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1333 1333
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1334 1334
 								GROUP BY hour_name 
1335 1335
 								ORDER BY hour_name ASC";
@@ -1337,12 +1337,12 @@  discard block
 block discarded – undo
1337 1337
       
1338 1338
 		
1339 1339
 		$sth = $this->db->prepare($query);
1340
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1340
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1341 1341
       
1342 1342
 		$hour_array = array();
1343 1343
 		$temp_array = array();
1344 1344
         
1345
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1345
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1346 1346
 		{
1347 1347
 			$temp_array['hour_name'] = $row['hour_name'];
1348 1348
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1361,33 +1361,33 @@  discard block
 block discarded – undo
1361 1361
 	* @return Integer the number of flights
1362 1362
 	*
1363 1363
 	*/
1364
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1364
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1365 1365
 	{
1366 1366
 		global $globalDBdriver;
1367 1367
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1368
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1368
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1369 1369
 		$query_values = array();
1370 1370
 		$query = '';
1371 1371
 		if ($year != '') {
1372 1372
 			if ($globalDBdriver == 'mysql') {
1373 1373
 				$query .= " AND YEAR(marine_output.date) = :year";
1374
-				$query_values = array_merge($query_values,array(':year' => $year));
1374
+				$query_values = array_merge($query_values, array(':year' => $year));
1375 1375
 			} else {
1376 1376
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1377
-				$query_values = array_merge($query_values,array(':year' => $year));
1377
+				$query_values = array_merge($query_values, array(':year' => $year));
1378 1378
 			}
1379 1379
 		}
1380 1380
 		if ($month != '') {
1381 1381
 			if ($globalDBdriver == 'mysql') {
1382 1382
 				$query .= " AND MONTH(marine_output.date) = :month";
1383
-				$query_values = array_merge($query_values,array(':month' => $month));
1383
+				$query_values = array_merge($query_values, array(':month' => $month));
1384 1384
 			} else {
1385 1385
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1386
-				$query_values = array_merge($query_values,array(':month' => $month));
1386
+				$query_values = array_merge($query_values, array(':month' => $month));
1387 1387
 			}
1388 1388
 		}
1389 1389
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1390
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1390
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1391 1391
 		
1392 1392
 		$sth = $this->db->prepare($queryi);
1393 1393
 		$sth->execute($query_values);
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
 	public function countAllHoursFromToday($filters = array())
1405 1405
 	{
1406 1406
 		global $globalTimezone, $globalDBdriver;
1407
-		$filter_query = $this->getFilter($filters,true,true);
1407
+		$filter_query = $this->getFilter($filters, true, true);
1408 1408
 		if ($globalTimezone != '') {
1409 1409
 			date_default_timezone_set($globalTimezone);
1410 1410
 			$datetime = new DateTime();
@@ -1412,12 +1412,12 @@  discard block
 block discarded – undo
1412 1412
 		} else $offset = '+00:00';
1413 1413
 
1414 1414
 		if ($globalDBdriver == 'mysql') {
1415
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1415
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1416 1416
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1417 1417
 								GROUP BY hour_name 
1418 1418
 								ORDER BY hour_name ASC";
1419 1419
 		} else {
1420
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1420
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1421 1421
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1422 1422
 								GROUP BY hour_name 
1423 1423
 								ORDER BY hour_name ASC";
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
 		$hour_array = array();
1430 1430
 		$temp_array = array();
1431 1431
         
1432
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1432
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1433 1433
 		{
1434 1434
 			$temp_array['hour_name'] = $row['hour_name'];
1435 1435
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1448,9 +1448,9 @@  discard block
 block discarded – undo
1448 1448
 	*/
1449 1449
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1450 1450
 	{
1451
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1451
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1452 1452
 
1453
-		$query  = "SELECT marine_output.marine_id
1453
+		$query = "SELECT marine_output.marine_id
1454 1454
 				FROM marine_output 
1455 1455
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1456 1456
         
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
 		$sth = $this->db->prepare($query);
1459 1459
 		$sth->execute();
1460 1460
 
1461
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1461
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1462 1462
 		{
1463 1463
 			return $row['marine_id'];
1464 1464
 		}
@@ -1483,23 +1483,23 @@  discard block
 block discarded – undo
1483 1483
 		}
1484 1484
 		
1485 1485
 		$current_date = date("Y-m-d H:i:s");
1486
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1486
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1487 1487
 		
1488 1488
 		$diff = abs(strtotime($current_date) - strtotime($date));
1489 1489
 
1490
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1490
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1491 1491
 		$years = $time_array['years'];
1492 1492
 		
1493
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1493
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1494 1494
 		$months = $time_array['months'];
1495 1495
 		
1496
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1496
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1497 1497
 		$days = $time_array['days'];
1498
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1498
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1499 1499
 		$hours = $time_array['hours'];
1500
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1500
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1501 1501
 		$minutes = $time_array['minutes'];
1502
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1502
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1503 1503
 		
1504 1504
 		return $time_array;
1505 1505
 	}
@@ -1522,63 +1522,63 @@  discard block
 block discarded – undo
1522 1522
 			$temp_array['direction_degree'] = $direction;
1523 1523
 			$temp_array['direction_shortname'] = "N";
1524 1524
 			$temp_array['direction_fullname'] = "North";
1525
-		} elseif ($direction >= 22.5 && $direction < 45){
1525
+		} elseif ($direction >= 22.5 && $direction < 45) {
1526 1526
 			$temp_array['direction_degree'] = $direction;
1527 1527
 			$temp_array['direction_shortname'] = "NNE";
1528 1528
 			$temp_array['direction_fullname'] = "North-Northeast";
1529
-		} elseif ($direction >= 45 && $direction < 67.5){
1529
+		} elseif ($direction >= 45 && $direction < 67.5) {
1530 1530
 			$temp_array['direction_degree'] = $direction;
1531 1531
 			$temp_array['direction_shortname'] = "NE";
1532 1532
 			$temp_array['direction_fullname'] = "Northeast";
1533
-		} elseif ($direction >= 67.5 && $direction < 90){
1533
+		} elseif ($direction >= 67.5 && $direction < 90) {
1534 1534
 			$temp_array['direction_degree'] = $direction;
1535 1535
 			$temp_array['direction_shortname'] = "ENE";
1536 1536
 			$temp_array['direction_fullname'] = "East-Northeast";
1537
-		} elseif ($direction >= 90 && $direction < 112.5){
1537
+		} elseif ($direction >= 90 && $direction < 112.5) {
1538 1538
 			$temp_array['direction_degree'] = $direction;
1539 1539
 			$temp_array['direction_shortname'] = "E";
1540 1540
 			$temp_array['direction_fullname'] = "East";
1541
-		} elseif ($direction >= 112.5 && $direction < 135){
1541
+		} elseif ($direction >= 112.5 && $direction < 135) {
1542 1542
 			$temp_array['direction_degree'] = $direction;
1543 1543
 			$temp_array['direction_shortname'] = "ESE";
1544 1544
 			$temp_array['direction_fullname'] = "East-Southeast";
1545
-		} elseif ($direction >= 135 && $direction < 157.5){
1545
+		} elseif ($direction >= 135 && $direction < 157.5) {
1546 1546
 			$temp_array['direction_degree'] = $direction;
1547 1547
 			$temp_array['direction_shortname'] = "SE";
1548 1548
 			$temp_array['direction_fullname'] = "Southeast";
1549
-		} elseif ($direction >= 157.5 && $direction < 180){
1549
+		} elseif ($direction >= 157.5 && $direction < 180) {
1550 1550
 			$temp_array['direction_degree'] = $direction;
1551 1551
 			$temp_array['direction_shortname'] = "SSE";
1552 1552
 			$temp_array['direction_fullname'] = "South-Southeast";
1553
-		} elseif ($direction >= 180 && $direction < 202.5){
1553
+		} elseif ($direction >= 180 && $direction < 202.5) {
1554 1554
 			$temp_array['direction_degree'] = $direction;
1555 1555
 			$temp_array['direction_shortname'] = "S";
1556 1556
 			$temp_array['direction_fullname'] = "South";
1557
-		} elseif ($direction >= 202.5 && $direction < 225){
1557
+		} elseif ($direction >= 202.5 && $direction < 225) {
1558 1558
 			$temp_array['direction_degree'] = $direction;
1559 1559
 			$temp_array['direction_shortname'] = "SSW";
1560 1560
 			$temp_array['direction_fullname'] = "South-Southwest";
1561
-		} elseif ($direction >= 225 && $direction < 247.5){
1561
+		} elseif ($direction >= 225 && $direction < 247.5) {
1562 1562
 			$temp_array['direction_degree'] = $direction;
1563 1563
 			$temp_array['direction_shortname'] = "SW";
1564 1564
 			$temp_array['direction_fullname'] = "Southwest";
1565
-		} elseif ($direction >= 247.5 && $direction < 270){
1565
+		} elseif ($direction >= 247.5 && $direction < 270) {
1566 1566
 			$temp_array['direction_degree'] = $direction;
1567 1567
 			$temp_array['direction_shortname'] = "WSW";
1568 1568
 			$temp_array['direction_fullname'] = "West-Southwest";
1569
-		} elseif ($direction >= 270 && $direction < 292.5){
1569
+		} elseif ($direction >= 270 && $direction < 292.5) {
1570 1570
 			$temp_array['direction_degree'] = $direction;
1571 1571
 			$temp_array['direction_shortname'] = "W";
1572 1572
 			$temp_array['direction_fullname'] = "West";
1573
-		} elseif ($direction >= 292.5 && $direction < 315){
1573
+		} elseif ($direction >= 292.5 && $direction < 315) {
1574 1574
 			$temp_array['direction_degree'] = $direction;
1575 1575
 			$temp_array['direction_shortname'] = "WNW";
1576 1576
 			$temp_array['direction_fullname'] = "West-Northwest";
1577
-		} elseif ($direction >= 315 && $direction < 337.5){
1577
+		} elseif ($direction >= 315 && $direction < 337.5) {
1578 1578
 			$temp_array['direction_degree'] = $direction;
1579 1579
 			$temp_array['direction_shortname'] = "NW";
1580 1580
 			$temp_array['direction_fullname'] = "Northwest";
1581
-		} elseif ($direction >= 337.5 && $direction < 360){
1581
+		} elseif ($direction >= 337.5 && $direction < 360) {
1582 1582
 			$temp_array['direction_degree'] = $direction;
1583 1583
 			$temp_array['direction_shortname'] = "NNW";
1584 1584
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1595,11 +1595,11 @@  discard block
 block discarded – undo
1595 1595
 	* @param Float $longitude longitute of the flight
1596 1596
 	* @return String the countrie
1597 1597
 	*/
1598
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1598
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1599 1599
 	{
1600 1600
 		global $globalDBdriver, $globalDebug;
1601
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1602
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1601
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1602
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1603 1603
 	
1604 1604
 		$Connection = new Connection($this->db);
1605 1605
 		if (!$Connection->tableExists('countries')) return '';
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
 	public function getCountryFromISO2($iso2)
1640 1640
 	{
1641 1641
 		global $globalDBdriver, $globalDebug;
1642
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1642
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1643 1643
 	
1644 1644
 		$Connection = new Connection($this->db);
1645 1645
 		if (!$Connection->tableExists('countries')) return '';
@@ -1687,7 +1687,7 @@  discard block
 block discarded – undo
1687 1687
 		
1688 1688
 		$bitly_data = json_decode($bitly_data);
1689 1689
 		$bitly_url = '';
1690
-		if ($bitly_data->status_txt = "OK"){
1690
+		if ($bitly_data->status_txt = "OK") {
1691 1691
 			$bitly_url = $bitly_data->data->url;
1692 1692
 		}
1693 1693
 
@@ -1701,11 +1701,11 @@  discard block
 block discarded – undo
1701 1701
 	* @return Array the vessel type list
1702 1702
 	*
1703 1703
 	*/
1704
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1704
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1705 1705
 	{
1706 1706
 		global $globalDBdriver;
1707
-		$filter_query = $this->getFilter($filters,true,true);
1708
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1707
+		$filter_query = $this->getFilter($filters, true, true);
1708
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1709 1709
 		    FROM marine_output ".$filter_query." marine_output.type  <> ''";
1710 1710
 		if ($olderthanmonths > 0) {
1711 1711
 			if ($globalDBdriver == 'mysql') {
@@ -1725,28 +1725,28 @@  discard block
 block discarded – undo
1725 1725
 		if ($year != '') {
1726 1726
 			if ($globalDBdriver == 'mysql') {
1727 1727
 				$query .= " AND YEAR(marine_output.date) = :year";
1728
-				$query_values = array_merge($query_values,array(':year' => $year));
1728
+				$query_values = array_merge($query_values, array(':year' => $year));
1729 1729
 			} else {
1730 1730
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1731
-				$query_values = array_merge($query_values,array(':year' => $year));
1731
+				$query_values = array_merge($query_values, array(':year' => $year));
1732 1732
 			}
1733 1733
 		}
1734 1734
 		if ($month != '') {
1735 1735
 			if ($globalDBdriver == 'mysql') {
1736 1736
 				$query .= " AND MONTH(marine_output.date) = :month";
1737
-				$query_values = array_merge($query_values,array(':month' => $month));
1737
+				$query_values = array_merge($query_values, array(':month' => $month));
1738 1738
 			} else {
1739 1739
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1740
-				$query_values = array_merge($query_values,array(':month' => $month));
1740
+				$query_values = array_merge($query_values, array(':month' => $month));
1741 1741
 			}
1742 1742
 		}
1743 1743
 		if ($day != '') {
1744 1744
 			if ($globalDBdriver == 'mysql') {
1745 1745
 				$query .= " AND DAY(marine_output.date) = :day";
1746
-				$query_values = array_merge($query_values,array(':day' => $day));
1746
+				$query_values = array_merge($query_values, array(':day' => $day));
1747 1747
 			} else {
1748 1748
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1749
-				$query_values = array_merge($query_values,array(':day' => $day));
1749
+				$query_values = array_merge($query_values, array(':day' => $day));
1750 1750
 			}
1751 1751
 		}
1752 1752
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
 		$sth->execute($query_values);
1756 1756
 		$marine_array = array();
1757 1757
 		$temp_array = array();
1758
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1758
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1759 1759
 		{
1760 1760
 			$temp_array['marine_type'] = $row['marine_type'];
1761 1761
 			$temp_array['marine_type_count'] = $row['marine_type_count'];
@@ -1766,7 +1766,7 @@  discard block
 block discarded – undo
1766 1766
 
1767 1767
 	public function getOrderBy()
1768 1768
 	{
1769
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1769
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1770 1770
 		
1771 1771
 		return $orderby;
1772 1772
 		
Please login to merge, or discard this patch.
Braces   +165 added lines, -59 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
69 71
 			}
70 72
 		}
71
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73
+		if ($filter_query_where == '' && $where) {
74
+			$filter_query_where = ' WHERE';
75
+		} elseif ($filter_query_where != '' && $and) {
76
+			$filter_query_where .= ' AND';
77
+		}
73 78
 		if ($filter_query_where != '') {
74 79
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75 80
 		}
@@ -123,32 +128,54 @@  discard block
 block discarded – undo
123 128
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
124 129
 			} elseif (isset($row['spotter_archive_output_id'])) {
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
126
-			*/} 
127
-			elseif (isset($row['marineid'])) {
131
+			*/} elseif (isset($row['marineid'])) {
128 132
 				$temp_array['marine_id'] = $row['marineid'];
129 133
 			} else {
130 134
 				$temp_array['marine_id'] = '';
131 135
 			}
132
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
133
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
134
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
135
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
136
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
137
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
138
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
139
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
136
+			if (isset($row['fammarine_id'])) {
137
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
138
+			}
139
+			if (isset($row['mmsi'])) {
140
+				$temp_array['mmsi'] = $row['mmsi'];
141
+			}
142
+			if (isset($row['type'])) {
143
+				$temp_array['type'] = $row['type'];
144
+			}
145
+			if (isset($row['type_id'])) {
146
+				$temp_array['type_id'] = $row['type_id'];
147
+			}
148
+			if (isset($row['ident'])) {
149
+				$temp_array['ident'] = $row['ident'];
150
+			}
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
140 160
 			if (isset($row['heading'])) {
141 161
 				$temp_array['heading'] = $row['heading'];
142 162
 				$heading_direction = $this->parseDirection($row['heading']);
143
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
163
+				if (isset($heading_direction[0]['direction_fullname'])) {
164
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
165
+				}
166
+			}
167
+			if (isset($row['ground_speed'])) {
168
+				$temp_array['ground_speed'] = $row['ground_speed'];
144 169
 			}
145
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 170
 
147 171
 			if($temp_array['mmsi'] != "")
148 172
 			{
149 173
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
151
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
174
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
175
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
176
+				} else {
177
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
178
+				}
152 179
 				unset($Image);
153 180
 				if (count($image_array) > 0) {
154 181
 					$temp_array['image'] = $image_array[0]['image'];
@@ -200,13 +227,21 @@  discard block
 block discarded – undo
200 227
 			}
201 228
 			
202 229
 			$fromsource = NULL;
203
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
204
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
205
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
230
+			if (isset($row['source_name']) && $row['source_name'] != '') {
231
+				$temp_array['source_name'] = $row['source_name'];
232
+			}
233
+			if (isset($row['over_country']) && $row['over_country'] != '') {
234
+				$temp_array['over_country'] = $row['over_country'];
235
+			}
236
+			if (isset($row['distance']) && $row['distance'] != '') {
237
+				$temp_array['distance'] = $row['distance'];
238
+			}
206 239
 			$temp_array['query_number_rows'] = $num_rows;
207 240
 			$spotter_array[] = $temp_array;
208 241
 		}
209
-		if ($num_rows == 0) return array();
242
+		if ($num_rows == 0) {
243
+			return array();
244
+		}
210 245
 		$spotter_array[0]['query_number_rows'] = $num_rows;
211 246
 		return $spotter_array;
212 247
 	}	
@@ -232,8 +267,12 @@  discard block
 block discarded – undo
232 267
 			{
233 268
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
234 269
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
235
-			} else $limit_query = "";
236
-		} else $limit_query = "";
270
+			} else {
271
+				$limit_query = "";
272
+			}
273
+		} else {
274
+			$limit_query = "";
275
+		}
237 276
 		if ($sort != "")
238 277
 		{
239 278
 			$search_orderby_array = $this->getOrderBy();
@@ -257,7 +296,9 @@  discard block
 block discarded – undo
257 296
 		global $global_query;
258 297
 		
259 298
 		date_default_timezone_set('UTC');
260
-		if ($id == '') return array();
299
+		if ($id == '') {
300
+			return array();
301
+		}
261 302
 		$additional_query = "marine_output.fammarine_id = :id";
262 303
 		$query_values = array(':id' => $id);
263 304
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -400,8 +441,11 @@  discard block
 block discarded – undo
400 441
 		$query .= " ORDER BY marine_output.source_name ASC";
401 442
 
402 443
 		$sth = $this->db->prepare($query);
403
-		if (!empty($query_values)) $sth->execute($query_values);
404
-		else $sth->execute();
444
+		if (!empty($query_values)) {
445
+			$sth->execute($query_values);
446
+		} else {
447
+			$sth->execute();
448
+		}
405 449
 
406 450
 		$source_array = array();
407 451
 		$temp_array = array();
@@ -456,8 +500,11 @@  discard block
 block discarded – undo
456 500
 		$sth = $this->db->prepare($query);
457 501
 		$sth->execute(array(':mmsi' => $mmsi));
458 502
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
459
-		if (isset($result[0])) return $result[0];
460
-		else return array();
503
+		if (isset($result[0])) {
504
+			return $result[0];
505
+		} else {
506
+			return array();
507
+		}
461 508
 	}
462 509
 
463 510
 	/*
@@ -473,7 +520,9 @@  discard block
 block discarded – undo
473 520
 			date_default_timezone_set($globalTimezone);
474 521
 			$datetime = new DateTime();
475 522
 			$offset = $datetime->format('P');
476
-		} else $offset = '+00:00';
523
+		} else {
524
+			$offset = '+00:00';
525
+		}
477 526
 
478 527
 		if ($globalDBdriver == 'mysql') {
479 528
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -703,9 +752,15 @@  discard block
 block discarded – undo
703 752
             		$latitude = 0;
704 753
             		$longitude = 0;
705 754
             	}
706
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
-                if ($arrival_date == '') $arrival_date = NULL;
755
+                if ($heading == '' || $Common->isInteger($heading) === false) {
756
+                	$heading = 0;
757
+                }
758
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
759
+                	$groundspeed = 0;
760
+                }
761
+                if ($arrival_date == '') {
762
+                	$arrival_date = NULL;
763
+                }
709 764
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 765
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 766
 
@@ -813,7 +868,9 @@  discard block
 block discarded – undo
813 868
 		global $globalDBdriver, $globalArchive;
814 869
 		//$filter_query = $this->getFilter($filters,true,true);
815 870
 		$Connection= new Connection($this->db);
816
-		if (!$Connection->tableExists('countries')) return array();
871
+		if (!$Connection->tableExists('countries')) {
872
+			return array();
873
+		}
817 874
 		require_once('class.SpotterLive.php');
818 875
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 876
 			$MarineLive = new MarineLive();
@@ -857,7 +914,9 @@  discard block
 block discarded – undo
857 914
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
858 915
 		}
859 916
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
860
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
917
+		if ($limit) {
918
+			$query .= " LIMIT 10 OFFSET 0";
919
+		}
861 920
 
862 921
 		$sth = $this->db->prepare($query);
863 922
 		$sth->execute();
@@ -891,12 +950,18 @@  discard block
 block discarded – undo
891 950
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
892 951
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
893 952
 		 if ($olderthanmonths > 0) {
894
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
895
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
953
+			if ($globalDBdriver == 'mysql') {
954
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
955
+			} else {
956
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
957
+			}
896 958
 		}
897 959
 		if ($sincedate != '') {
898
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
899
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
960
+			if ($globalDBdriver == 'mysql') {
961
+				$query .= " AND marine_output.date > '".$sincedate."'";
962
+			} else {
963
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
964
+			}
900 965
 		}
901 966
 		$query_values = array();
902 967
 		if ($year != '') {
@@ -927,7 +992,9 @@  discard block
 block discarded – undo
927 992
 			}
928 993
 		}
929 994
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
930
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
995
+		if ($limit) {
996
+			$query .= " LIMIT 10 OFFSET 0";
997
+		}
931 998
       		
932 999
 		$sth = $this->db->prepare($query);
933 1000
 		$sth->execute($query_values);
@@ -962,7 +1029,9 @@  discard block
 block discarded – undo
962 1029
 			date_default_timezone_set($globalTimezone);
963 1030
 			$datetime = new DateTime();
964 1031
 			$offset = $datetime->format('P');
965
-		} else $offset = '+00:00';
1032
+		} else {
1033
+			$offset = '+00:00';
1034
+		}
966 1035
 
967 1036
 		if ($globalDBdriver == 'mysql') {
968 1037
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1012,7 +1081,9 @@  discard block
 block discarded – undo
1012 1081
 			date_default_timezone_set($globalTimezone);
1013 1082
 			$datetime = new DateTime();
1014 1083
 			$offset = $datetime->format('P');
1015
-		} else $offset = '+00:00';
1084
+		} else {
1085
+			$offset = '+00:00';
1086
+		}
1016 1087
 		$filter_query = $this->getFilter($filters,true,true);
1017 1088
 		if ($globalDBdriver == 'mysql') {
1018 1089
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1058,7 +1129,9 @@  discard block
 block discarded – undo
1058 1129
 			date_default_timezone_set($globalTimezone);
1059 1130
 			$datetime = new DateTime();
1060 1131
 			$offset = $datetime->format('P');
1061
-		} else $offset = '+00:00';
1132
+		} else {
1133
+			$offset = '+00:00';
1134
+		}
1062 1135
 		$filter_query = $this->getFilter($filters,true,true);
1063 1136
 		if ($globalDBdriver == 'mysql') {
1064 1137
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1106,7 +1179,9 @@  discard block
 block discarded – undo
1106 1179
 			date_default_timezone_set($globalTimezone);
1107 1180
 			$datetime = new DateTime();
1108 1181
 			$offset = $datetime->format('P');
1109
-		} else $offset = '+00:00';
1182
+		} else {
1183
+			$offset = '+00:00';
1184
+		}
1110 1185
 
1111 1186
 		if ($globalDBdriver == 'mysql') {
1112 1187
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1155,7 +1230,9 @@  discard block
 block discarded – undo
1155 1230
 			date_default_timezone_set($globalTimezone);
1156 1231
 			$datetime = new DateTime();
1157 1232
 			$offset = $datetime->format('P');
1158
-		} else $offset = '+00:00';
1233
+		} else {
1234
+			$offset = '+00:00';
1235
+		}
1159 1236
 		$filter_query = $this->getFilter($filters,true,true);
1160 1237
 		if ($globalDBdriver == 'mysql') {
1161 1238
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1204,7 +1281,9 @@  discard block
 block discarded – undo
1204 1281
 			date_default_timezone_set($globalTimezone);
1205 1282
 			$datetime = new DateTime();
1206 1283
 			$offset = $datetime->format('P');
1207
-		} else $offset = '+00:00';
1284
+		} else {
1285
+			$offset = '+00:00';
1286
+		}
1208 1287
 
1209 1288
 		$orderby_sql = '';
1210 1289
 		if ($orderby == "hour")
@@ -1273,7 +1352,9 @@  discard block
 block discarded – undo
1273 1352
 			date_default_timezone_set($globalTimezone);
1274 1353
 			$datetime = new DateTime($date);
1275 1354
 			$offset = $datetime->format('P');
1276
-		} else $offset = '+00:00';
1355
+		} else {
1356
+			$offset = '+00:00';
1357
+		}
1277 1358
 
1278 1359
 		if ($globalDBdriver == 'mysql') {
1279 1360
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1321,7 +1402,9 @@  discard block
 block discarded – undo
1321 1402
 			date_default_timezone_set($globalTimezone);
1322 1403
 			$datetime = new DateTime();
1323 1404
 			$offset = $datetime->format('P');
1324
-		} else $offset = '+00:00';
1405
+		} else {
1406
+			$offset = '+00:00';
1407
+		}
1325 1408
 
1326 1409
 		if ($globalDBdriver == 'mysql') {
1327 1410
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1386,8 +1469,11 @@  discard block
 block discarded – undo
1386 1469
 				$query_values = array_merge($query_values,array(':month' => $month));
1387 1470
 			}
1388 1471
 		}
1389
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1390
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1472
+		if (empty($query_values)) {
1473
+			$queryi .= $this->getFilter($filters);
1474
+		} else {
1475
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1476
+		}
1391 1477
 		
1392 1478
 		$sth = $this->db->prepare($queryi);
1393 1479
 		$sth->execute($query_values);
@@ -1409,7 +1495,9 @@  discard block
 block discarded – undo
1409 1495
 			date_default_timezone_set($globalTimezone);
1410 1496
 			$datetime = new DateTime();
1411 1497
 			$offset = $datetime->format('P');
1412
-		} else $offset = '+00:00';
1498
+		} else {
1499
+			$offset = '+00:00';
1500
+		}
1413 1501
 
1414 1502
 		if ($globalDBdriver == 'mysql') {
1415 1503
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1513,7 +1601,9 @@  discard block
 block discarded – undo
1513 1601
 	*/
1514 1602
 	public function parseDirection($direction = 0)
1515 1603
 	{
1516
-		if ($direction == '') $direction = 0;
1604
+		if ($direction == '') {
1605
+			$direction = 0;
1606
+		}
1517 1607
 		$direction_array = array();
1518 1608
 		$temp_array = array();
1519 1609
 
@@ -1602,7 +1692,9 @@  discard block
 block discarded – undo
1602 1692
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1603 1693
 	
1604 1694
 		$Connection = new Connection($this->db);
1605
-		if (!$Connection->tableExists('countries')) return '';
1695
+		if (!$Connection->tableExists('countries')) {
1696
+			return '';
1697
+		}
1606 1698
 	
1607 1699
 		try {
1608 1700
 			/*
@@ -1622,9 +1714,13 @@  discard block
 block discarded – undo
1622 1714
 			$sth->closeCursor();
1623 1715
 			if (count($row) > 0) {
1624 1716
 				return $row;
1625
-			} else return '';
1717
+			} else {
1718
+				return '';
1719
+			}
1626 1720
 		} catch (PDOException $e) {
1627
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1721
+			if (isset($globalDebug) && $globalDebug) {
1722
+				echo 'Error : '.$e->getMessage()."\n";
1723
+			}
1628 1724
 			return '';
1629 1725
 		}
1630 1726
 	
@@ -1642,7 +1738,9 @@  discard block
 block discarded – undo
1642 1738
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1643 1739
 	
1644 1740
 		$Connection = new Connection($this->db);
1645
-		if (!$Connection->tableExists('countries')) return '';
1741
+		if (!$Connection->tableExists('countries')) {
1742
+			return '';
1743
+		}
1646 1744
 	
1647 1745
 		try {
1648 1746
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1654,9 +1752,13 @@  discard block
 block discarded – undo
1654 1752
 			$sth->closeCursor();
1655 1753
 			if (count($row) > 0) {
1656 1754
 				return $row;
1657
-			} else return '';
1755
+			} else {
1756
+				return '';
1757
+			}
1658 1758
 		} catch (PDOException $e) {
1659
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1759
+			if (isset($globalDebug) && $globalDebug) {
1760
+				echo 'Error : '.$e->getMessage()."\n";
1761
+			}
1660 1762
 			return '';
1661 1763
 		}
1662 1764
 	
@@ -1674,7 +1776,9 @@  discard block
 block discarded – undo
1674 1776
 	{
1675 1777
 		global $globalBitlyAccessToken;
1676 1778
 		
1677
-		if ($globalBitlyAccessToken == '') return $url;
1779
+		if ($globalBitlyAccessToken == '') {
1780
+			return $url;
1781
+		}
1678 1782
         
1679 1783
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1680 1784
 		
@@ -1750,7 +1854,9 @@  discard block
 block discarded – undo
1750 1854
 			}
1751 1855
 		}
1752 1856
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
1753
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1857
+		if ($limit) {
1858
+			$query .= " LIMIT 10 OFFSET 0";
1859
+		}
1754 1860
 		$sth = $this->db->prepare($query);
1755 1861
 		$sth->execute($query_values);
1756 1862
 		$marine_array = array();
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 2 patches
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -13,33 +13,33 @@  discard block
 block discarded – undo
13 13
 	* @param Array $filter the filter
14 14
 	* @return Array the SQL part
15 15
 	*/
16
-	public function getFilter($filter = array(),$where = false,$and = false) {
16
+	public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 		$filters = array();
19 19
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 				$filters = $globalStatsFilters[$globalFilterName];
22 22
 			} else {
23
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 			}
25 25
 		}
26 26
 		if (isset($filter[0]['source'])) {
27
-			$filters = array_merge($filters,$filter);
27
+			$filters = array_merge($filters, $filter);
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 		$filter_query_join = '';
31 31
 		$filter_query_where = '';
32
-		foreach($filters as $flt) {
32
+		foreach ($filters as $flt) {
33 33
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
34 34
 				if (isset($flt['source'])) {
35
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
35
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
36 36
 				} else {
37
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
37
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
38 38
 				}
39 39
 			}
40 40
 		}
41 41
 		if (isset($filter['source']) && !empty($filter['source'])) {
42
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
42
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
43 43
 		}
44 44
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
45 45
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -67,38 +67,38 @@  discard block
 block discarded – undo
67 67
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'";
68 68
 				}
69 69
 			}
70
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
70
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
71 71
 		}
72 72
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
73
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
74 74
 		}
75 75
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76 76
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77 77
 		if ($filter_query_where != '') {
78
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
79 79
 		}
80 80
 		$filter_query = $filter_query_join.$filter_query_where;
81 81
 		return $filter_query;
82 82
 	}
83 83
 
84 84
 	// tracker_archive
85
-	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') {
85
+	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
86 86
 		require_once(dirname(__FILE__).'/class.Tracker.php');
87 87
 		if ($over_country == '') {
88 88
 			$Tracker = new Tracker($this->db);
89
-			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
89
+			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude);
90 90
 			if (!empty($data_country)) $country = $data_country['iso2'];
91 91
 			else $country = '';
92 92
 		} else $country = $over_country;
93 93
 		// Route is not added in tracker_archive
94
-		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
94
+		$query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
95 95
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
96
-		$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);
96
+		$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);
97 97
 		try {
98 98
 			$sth = $this->db->prepare($query);
99 99
 			$sth->execute($query_values);
100 100
 			$sth->closeCursor();
101
-		} catch(PDOException $e) {
101
+		} catch (PDOException $e) {
102 102
 			return "error : ".$e->getMessage();
103 103
 		}
104 104
 		return "success";
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 
119 119
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
120 120
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
121
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
121
+                $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
122 122
 
123
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
123
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident));
124 124
 
125 125
                 return $spotter_array;
126 126
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
140 140
                 //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
141 141
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
142
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
142
+                $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
143 143
 
144 144
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
145 145
                   /*
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
                 }
153 153
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
154 154
                 */
155
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
155
+                $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id));
156 156
 
157 157
                 return $spotter_array;
158 158
         }
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 	{
168 168
                 date_default_timezone_set('UTC');
169 169
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
170
-                $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
170
+                $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
171 171
 
172 172
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
173 173
 
174 174
                 try {
175 175
                         $sth = $this->db->prepare($query);
176 176
                         $sth->execute(array(':id' => $id));
177
-                } catch(PDOException $e) {
177
+                } catch (PDOException $e) {
178 178
                         echo $e->getMessage();
179 179
                         die;
180 180
                 }
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
         {
194 194
                 date_default_timezone_set('UTC');
195 195
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
196
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
196
+                $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
197 197
 
198 198
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
199 199
 
200 200
                 try {
201 201
                         $sth = $this->db->prepare($query);
202 202
                         $sth->execute(array(':id' => $id));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         echo $e->getMessage();
205 205
                         die;
206 206
                 }
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
                 date_default_timezone_set('UTC');
223 223
 
224 224
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
225
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
225
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
226 226
 
227 227
                 try {
228 228
                         $sth = $this->db->prepare($query);
229 229
                         $sth->execute(array(':ident' => $ident));
230
-                } catch(PDOException $e) {
230
+                } catch (PDOException $e) {
231 231
                         echo $e->getMessage();
232 232
                         die;
233 233
                 }
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
                 date_default_timezone_set('UTC');
249 249
 
250 250
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
251
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
251
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
252 252
 
253 253
                 try {
254 254
                         $sth = $this->db->prepare($query);
255 255
                         $sth->execute(array(':id' => $id));
256
-                } catch(PDOException $e) {
256
+                } catch (PDOException $e) {
257 257
                         echo $e->getMessage();
258 258
                         die;
259 259
                 }
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
                 date_default_timezone_set('UTC');
275 275
 
276 276
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
277
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
277
+                $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
278 278
 
279 279
                 try {
280 280
                         $sth = $this->db->prepare($query);
281 281
                         $sth->execute(array(':id' => $id));
282
-                } catch(PDOException $e) {
282
+                } catch (PDOException $e) {
283 283
                         echo $e->getMessage();
284 284
                         die;
285 285
                 }
@@ -301,13 +301,13 @@  discard block
 block discarded – undo
301 301
                 date_default_timezone_set('UTC');
302 302
 
303 303
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
304
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
304
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
305 305
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
306 306
 
307 307
                 try {
308 308
                         $sth = $this->db->prepare($query);
309 309
                         $sth->execute(array(':ident' => $ident));
310
-                } catch(PDOException $e) {
310
+                } catch (PDOException $e) {
311 311
                         echo $e->getMessage();
312 312
                         die;
313 313
                 }
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
         * @return Array the spotter information
325 325
         *
326 326
         */
327
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
327
+        public function getTrackerArchiveData($ident, $famtrackid, $date)
328 328
         {
329 329
     		$Tracker = new Tracker($this->db);
330 330
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
331
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
331
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
332 332
 
333
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
333
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%'));
334 334
 
335 335
                 return $spotter_array;
336 336
         }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
                 try {
344 344
                         $sth = $this->db->prepare($query);
345 345
                         $sth->execute();
346
-                } catch(PDOException $e) {
346
+                } catch (PDOException $e) {
347 347
                         echo $e->getMessage();
348 348
                         die;
349 349
                 }
@@ -355,24 +355,24 @@  discard block
 block discarded – undo
355 355
         * @return Array the spotter information
356 356
         *
357 357
         */
358
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
358
+        public function getMinLiveTrackerData($begindate, $enddate, $filter = array())
359 359
         {
360 360
                 global $globalDBdriver, $globalLiveInterval;
361 361
                 date_default_timezone_set('UTC');
362 362
 
363 363
                 $filter_query = '';
364 364
                 if (isset($filter['source']) && !empty($filter['source'])) {
365
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
365
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
366 366
                 }
367 367
                 // Use spotter_output also ?
368 368
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
369
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
369
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
370 370
                 }
371 371
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
372 372
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
373 373
                 }
374 374
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
375
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
375
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
376 376
                 }
377 377
 
378 378
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
 						GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid 
392 392
 				    AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
393 393
 */
394
-			$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
394
+			$query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
395 395
 				    FROM tracker_archive 
396 396
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
397 397
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
398 398
                         	    '.$filter_query.' ORDER BY famtrackid';
399 399
                 } else {
400 400
                         //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
401
-                        $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
401
+                        $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
402 402
                         	    FROM tracker_archive 
403 403
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
404 404
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
                 try {
409 409
                         $sth = $this->db->prepare($query);
410 410
                         $sth->execute();
411
-                } catch(PDOException $e) {
411
+                } catch (PDOException $e) {
412 412
                         echo $e->getMessage();
413 413
                         die;
414 414
                 }
@@ -423,24 +423,24 @@  discard block
 block discarded – undo
423 423
         * @return Array the spotter information
424 424
         *
425 425
         */
426
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
426
+        public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array())
427 427
         {
428 428
                 global $globalDBdriver, $globalLiveInterval;
429 429
                 date_default_timezone_set('UTC');
430 430
 
431 431
                 $filter_query = '';
432 432
                 if (isset($filter['source']) && !empty($filter['source'])) {
433
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
433
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
434 434
                 }
435 435
                 // Should use spotter_output also ?
436 436
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
437
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
437
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
438 438
                 }
439 439
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
440 440
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
441 441
                 }
442 442
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
443
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
443
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
444 444
                 }
445 445
 
446 446
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
                     		    FROM tracker_archive 
451 451
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
452 452
 			*/
453
-			$query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
453
+			$query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
454 454
 				    FROM tracker_archive_output 
455 455
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao 
456 456
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
466 466
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
467 467
                         */
468
-                        $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
468
+                        $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
469 469
                         	    FROM tracker_archive_output 
470 470
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
471 471
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 try {
478 478
                         $sth = $this->db->prepare($query);
479 479
                         $sth->execute();
480
-                } catch(PDOException $e) {
480
+                } catch (PDOException $e) {
481 481
                         echo $e->getMessage();
482 482
                         die;
483 483
                 }
@@ -492,23 +492,23 @@  discard block
 block discarded – undo
492 492
         * @return Array the spotter information
493 493
         *
494 494
         */
495
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
495
+        public function getLiveTrackerCount($begindate, $enddate, $filter = array())
496 496
         {
497 497
                 global $globalDBdriver, $globalLiveInterval;
498 498
                 date_default_timezone_set('UTC');
499 499
 
500 500
                 $filter_query = '';
501 501
                 if (isset($filter['source']) && !empty($filter['source'])) {
502
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
502
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
503 503
                 }
504 504
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
505
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
505
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
506 506
                 }
507 507
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
508 508
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
509 509
                 }
510 510
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
511
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
511
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
512 512
                 }
513 513
 
514 514
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                 try {
524 524
                         $sth = $this->db->prepare($query);
525 525
                         $sth->execute();
526
-                } catch(PDOException $e) {
526
+                } catch (PDOException $e) {
527 527
                         echo $e->getMessage();
528 528
                         die;
529 529
                 }
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
     * @return Array the spotter information
544 544
     *
545 545
     */
546
-    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
546
+    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
547 547
     {
548 548
 	global $globalTimezone, $globalDBdriver;
549 549
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	        
566 566
 		$q_array = explode(" ", $q);
567 567
 		
568
-		foreach ($q_array as $q_item){
568
+		foreach ($q_array as $q_item) {
569 569
 		    $additional_query .= " AND (";
570 570
 		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
571 571
 		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	
598 598
 	if ($registration != "")
599 599
 	{
600
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
600
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
601 601
 	    if (!is_string($registration))
602 602
 	    {
603 603
 		return false;
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	
609 609
 	if ($aircraft_icao != "")
610 610
 	{
611
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
611
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
612 612
 	    if (!is_string($aircraft_icao))
613 613
 	    {
614 614
 		return false;
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	
620 620
 	if ($aircraft_manufacturer != "")
621 621
 	{
622
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
622
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
623 623
 	    if (!is_string($aircraft_manufacturer))
624 624
 	    {
625 625
 		return false;
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	
641 641
 	if ($airline_icao != "")
642 642
 	{
643
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
643
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
644 644
 	    if (!is_string($airline_icao))
645 645
 	    {
646 646
 		return false;
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	
652 652
 	if ($airline_country != "")
653 653
 	{
654
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
654
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
655 655
 	    if (!is_string($airline_country))
656 656
 	    {
657 657
 		return false;
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	
663 663
 	if ($airline_type != "")
664 664
 	{
665
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
665
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
666 666
 	    if (!is_string($airline_type))
667 667
 	    {
668 668
 		return false;
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	
685 685
 	if ($airport != "")
686 686
 	{
687
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
687
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
688 688
 	    if (!is_string($airport))
689 689
 	    {
690 690
 		return false;
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 	
696 696
 	if ($airport_country != "")
697 697
 	{
698
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
698
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
699 699
 	    if (!is_string($airport_country))
700 700
 	    {
701 701
 		return false;
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
     
707 707
 	if ($callsign != "")
708 708
 	{
709
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
709
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
710 710
 	    if (!is_string($callsign))
711 711
 	    {
712 712
 		return false;
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 		$translate = $Translation->ident2icao($callsign);
715 715
 		if ($translate != $callsign) {
716 716
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
717
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
717
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
718 718
 		} else {
719 719
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
720 720
 		}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 
724 724
 	if ($owner != "")
725 725
 	{
726
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
726
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
727 727
 	    if (!is_string($owner))
728 728
 	    {
729 729
 		return false;
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 
735 735
 	if ($pilot_name != "")
736 736
 	{
737
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
737
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
738 738
 	    if (!is_string($pilot_name))
739 739
 	    {
740 740
 		return false;
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	
746 746
 	if ($pilot_id != "")
747 747
 	{
748
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
748
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
749 749
 	    if (!is_string($pilot_id))
750 750
 	    {
751 751
 		return false;
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 	
757 757
 	if ($departure_airport_route != "")
758 758
 	{
759
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
759
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
760 760
 	    if (!is_string($departure_airport_route))
761 761
 	    {
762 762
 		return false;
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 	
768 768
 	if ($arrival_airport_route != "")
769 769
 	{
770
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
770
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
771 771
 	    if (!is_string($arrival_airport_route))
772 772
 	    {
773 773
 		return false;
@@ -780,8 +780,8 @@  discard block
 block discarded – undo
780 780
 	{
781 781
 	    $altitude_array = explode(",", $altitude);
782 782
 	    
783
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
784
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
783
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
784
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
785 785
 	    
786 786
 
787 787
 	    if ($altitude_array[1] != "")
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	{
800 800
 	    $date_array = explode(",", $date_posted);
801 801
 	    
802
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
803
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
802
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
803
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
804 804
 	    
805 805
 	    if ($globalTimezone != '') {
806 806
 		date_default_timezone_set($globalTimezone);
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 	{
833 833
 	    $limit_array = explode(",", $limit);
834 834
 	    
835
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
836
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
835
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
836
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
837 837
 	    
838 838
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
839 839
 	    {
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 	
845 845
 
846 846
 	if ($origLat != "" && $origLon != "" && $dist != "") {
847
-		$dist = number_format($dist*0.621371,2,'.','');
848
-		$query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
847
+		$dist = number_format($dist*0.621371, 2, '.', '');
848
+		$query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
849 849
                           FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
850 850
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
851 851
 	} else {
@@ -862,12 +862,12 @@  discard block
 block discarded – undo
862 862
 			$additional_query .= " AND (tracker_archive_output.waypoints <> '')";
863 863
 		}
864 864
 
865
-		$query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
865
+		$query = "SELECT tracker_archive_output.* FROM tracker_archive_output 
866 866
 		    WHERE tracker_archive_output.ident <> '' 
867 867
 		    ".$additional_query."
868 868
 		    ".$filter_query.$orderby_query;
869 869
 	}
870
-	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
870
+	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
871 871
 
872 872
 	return $spotter_array;
873 873
     }
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
                 try {
885 885
                         $sth = $this->db->prepare($query);
886 886
                         $sth->execute();
887
-                } catch(PDOException $e) {
887
+                } catch (PDOException $e) {
888 888
                         return "error";
889 889
                 }
890 890
 	}
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 	{
922 922
 	    $limit_array = explode(",", $limit);
923 923
 	    
924
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
925
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
924
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
925
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
926 926
 	    
927 927
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
928 928
 	    {
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 	$query_values = array();
964 964
 	$limit_query = '';
965 965
 	$additional_query = '';
966
-	$filter_query = $this->getFilter($filter,true,true);
966
+	$filter_query = $this->getFilter($filter, true, true);
967 967
 	
968 968
 	if ($owner != "")
969 969
 	{
@@ -980,8 +980,8 @@  discard block
 block discarded – undo
980 980
 	{
981 981
 	    $limit_array = explode(",", $limit);
982 982
 	    
983
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
984
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
983
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
984
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
985 985
 	    
986 986
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
987 987
 	    {
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 	$query_values = array();
1022 1022
 	$limit_query = '';
1023 1023
 	$additional_query = '';
1024
-	$filter_query = $this->getFilter($filter,true,true);
1024
+	$filter_query = $this->getFilter($filter, true, true);
1025 1025
 	
1026 1026
 	if ($pilot != "")
1027 1027
 	{
@@ -1033,8 +1033,8 @@  discard block
 block discarded – undo
1033 1033
 	{
1034 1034
 	    $limit_array = explode(",", $limit);
1035 1035
 	    
1036
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1037
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1036
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1037
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1038 1038
 	    
1039 1039
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1040 1040
 	    {
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
     * @return Array the airline country list
1065 1065
     *
1066 1066
     */
1067
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1067
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1068 1068
     {
1069 1069
 	global $globalDBdriver;
1070 1070
 	/*
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 	$flight_array = array();
1094 1094
 	$temp_array = array();
1095 1095
         
1096
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1096
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1097 1097
 	{
1098 1098
 	    $temp_array['flight_count'] = $row['nb'];
1099 1099
 	    $temp_array['flight_country'] = $row['name'];
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
     * @return Array the airline country list
1111 1111
     *
1112 1112
     */
1113
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1113
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1114 1114
     {
1115 1115
 	global $globalDBdriver;
1116 1116
 	/*
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 	$flight_array = array();
1140 1140
 	$temp_array = array();
1141 1141
         
1142
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1142
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1143 1143
 	{
1144 1144
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1145 1145
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1157,14 +1157,14 @@  discard block
 block discarded – undo
1157 1157
     * @return Array the spotter information
1158 1158
     *
1159 1159
     */
1160
-    public function getDateArchiveTrackerDataById($id,$date)
1160
+    public function getDateArchiveTrackerDataById($id, $date)
1161 1161
     {
1162 1162
 	$Tracker = new Tracker($this->db);
1163 1163
 	date_default_timezone_set('UTC');
1164 1164
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1165
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1166
-	$date = date('c',$date);
1167
-	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1165
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1166
+	$date = date('c', $date);
1167
+	$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1168 1168
 	return $spotter_array;
1169 1169
     }
1170 1170
 
@@ -1174,14 +1174,14 @@  discard block
 block discarded – undo
1174 1174
     * @return Array the spotter information
1175 1175
     *
1176 1176
     */
1177
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1177
+    public function getDateArchiveTrackerDataByIdent($ident, $date)
1178 1178
     {
1179 1179
 	$Tracker = new Tracker($this->db);
1180 1180
 	date_default_timezone_set('UTC');
1181 1181
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1182
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1183
-	$date = date('c',$date);
1184
-	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1182
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1183
+	$date = date('c', $date);
1184
+	$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1185 1185
 	return $spotter_array;
1186 1186
     }
1187 1187
 
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
     * @return Array the spotter information
1192 1192
     *
1193 1193
     */
1194
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1194
+    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1195 1195
     {
1196 1196
 	global $global_query;
1197 1197
 	$Tracker = new Tracker();
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 	$query_values = array();
1200 1200
 	$limit_query = '';
1201 1201
 	$additional_query = '';
1202
-	$filter_query = $this->getFilter($filters,true,true);
1202
+	$filter_query = $this->getFilter($filters, true, true);
1203 1203
 	
1204 1204
 	if ($airport != "")
1205 1205
 	{
@@ -1216,8 +1216,8 @@  discard block
 block discarded – undo
1216 1216
 	{
1217 1217
 	    $limit_array = explode(",", $limit);
1218 1218
 	    
1219
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1220
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1219
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1220
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1221 1221
 	    
1222 1222
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1223 1223
 	    {
Please login to merge, or discard this patch.
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		if (isset($filter[0]['source'])) {
27 27
 			$filters = array_merge($filters,$filter);
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) {
30
+			$filter = array_merge($filter,$globalFilter);
31
+		}
30 32
 		$filter_query_join = '';
31 33
 		$filter_query_where = '';
32 34
 		foreach($filters as $flt) {
@@ -72,8 +74,11 @@  discard block
 block discarded – undo
72 74
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73 75
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74 76
 		}
75
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77
+		if ($filter_query_where == '' && $where) {
78
+			$filter_query_where = ' WHERE';
79
+		} elseif ($filter_query_where != '' && $and) {
80
+			$filter_query_where .= ' AND';
81
+		}
77 82
 		if ($filter_query_where != '') {
78 83
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79 84
 		}
@@ -87,9 +92,14 @@  discard block
 block discarded – undo
87 92
 		if ($over_country == '') {
88 93
 			$Tracker = new Tracker($this->db);
89 94
 			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
90
-			if (!empty($data_country)) $country = $data_country['iso2'];
91
-			else $country = '';
92
-		} else $country = $over_country;
95
+			if (!empty($data_country)) {
96
+				$country = $data_country['iso2'];
97
+			} else {
98
+				$country = '';
99
+			}
100
+		} else {
101
+			$country = $over_country;
102
+		}
93 103
 		// Route is not added in tracker_archive
94 104
 		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
95 105
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
@@ -588,7 +598,9 @@  discard block
 block discarded – undo
588 598
 		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
589 599
 		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
590 600
 		    $translate = $Translation->ident2icao($q_item);
591
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
601
+		    if ($translate != $q_item) {
602
+		    	$additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
603
+		    }
592 604
 		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
593 605
 		    $additional_query .= ")";
594 606
 		}
@@ -806,7 +818,9 @@  discard block
 block discarded – undo
806 818
 		date_default_timezone_set($globalTimezone);
807 819
 		$datetime = new DateTime();
808 820
 		$offset = $datetime->format('P');
809
-	    } else $offset = '+00:00';
821
+	    } else {
822
+	    	$offset = '+00:00';
823
+	    }
810 824
 
811 825
 
812 826
 	    if ($date_array[1] != "")
@@ -1082,9 +1096,13 @@  discard block
 block discarded – undo
1082 1096
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1083 1097
 			}
1084 1098
 		}
1085
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1099
+                if ($sincedate != '') {
1100
+                	$query .= "AND date > '".$sincedate."' ";
1101
+                }
1086 1102
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1087
-	if ($limit) $query .= " LIMIT 0,10";
1103
+	if ($limit) {
1104
+		$query .= " LIMIT 0,10";
1105
+	}
1088 1106
       
1089 1107
 	
1090 1108
 	$sth = $this->db->prepare($query);
@@ -1128,9 +1146,13 @@  discard block
 block discarded – undo
1128 1146
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1129 1147
 			}
1130 1148
 		}
1131
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1149
+                if ($sincedate != '') {
1150
+                	$query .= "AND s.date > '".$sincedate."' ";
1151
+                }
1132 1152
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1133
-	if ($limit) $query .= " LIMIT 0,10";
1153
+	if ($limit) {
1154
+		$query .= " LIMIT 0,10";
1155
+	}
1134 1156
       
1135 1157
 	
1136 1158
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
require/class.MarineArchive.php 2 patches
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -13,33 +13,33 @@  discard block
 block discarded – undo
13 13
 	* @param Array $filter the filter
14 14
 	* @return Array the SQL part
15 15
 	*/
16
-	public function getFilter($filter = array(),$where = false,$and = false) {
16
+	public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 		$filters = array();
19 19
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 				$filters = $globalStatsFilters[$globalFilterName];
22 22
 			} else {
23
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 			}
25 25
 		}
26 26
 		if (isset($filter[0]['source'])) {
27
-			$filters = array_merge($filters,$filter);
27
+			$filters = array_merge($filters, $filter);
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 		$filter_query_join = '';
31 31
 		$filter_query_where = '';
32
-		foreach($filters as $flt) {
32
+		foreach ($filters as $flt) {
33 33
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
34 34
 				if (isset($flt['source'])) {
35
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
35
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
36 36
 				} else {
37
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
37
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
38 38
 				}
39 39
 			}
40 40
 		}
41 41
 		if (isset($filter['source']) && !empty($filter['source'])) {
42
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
42
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
43 43
 		}
44 44
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
45 45
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -67,43 +67,43 @@  discard block
 block discarded – undo
67 67
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'";
68 68
 				}
69 69
 			}
70
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
70
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
71 71
 		}
72 72
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
73
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
74 74
 		}
75 75
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76 76
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77 77
 		if ($filter_query_where != '') {
78
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
79 79
 		}
80 80
 		$filter_query = $filter_query_join.$filter_query_where;
81 81
 		return $filter_query;
82 82
 	}
83 83
 
84 84
 	// marine_archive
85
-	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') {
85
+	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
86 86
 		
87 87
 		require_once(dirname(__FILE__).'/class.Marine.php');
88 88
 		if ($over_country == '') {
89 89
 			$Marine = new Marine($this->db);
90
-			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
90
+			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude);
91 91
 			if (!empty($data_country)) $country = $data_country['iso2'];
92 92
 			else $country = '';
93 93
 		} else $country = $over_country;
94 94
 		
95 95
 		//$country = $over_country;
96 96
 		// Route is not added in marine_archive
97
-		$query  = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
97
+		$query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
98 98
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
99 99
 
100
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
100
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
101 101
 
102 102
 		try {
103 103
 			$sth = $this->db->prepare($query);
104 104
 			$sth->execute($query_values);
105 105
 			$sth->closeCursor();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109 109
 		return "success";
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 
124 124
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
125 125
                 //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
-                $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
126
+                $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
127 127
 
128
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
128
+                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident));
129 129
 
130 130
                 return $spotter_array;
131 131
         }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
145 145
                 //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146 146
                 //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
-                $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
147
+                $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
148 148
 
149 149
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
150 150
                   /*
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                 }
158 158
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
159 159
                 */
160
-                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
160
+                $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id));
161 161
 
162 162
                 return $spotter_array;
163 163
         }
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	{
173 173
                 date_default_timezone_set('UTC');
174 174
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
175
-                $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
175
+                $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
176 176
 
177 177
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
178 178
 
179 179
                 try {
180 180
                         $sth = $this->db->prepare($query);
181 181
                         $sth->execute(array(':id' => $id));
182
-                } catch(PDOException $e) {
182
+                } catch (PDOException $e) {
183 183
                         echo $e->getMessage();
184 184
                         die;
185 185
                 }
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
         {
199 199
                 date_default_timezone_set('UTC');
200 200
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
201
-                $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
201
+                $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
202 202
 
203 203
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
204 204
 
205 205
                 try {
206 206
                         $sth = $this->db->prepare($query);
207 207
                         $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
208
+                } catch (PDOException $e) {
209 209
                         echo $e->getMessage();
210 210
                         die;
211 211
                 }
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
                 date_default_timezone_set('UTC');
228 228
 
229 229
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
230
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
231 231
 
232 232
                 try {
233 233
                         $sth = $this->db->prepare($query);
234 234
                         $sth->execute(array(':ident' => $ident));
235
-                } catch(PDOException $e) {
235
+                } catch (PDOException $e) {
236 236
                         echo $e->getMessage();
237 237
                         die;
238 238
                 }
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
                 date_default_timezone_set('UTC');
254 254
 
255 255
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
256
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
257 257
 
258 258
                 try {
259 259
                         $sth = $this->db->prepare($query);
260 260
                         $sth->execute(array(':id' => $id));
261
-                } catch(PDOException $e) {
261
+                } catch (PDOException $e) {
262 262
                         echo $e->getMessage();
263 263
                         die;
264 264
                 }
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
                 date_default_timezone_set('UTC');
280 280
 
281 281
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
282
-                $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
282
+                $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
283 283
 
284 284
                 try {
285 285
                         $sth = $this->db->prepare($query);
286 286
                         $sth->execute(array(':id' => $id));
287
-                } catch(PDOException $e) {
287
+                } catch (PDOException $e) {
288 288
                         echo $e->getMessage();
289 289
                         die;
290 290
                 }
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
                 date_default_timezone_set('UTC');
307 307
 
308 308
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
309
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
310 310
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
311 311
 
312 312
                 try {
313 313
                         $sth = $this->db->prepare($query);
314 314
                         $sth->execute(array(':ident' => $ident));
315
-                } catch(PDOException $e) {
315
+                } catch (PDOException $e) {
316 316
                         echo $e->getMessage();
317 317
                         die;
318 318
                 }
@@ -329,13 +329,13 @@  discard block
 block discarded – undo
329 329
         * @return Array the spotter information
330 330
         *
331 331
         */
332
-        public function getMarineArchiveData($ident,$fammarine_id,$date)
332
+        public function getMarineArchiveData($ident, $fammarine_id, $date)
333 333
         {
334 334
     		$Marine = new Marine($this->db);
335 335
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
336
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
336
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
337 337
 
338
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
338
+                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%'));
339 339
 
340 340
                 return $spotter_array;
341 341
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 try {
349 349
                         $sth = $this->db->prepare($query);
350 350
                         $sth->execute();
351
-                } catch(PDOException $e) {
351
+                } catch (PDOException $e) {
352 352
                         echo $e->getMessage();
353 353
                         die;
354 354
                 }
@@ -360,24 +360,24 @@  discard block
 block discarded – undo
360 360
         * @return Array the spotter information
361 361
         *
362 362
         */
363
-        public function getMinLiveMarineData($begindate,$enddate,$filter = array())
363
+        public function getMinLiveMarineData($begindate, $enddate, $filter = array())
364 364
         {
365 365
                 global $globalDBdriver, $globalLiveInterval;
366 366
                 date_default_timezone_set('UTC');
367 367
 
368 368
                 $filter_query = '';
369 369
                 if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
370
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
371 371
                 }
372 372
                 // Use spotter_output also ?
373 373
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
374
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
375 375
                 }
376 376
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377 377
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
378 378
                 }
379 379
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
380
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
381 381
                 }
382 382
 
383 383
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 						GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id 
397 397
 				    AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
398 398
 */
399
-			$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
399
+			$query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
400 400
 				    FROM marine_archive 
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
402 402
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY fammarine_id';
404 404
                 } else {
405 405
                         //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
406
+                        $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM marine_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
409 409
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 try {
414 414
                         $sth = $this->db->prepare($query);
415 415
                         $sth->execute();
416
-                } catch(PDOException $e) {
416
+                } catch (PDOException $e) {
417 417
                         echo $e->getMessage();
418 418
                         die;
419 419
                 }
@@ -428,24 +428,24 @@  discard block
 block discarded – undo
428 428
         * @return Array the spotter information
429 429
         *
430 430
         */
431
-        public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
431
+        public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array())
432 432
         {
433 433
                 global $globalDBdriver, $globalLiveInterval;
434 434
                 date_default_timezone_set('UTC');
435 435
 
436 436
                 $filter_query = '';
437 437
                 if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
438
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
439 439
                 }
440 440
                 // Should use spotter_output also ?
441 441
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
442
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
443 443
                 }
444 444
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445 445
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
446 446
                 }
447 447
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
448
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
449 449
                 }
450 450
 
451 451
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                     		    FROM marine_archive 
456 456
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
457 457
 			*/
458
-			$query  = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
458
+			$query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
459 459
 				    FROM marine_archive_output 
460 460
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao 
461 461
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
473
+                        $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM marine_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                 try {
483 483
                         $sth = $this->db->prepare($query);
484 484
                         $sth->execute();
485
-                } catch(PDOException $e) {
485
+                } catch (PDOException $e) {
486 486
                         echo $e->getMessage();
487 487
                         die;
488 488
                 }
@@ -497,23 +497,23 @@  discard block
 block discarded – undo
497 497
         * @return Array the spotter information
498 498
         *
499 499
         */
500
-        public function getLiveMarineCount($begindate,$enddate,$filter = array())
500
+        public function getLiveMarineCount($begindate, $enddate, $filter = array())
501 501
         {
502 502
                 global $globalDBdriver, $globalLiveInterval;
503 503
                 date_default_timezone_set('UTC');
504 504
 
505 505
                 $filter_query = '';
506 506
                 if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
507
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
508 508
                 }
509 509
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
510
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
511 511
                 }
512 512
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513 513
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
514 514
                 }
515 515
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
516
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
517 517
                 }
518 518
 
519 519
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
                 try {
529 529
                         $sth = $this->db->prepare($query);
530 530
                         $sth->execute();
531
-                } catch(PDOException $e) {
531
+                } catch (PDOException $e) {
532 532
                         echo $e->getMessage();
533 533
                         die;
534 534
                 }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     * @return Array the spotter information
549 549
     *
550 550
     */
551
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
551
+    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
552 552
     {
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573
-		foreach ($q_array as $q_item){
573
+		foreach ($q_array as $q_item) {
574 574
 		    $additional_query .= " AND (";
575 575
 		    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
576 576
 		    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
605
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
606 606
 	    if (!is_string($registration))
607 607
 	    {
608 608
 		return false;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
616
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
617 617
 	    if (!is_string($aircraft_icao))
618 618
 	    {
619 619
 		return false;
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
627
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
628 628
 	    if (!is_string($aircraft_manufacturer))
629 629
 	    {
630 630
 		return false;
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
648
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
649 649
 	    if (!is_string($airline_icao))
650 650
 	    {
651 651
 		return false;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
660 660
 	    if (!is_string($airline_country))
661 661
 	    {
662 662
 		return false;
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
670
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
671 671
 	    if (!is_string($airline_type))
672 672
 	    {
673 673
 		return false;
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
693 693
 	    if (!is_string($airport))
694 694
 	    {
695 695
 		return false;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
703
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
704 704
 	    if (!is_string($airport_country))
705 705
 	    {
706 706
 		return false;
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
714
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
715 715
 	    if (!is_string($callsign))
716 716
 	    {
717 717
 		return false;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
722
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
722
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
723 723
 		} else {
724 724
 			$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
725 725
 		}
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
731
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
732 732
 	    if (!is_string($owner))
733 733
 	    {
734 734
 		return false;
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
742
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
743 743
 	    if (!is_string($pilot_name))
744 744
 	    {
745 745
 		return false;
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
753
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
754 754
 	    if (!is_string($pilot_id))
755 755
 	    {
756 756
 		return false;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
764
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
765 765
 	    if (!is_string($departure_airport_route))
766 766
 	    {
767 767
 		return false;
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
775
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
776 776
 	    if (!is_string($arrival_airport_route))
777 777
 	    {
778 778
 		return false;
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 	{
786 786
 	    $altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
789
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792 792
 	    if ($altitude_array[1] != "")
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 	{
805 805
 	    $date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
808
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
809 809
 	    
810 810
 	    if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 	{
838 838
 	    $limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
841
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843 843
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844 844
 	    {
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	
850 850
 
851 851
 	if ($origLat != "" && $origLon != "" && $dist != "") {
852
-		$dist = number_format($dist*0.621371,2,'.','');
853
-		$query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
852
+		$dist = number_format($dist*0.621371, 2, '.', '');
853
+		$query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
854 854
                           FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
855 855
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
856 856
 	} else {
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
 			$additional_query .= " AND (marine_archive_output.waypoints <> '')";
868 868
 		}
869 869
 
870
-		$query  = "SELECT marine_archive_output.* FROM marine_archive_output 
870
+		$query = "SELECT marine_archive_output.* FROM marine_archive_output 
871 871
 		    WHERE marine_archive_output.ident <> '' 
872 872
 		    ".$additional_query."
873 873
 		    ".$filter_query.$orderby_query;
874 874
 	}
875
-	$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
875
+	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
876 876
 
877 877
 	return $spotter_array;
878 878
     }
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
                 try {
890 890
                         $sth = $this->db->prepare($query);
891 891
                         $sth->execute();
892
-                } catch(PDOException $e) {
892
+                } catch (PDOException $e) {
893 893
                         return "error";
894 894
                 }
895 895
 	}
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	{
927 927
 	    $limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
930
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932 932
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933 933
 	    {
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 	$query_values = array();
969 969
 	$limit_query = '';
970 970
 	$additional_query = '';
971
-	$filter_query = $this->getFilter($filter,true,true);
971
+	$filter_query = $this->getFilter($filter, true, true);
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
 	{
986 986
 	    $limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
989
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991 991
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992 992
 	    {
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 	$query_values = array();
1027 1027
 	$limit_query = '';
1028 1028
 	$additional_query = '';
1029
-	$filter_query = $this->getFilter($filter,true,true);
1029
+	$filter_query = $this->getFilter($filter, true, true);
1030 1030
 	
1031 1031
 	if ($pilot != "")
1032 1032
 	{
@@ -1038,8 +1038,8 @@  discard block
 block discarded – undo
1038 1038
 	{
1039 1039
 	    $limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1042
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044 1044
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045 1045
 	    {
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
     * @return Array the airline country list
1070 1070
     *
1071 1071
     */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1072
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1073 1073
     {
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 	$flight_array = array();
1099 1099
 	$temp_array = array();
1100 1100
         
1101
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1101
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103 1103
 	    $temp_array['flight_count'] = $row['nb'];
1104 1104
 	    $temp_array['flight_country'] = $row['name'];
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
     * @return Array the airline country list
1116 1116
     *
1117 1117
     */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1118
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1119 1119
     {
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 	$flight_array = array();
1145 1145
 	$temp_array = array();
1146 1146
         
1147
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1147
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149 1149
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1150 1150
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1162,14 +1162,14 @@  discard block
 block discarded – undo
1162 1162
     * @return Array the spotter information
1163 1163
     *
1164 1164
     */
1165
-    public function getDateArchiveMarineDataById($id,$date)
1165
+    public function getDateArchiveMarineDataById($id, $date)
1166 1166
     {
1167 1167
 	$Marine = new Marine($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1170 1170
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1171
-	$date = date('c',$date);
1172
-	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1171
+	$date = date('c', $date);
1172
+	$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1173 1173
 	return $spotter_array;
1174 1174
     }
1175 1175
 
@@ -1179,14 +1179,14 @@  discard block
 block discarded – undo
1179 1179
     * @return Array the spotter information
1180 1180
     *
1181 1181
     */
1182
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1182
+    public function getDateArchiveMarineDataByIdent($ident, $date)
1183 1183
     {
1184 1184
 	$Marine = new Marine($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1187 1187
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1188
-	$date = date('c',$date);
1189
-	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1188
+	$date = date('c', $date);
1189
+	$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1190 1190
 	return $spotter_array;
1191 1191
     }
1192 1192
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
     * @return Array the spotter information
1197 1197
     *
1198 1198
     */
1199
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1199
+    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1200 1200
     {
1201 1201
 	global $global_query;
1202 1202
 	$Marine = new Marine();
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 	$query_values = array();
1205 1205
 	$limit_query = '';
1206 1206
 	$additional_query = '';
1207
-	$filter_query = $this->getFilter($filters,true,true);
1207
+	$filter_query = $this->getFilter($filters, true, true);
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
@@ -1221,8 +1221,8 @@  discard block
 block discarded – undo
1221 1221
 	{
1222 1222
 	    $limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1225
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227 1227
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228 1228
 	    {
Please login to merge, or discard this patch.
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		if (isset($filter[0]['source'])) {
27 27
 			$filters = array_merge($filters,$filter);
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) {
30
+			$filter = array_merge($filter,$globalFilter);
31
+		}
30 32
 		$filter_query_join = '';
31 33
 		$filter_query_where = '';
32 34
 		foreach($filters as $flt) {
@@ -72,8 +74,11 @@  discard block
 block discarded – undo
72 74
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73 75
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74 76
 		}
75
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77
+		if ($filter_query_where == '' && $where) {
78
+			$filter_query_where = ' WHERE';
79
+		} elseif ($filter_query_where != '' && $and) {
80
+			$filter_query_where .= ' AND';
81
+		}
77 82
 		if ($filter_query_where != '') {
78 83
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79 84
 		}
@@ -88,9 +93,14 @@  discard block
 block discarded – undo
88 93
 		if ($over_country == '') {
89 94
 			$Marine = new Marine($this->db);
90 95
 			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
91
-			if (!empty($data_country)) $country = $data_country['iso2'];
92
-			else $country = '';
93
-		} else $country = $over_country;
96
+			if (!empty($data_country)) {
97
+				$country = $data_country['iso2'];
98
+			} else {
99
+				$country = '';
100
+			}
101
+		} else {
102
+			$country = $over_country;
103
+		}
94 104
 		
95 105
 		//$country = $over_country;
96 106
 		// Route is not added in marine_archive
@@ -593,7 +603,9 @@  discard block
 block discarded – undo
593 603
 		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
594 604
 		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
595 605
 		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
606
+		    if ($translate != $q_item) {
607
+		    	$additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
608
+		    }
597 609
 		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
598 610
 		    $additional_query .= ")";
599 611
 		}
@@ -811,7 +823,9 @@  discard block
 block discarded – undo
811 823
 		date_default_timezone_set($globalTimezone);
812 824
 		$datetime = new DateTime();
813 825
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
826
+	    } else {
827
+	    	$offset = '+00:00';
828
+	    }
815 829
 
816 830
 
817 831
 	    if ($date_array[1] != "")
@@ -1087,9 +1101,13 @@  discard block
 block discarded – undo
1087 1101
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1102
 			}
1089 1103
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1104
+                if ($sincedate != '') {
1105
+                	$query .= "AND date > '".$sincedate."' ";
1106
+                }
1091 1107
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092
-	if ($limit) $query .= " LIMIT 0,10";
1108
+	if ($limit) {
1109
+		$query .= " LIMIT 0,10";
1110
+	}
1093 1111
       
1094 1112
 	
1095 1113
 	$sth = $this->db->prepare($query);
@@ -1133,9 +1151,13 @@  discard block
 block discarded – undo
1133 1151
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1152
 			}
1135 1153
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1154
+                if ($sincedate != '') {
1155
+                	$query .= "AND s.date > '".$sincedate."' ";
1156
+                }
1137 1157
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138
-	if ($limit) $query .= " LIMIT 0,10";
1158
+	if ($limit) {
1159
+		$query .= " LIMIT 0,10";
1160
+	}
1139 1161
       
1140 1162
 	
1141 1163
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
statistics.php 3 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
         <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
82 82
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
83 83
 	<?php
84
-	    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
84
+		if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
85 85
 	?>
86 86
     	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
87 87
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
88 88
         <?php
89
-    	    } else {
90
-    	?>
89
+			} else {
90
+		?>
91 91
     	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
92 92
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
93 93
     	<?php
94
-    	    }
95
-    	?>
94
+			}
95
+		?>
96 96
         <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
97 97
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
98 98
         <?php
99
-    		if ($airline_icao == '') {
100
-    	?>
99
+			if ($airline_icao == '') {
100
+		?>
101 101
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
102 102
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
103 103
 	<?php
@@ -136,38 +136,38 @@  discard block
 block discarded – undo
136 136
             <div class="col-md-6">
137 137
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
138 138
                  <?php
139
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
140
-		    if (count($aircraft_array) == 0) print _("No data available");
141
-		    else {
142
-                    print '<div id="chart1" class="chart" width="100%"></div><script>';
143
-                    $aircraft_data = '';
144
-                    foreach($aircraft_array as $aircraft_item)
145
-                    {
146
-                        $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
147
-                    }
148
-                    $aircraft_data = substr($aircraft_data, 0, -1);
149
-		    print 'var series = ['.$aircraft_data.'];';
150
-		    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
151
-		    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
152
-		    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
153
-                    print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
154
-                    print 'dataset';
155
-                    print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
156
-                    print '</script>';
157
-                  }
158
-                  ?>
139
+				  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
140
+			if (count($aircraft_array) == 0) print _("No data available");
141
+			else {
142
+					print '<div id="chart1" class="chart" width="100%"></div><script>';
143
+					$aircraft_data = '';
144
+					foreach($aircraft_array as $aircraft_item)
145
+					{
146
+						$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
147
+					}
148
+					$aircraft_data = substr($aircraft_data, 0, -1);
149
+			print 'var series = ['.$aircraft_data.'];';
150
+			print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
151
+			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
152
+			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
153
+					print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
154
+					print 'dataset';
155
+					print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
156
+					print '</script>';
157
+				  }
158
+				  ?>
159 159
                 <div class="more">
160 160
             	    <?php
161
-            		if ($year != '' && $month != '') {
162
-            	    ?>
161
+					if ($year != '' && $month != '') {
162
+					?>
163 163
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
164 164
             	    <?php
165
-            		} else {
166
-            	    ?>
165
+					} else {
166
+					?>
167 167
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
168 168
             	    <?php
169
-            		}
170
-            	    ?>
169
+					}
170
+					?>
171 171
                 </div>
172 172
             </div>
173 173
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -220,29 +220,29 @@  discard block
 block discarded – undo
220 220
             <div class="col-md-6">
221 221
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
222 222
                  <?php
223
-                  $marine_array = $Marine->countAllMarineTypes();
224
-		    if (count($marine_array) == 0) print _("No data available");
225
-		    else {
226
-                    print '<div id="chart1" class="chart" width="100%"></div><script>';
227
-                    $marine_data = '';
228
-                    foreach($marine_array as $marine_item)
229
-                    {
230
-                        $marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
231
-                    }
232
-                    $marine_data = substr($marine_data, 0, -1);
233
-		    print 'var series = ['.$marine_data.'];';
234
-		    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
235
-		    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
236
-		    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
237
-                    print 'var marinetype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
238
-                    print 'dataset';
239
-                    print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
240
-                    print '</script>';
241
-                  }
242
-                  ?>
223
+				  $marine_array = $Marine->countAllMarineTypes();
224
+			if (count($marine_array) == 0) print _("No data available");
225
+			else {
226
+					print '<div id="chart1" class="chart" width="100%"></div><script>';
227
+					$marine_data = '';
228
+					foreach($marine_array as $marine_item)
229
+					{
230
+						$marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
231
+					}
232
+					$marine_data = substr($marine_data, 0, -1);
233
+			print 'var series = ['.$marine_data.'];';
234
+			print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
235
+			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
236
+			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
237
+					print 'var marinetype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
238
+					print 'dataset';
239
+					print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
240
+					print '</script>';
241
+				  }
242
+				  ?>
243 243
                 <div class="more">
244 244
             	    <?php
245
-            	    /*
245
+					/*
246 246
             		if ($year != '' && $month != '') {
247 247
             	    ?>
248 248
             	    <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
             	    <?php
254 254
             		}
255 255
             		*/
256
-            	    ?>
256
+					?>
257 257
                 </div>
258 258
             </div>
259 259
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 }
20 20
 
21 21
 if (!isset($filter_name)) $filter_name = '';
22
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
22
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
23 23
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
24 24
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25 25
 }
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 	$title = _("Statistics");
35 35
 }
36 36
 
37
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
38
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
37
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
38
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
39 39
 
40 40
 require_once('header.php');
41 41
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 			date_default_timezone_set('UTC');
63 63
 			$lastupdate = strtotime($last_update[0]['value']);
64 64
 			if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
65
-			print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
65
+			print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
66 66
 		}
67 67
 	}
68 68
 ?>
@@ -76,30 +76,30 @@  discard block
 block discarded – undo
76 76
 <?php
77 77
 	if ($type == 'aircraft') {
78 78
 ?>
79
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
80
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
81
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
82
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
79
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
80
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
81
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
82
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
83 83
 	<?php
84
-	    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
84
+	    if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
85 85
 	?>
86
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
87
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
86
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
87
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
88 88
         <?php
89 89
     	    } else {
90 90
     	?>
91
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
92
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
91
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
92
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
93 93
     	<?php
94 94
     	    }
95 95
     	?>
96
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
97
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
96
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
97
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
98 98
         <?php
99 99
     		if ($airline_icao == '') {
100 100
     	?>
101
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
102
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
101
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
102
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
103 103
 	<?php
104 104
 		}
105 105
 	?>
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
108 108
 			if ($airline_icao == '' || $airline_icao == 'all') {
109 109
 	?>
110
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
111
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
110
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
111
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
112 112
 	<?php
113 113
 			}
114 114
 		}
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 <?php
117 117
 	} elseif ($type == 'marine') {
118 118
 ?>
119
-	<span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
120
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
119
+	<span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name, $year, $month)); ?></span> <?php echo _("Vessels"); ?></span>
120
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
121 121
 <?php
122 122
 	} elseif ($type == 'tracker') {
123 123
 ?>
124
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
125
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
124
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name, $year, $month)); ?></span> <?php echo _("Trackers"); ?></span>
125
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
126 126
 <?php
127 127
 	}
128 128
 ?>
129 129
     </p>
130
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
130
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
131 131
     <div class="specific-stats">
132 132
 <?php
133 133
 	if ($type == 'aircraft') {
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
             <div class="col-md-6">
137 137
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
138 138
                  <?php
139
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
139
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
140 140
 		    if (count($aircraft_array) == 0) print _("No data available");
141 141
 		    else {
142 142
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
143 143
                     $aircraft_data = '';
144
-                    foreach($aircraft_array as $aircraft_item)
144
+                    foreach ($aircraft_array as $aircraft_item)
145 145
                     {
146 146
                         $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
147 147
                     }
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
             	    ?>
171 171
                 </div>
172 172
             </div>
173
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
173
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
174 174
 <?php
175 175
 //    echo $airline_icao;
176 176
 		if ($airline_icao == '' || $airline_icao == 'all') {
177
-			$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
177
+			$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
178 178
 			if (count($airline_array) > 0) {
179 179
 				print '<div class="col-md-6">';
180 180
 				print '<h2>'._("Top 10 Most Common Airline").'</h2>';
181 181
 				print '<div id="chart2" class="chart" width="100%"></div><script>';
182 182
 				$airline_data = '';
183
-				foreach($airline_array as $airline_item)
183
+				foreach ($airline_array as $airline_item)
184 184
 				{
185 185
 					$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
186 186
 				}
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			}
207 207
 ?>
208 208
         </div>
209
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
209
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
210 210
 <?php
211 211
 		}
212 212
 ?>
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		    else {
226 226
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
227 227
                     $marine_data = '';
228
-                    foreach($marine_array as $marine_item)
228
+                    foreach ($marine_array as $marine_item)
229 229
                     {
230 230
                         $marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
231 231
                     }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
             	    ?>
257 257
                 </div>
258 258
             </div>
259
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
259
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
260 260
 	</div>
261 261
 <?php
262 262
 	}
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 ?>
267 267
         <div class="row column">
268 268
 <?php
269
-		$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
270
-		if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
269
+		$flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
270
+		if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
271 271
 			if (empty($flightover_array)) {
272 272
 				print '<div class="col-md-12">';
273 273
 			} else {
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 ?>
277 277
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
278 278
 <?php
279
-			$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
279
+			$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
280 280
 			if (count($pilot_array) == 0) print _("No data available");
281 281
 			else {
282 282
 				print '<div id="chart7" class="chart" width="100%"></div><script>';
283 283
 				$pilot_data = '';
284
-				foreach($pilot_array as $pilot_item)
284
+				foreach ($pilot_array as $pilot_item)
285 285
 				{
286 286
 					$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
287 287
 				}
@@ -303,19 +303,19 @@  discard block
 block discarded – undo
303 303
 ?>
304 304
             </div>
305 305
         
306
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
306
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
307 307
 <?php
308 308
 		} else {
309 309
 ?>
310 310
             <div class="col-md-6">
311 311
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
312 312
 <?php
313
-			$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
313
+			$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
314 314
 			if (count($owner_array) == 0) print _("No data available");
315 315
 			else {
316 316
 				print '<div id="chart7" class="chart" width="100%"></div><script>';
317 317
 				$owner_data = '';
318
-				foreach($owner_array as $owner_item)
318
+				foreach ($owner_array as $owner_item)
319 319
 				{
320 320
 					$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
321 321
 				}
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
                 </div>
336 336
             </div>
337 337
         
338
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
338
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
339 339
 <?php
340 340
 		}
341 341
 		if (!empty($flightover_array)) {
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 				print '<div id="chart10" class="chart" width="100%"></div><script>';
350 350
 				print 'var series = [';
351 351
 				$flightover_data = '';
352
-				foreach($flightover_array as $flightover_item)
352
+				foreach ($flightover_array as $flightover_item)
353 353
 				{
354 354
 					$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
355 355
 				}
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 		}
396 396
 ?>
397 397
         </div>
398
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
398
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
399 399
 
400 400
     	
401 401
         </div>
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
416 416
 			print 'var series = [';
417 417
 			$flightover_data = '';
418
-			foreach($flightover_array as $flightover_item)
418
+			foreach ($flightover_array as $flightover_item)
419 419
 			{
420 420
 				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
421 421
 			}
@@ -470,14 +470,14 @@  discard block
 block discarded – undo
470 470
         <div class="row column">
471 471
             <div class="col-md-6">
472 472
 <?php
473
-		$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
473
+		$airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
474 474
 		if (count($airport_airport_array) > 0) {
475 475
 			print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
476 476
 			print '<div id="chart3" class="chart" width="100%"></div><script>';
477 477
 			print "\n";
478 478
 			print 'var series = [';
479 479
 			$airport_data = '';
480
-			foreach($airport_airport_array as $airport_item)
480
+			foreach ($airport_airport_array as $airport_item)
481 481
 			{
482 482
 				$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
483 483
 			}
@@ -528,18 +528,18 @@  discard block
 block discarded – undo
528 528
 		}
529 529
 ?>
530 530
             </div>
531
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
531
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
532 532
 
533 533
             <div class="col-md-6">
534 534
 <?php
535
-		$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
535
+		$airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
536 536
 		if (count($airport_airport_array2) > 0) {
537 537
 			print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
538 538
 			print '<div id="chart4" class="chart" width="100%"></div><script>';
539 539
 			print "\n";
540 540
 			print 'var series = [';
541 541
 			$airport_data = '';
542
-			foreach($airport_airport_array2 as $airport_item)
542
+			foreach ($airport_airport_array2 as $airport_item)
543 543
 			{
544 544
 				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
545 545
 			}
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 ?>
592 592
             </div>
593 593
         </div>
594
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
594
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
595 595
 <?php 
596 596
 	}
597 597
 ?>
@@ -605,19 +605,19 @@  discard block
 block discarded – undo
605 605
             <div class="col-md-6">
606 606
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
607 607
 <?php
608
-			$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
608
+			$year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
609 609
 			if (count($year_array) == 0) print _("No data available");
610 610
 			else {
611 611
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
612 612
 				$year_data = '';
613 613
 				$year_cnt = '';
614
-				foreach($year_array as $year_item)
614
+				foreach ($year_array as $year_item)
615 615
 				{
616 616
 					$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
617 617
 					$year_cnt .= $year_item['date_count'].',';
618 618
 				}
619 619
 				$year_data = "['x',".substr($year_data, 0, -1)."]";
620
-				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
620
+				$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
621 621
 				print 'c3.generate({
622 622
 				    bindto: "#chart8",
623 623
 				    data: { x: "x",
@@ -630,23 +630,23 @@  discard block
 block discarded – undo
630 630
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
631 631
                 </div>
632 632
             </div>
633
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
633
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
634 634
             <div class="col-md-6">
635 635
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
636 636
 <?php
637
-			$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
637
+			$month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
638 638
 			if (count($month_array) == 0) print _("No data available");
639 639
 			else {
640 640
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
641 641
 				$month_data = '';
642 642
 				$month_cnt = '';
643
-				foreach($month_array as $month_item)
643
+				foreach ($month_array as $month_item)
644 644
 				{
645 645
 					$month_data .= '"'.$month_item['date_name'].'",';
646 646
 					$month_cnt .= $month_item['date_count'].',';
647 647
 				}
648 648
 				$month_data = "['x',".substr($month_data, 0, -1)."]";
649
-				$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
649
+				$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
650 650
 				print 'c3.generate({
651 651
 				    bindto: "#chart9",
652 652
 				    data: { x: "x",
@@ -659,24 +659,24 @@  discard block
 block discarded – undo
659 659
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
660 660
                 </div>
661 661
             </div>
662
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
662
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
663 663
 
664 664
             <div class="col-md-6">
665 665
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
666 666
 <?php
667
-			$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
667
+			$date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
668 668
 			if (empty($date_array)) print _("No data available");
669 669
 			else {
670 670
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
671 671
 				$date_data = '';
672 672
 				$date_cnt = '';
673
-				foreach($date_array as $date_item)
673
+				foreach ($date_array as $date_item)
674 674
 				{
675 675
 					$date_data .= '"'.$date_item['date_name'].'",';
676 676
 					$date_cnt .= $date_item['date_count'].',';
677 677
 				}
678 678
 				$date_data = "['x',".substr($date_data, 0, -1)."]";
679
-				$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
679
+				$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
680 680
 				print 'c3.generate({
681 681
 				    bindto: "#chart5",
682 682
 				    data: { x: "x",
@@ -689,23 +689,23 @@  discard block
 block discarded – undo
689 689
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
690 690
                 </div>
691 691
             </div>
692
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
692
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
693 693
             <div class="col-md-6">
694 694
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
695 695
 <?php
696
-			$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
696
+			$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
697 697
 			if (empty($hour_array)) print _("No data available");
698 698
 			else {
699 699
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
700 700
 				$hour_data = '';
701 701
 				$hour_cnt = '';
702
-				foreach($hour_array as $hour_item)
702
+				foreach ($hour_array as $hour_item)
703 703
 				{
704 704
 					$hour_data .= '"'.$hour_item['hour_name'].':00",';
705 705
 					$hour_cnt .= $hour_item['hour_count'].',';
706 706
 				}
707 707
 				$hour_data = "[".substr($hour_data, 0, -1)."]";
708
-				$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
708
+				$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
709 709
 				print 'c3.generate({
710 710
 				    bindto: "#chart6",
711 711
 				    data: {
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
719 719
                 </div>
720 720
             </div>
721
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
721
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
722 722
         </div>
723 723
 <?php
724 724
 		}
@@ -736,19 +736,19 @@  discard block
 block discarded – undo
736 736
             <div class="col-md-6">
737 737
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
738 738
 <?php
739
-			$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
739
+			$year_array = $Marine->countAllMonthsLastYear(true, $airline_icao, $filter_name);
740 740
 			if (count($year_array) == 0) print _("No data available");
741 741
 			else {
742 742
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
743 743
 				$year_data = '';
744 744
 				$year_cnt = '';
745
-				foreach($year_array as $year_item)
745
+				foreach ($year_array as $year_item)
746 746
 				{
747 747
 					$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
748 748
 					$year_cnt .= $year_item['date_count'].',';
749 749
 				}
750 750
 				$year_data = "['x',".substr($year_data, 0, -1)."]";
751
-				$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
751
+				$year_cnt = "['vessels',".substr($year_cnt, 0, -1)."]";
752 752
 				print 'c3.generate({
753 753
 				    bindto: "#chart8",
754 754
 				    data: { x: "x",
@@ -764,23 +764,23 @@  discard block
 block discarded – undo
764 764
                 -->
765 765
             </div>
766 766
             
767
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
767
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
768 768
             <div class="col-md-6">
769 769
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
770 770
 <?php
771
-			$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
771
+			$month_array = $Marine->countAllDatesLastMonth($airline_icao, $filter_name);
772 772
 			if (count($month_array) == 0) print _("No data available");
773 773
 			else {
774 774
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
775 775
 				$month_data = '';
776 776
 				$month_cnt = '';
777
-				foreach($month_array as $month_item)
777
+				foreach ($month_array as $month_item)
778 778
 				{
779 779
 					$month_data .= '"'.$month_item['date_name'].'",';
780 780
 					$month_cnt .= $month_item['date_count'].',';
781 781
 				}
782 782
 				$month_data = "['x',".substr($month_data, 0, -1)."]";
783
-				$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
783
+				$month_cnt = "['vessels',".substr($month_cnt, 0, -1)."]";
784 784
 				print 'c3.generate({
785 785
 				    bindto: "#chart9",
786 786
 				    data: { x: "x",
@@ -796,24 +796,24 @@  discard block
 block discarded – undo
796 796
                 -->
797 797
                 
798 798
             </div>
799
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
799
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
800 800
 
801 801
             <div class="col-md-6">
802 802
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
803 803
 <?php
804
-			$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
804
+			$date_array = $Marine->countAllDatesLast7Days($airline_icao, $filter_name);
805 805
 			if (empty($date_array)) print _("No data available");
806 806
 			else {
807 807
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
808 808
 				$date_data = '';
809 809
 				$date_cnt = '';
810
-				foreach($date_array as $date_item)
810
+				foreach ($date_array as $date_item)
811 811
 				{
812 812
 					$date_data .= '"'.$date_item['date_name'].'",';
813 813
 					$date_cnt .= $date_item['date_count'].',';
814 814
 				}
815 815
 				$date_data = "['x',".substr($date_data, 0, -1)."]";
816
-				$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
816
+				$date_cnt = "['vessels',".substr($date_cnt, 0, -1)."]";
817 817
 				print 'c3.generate({
818 818
 				    bindto: "#chart5",
819 819
 				    data: { x: "x",
@@ -828,23 +828,23 @@  discard block
 block discarded – undo
828 828
                 </div>
829 829
                 -->
830 830
             </div>
831
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
831
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
832 832
             <div class="col-md-6">
833 833
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
834 834
 <?php
835
-			$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
835
+			$hour_array = $Marine->countAllHours('hour', true, $airline_icao, $filter_name);
836 836
 			if (empty($hour_array)) print _("No data available");
837 837
 			else {
838 838
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
839 839
 				$hour_data = '';
840 840
 				$hour_cnt = '';
841
-				foreach($hour_array as $hour_item)
841
+				foreach ($hour_array as $hour_item)
842 842
 				{
843 843
 					$hour_data .= '"'.$hour_item['hour_name'].':00",';
844 844
 					$hour_cnt .= $hour_item['hour_count'].',';
845 845
 				}
846 846
 				$hour_data = "[".substr($hour_data, 0, -1)."]";
847
-				$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
847
+				$hour_cnt = "['vessels',".substr($hour_cnt, 0, -1)."]";
848 848
 				print 'c3.generate({
849 849
 				    bindto: "#chart6",
850 850
 				    data: {
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
                 </div>
860 860
                 -->
861 861
             </div>
862
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
862
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
863 863
         </div>
864 864
 <?php
865 865
 		}
@@ -883,13 +883,13 @@  discard block
 block discarded – undo
883 883
 				print '<div id="chart32" class="chart" width="100%"></div><script>';
884 884
 				$year_data = '';
885 885
 				$year_cnt = '';
886
-				foreach($year_array as $year_item)
886
+				foreach ($year_array as $year_item)
887 887
 				{
888 888
 					$year_data .= '"'.$year_item['year'].'-01-01",';
889 889
 					$year_cnt .= $year_item['count'].',';
890 890
 				}
891 891
 				$year_data = "['x',".substr($year_data, 0, -1)."]";
892
-				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
892
+				$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
893 893
 				print 'c3.generate({
894 894
 				    bindto: "#chart32",
895 895
 				    data: { x: "x",
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
903 903
                 </div>
904 904
             </div>
905
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
905
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
906 906
 
907 907
         <div class="row column">
908 908
             <div class="col-md-6">
@@ -914,13 +914,13 @@  discard block
 block discarded – undo
914 914
 				print '<div id="chart33" class="chart" width="100%"></div><script>';
915 915
 				$year_data = '';
916 916
 				$year_cnt = '';
917
-				foreach($year_array as $year_item)
917
+				foreach ($year_array as $year_item)
918 918
 				{
919 919
 					$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
920 920
 					$year_cnt .= $year_item['count'].',';
921 921
 				}
922 922
 				$year_data = "['x',".substr($year_data, 0, -1)."]";
923
-				$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
923
+				$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
924 924
 				print 'c3.generate({
925 925
 				    bindto: "#chart33",
926 926
 				    data: { x: "x",
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
934 934
                 </div>
935 935
             </div>
936
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
936
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
937 937
 <br/>
938 938
 <?php
939 939
 		}
@@ -951,9 +951,9 @@  discard block
 block discarded – undo
951 951
 <?php
952 952
 			//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
953 953
 			if ($year == '' && $month == '') {
954
-				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
954
+				$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
955 955
 			} else {
956
-				$polar = $Stats->getStatsSource('polar',$year,$month);
956
+				$polar = $Stats->getStatsSource('polar', $year, $month);
957 957
 			}
958 958
 			if (!empty($polar)) {
959 959
 				print '<h2>'._("Coverage pattern").'</h2>';
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 					unset($polar_data);
962 962
 					$Spotter = new Spotter();
963 963
 					$data = json_decode($eachpolar['source_data']);
964
-					foreach($data as $value => $key) {
964
+					foreach ($data as $value => $key) {
965 965
 						$direction = $Spotter->parseDirection(($value*22.5));
966 966
 						$distance = $key;
967 967
 						$unit = 'km';
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 ?>
982 982
             <div class="col-md-6">
983 983
                 <h4><?php print $eachpolar['source_name']; ?></h4>
984
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
984
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
985 985
         	<script>
986 986
         	    (function() {
987 987
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 		      color: color,
1006 1006
 		      unit: '<?php echo $unit; ?>'
1007 1007
 		    };
1008
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1008
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1009 1009
 		    })();
1010 1010
 		</script>
1011 1011
             </div>
@@ -1019,22 +1019,22 @@  discard block
 block discarded – undo
1019 1019
 <?php
1020 1020
 			//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1021 1021
 			if ($year == '' && $month == '') {
1022
-				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1022
+				$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
1023 1023
 			} else {
1024
-				$msg = $Stats->getStatsSource('msg',$year,$month);
1024
+				$msg = $Stats->getStatsSource('msg', $year, $month);
1025 1025
 			}
1026 1026
 			if (!empty($msg)) {
1027 1027
 				print '<h2>'._("Messages received").'</h2>';
1028 1028
 				foreach ($msg as $eachmsg) {
1029 1029
 					//$eachmsg = $msg[0];
1030 1030
 					$data = $eachmsg['source_data'];
1031
-					if ($data > 500) $max = (round(($data+100)/100))*100;
1031
+					if ($data > 500) $max = (round(($data + 100)/100))*100;
1032 1032
 					else $max = 500;
1033 1033
 ?>
1034
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1034
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1035 1035
         	<script>
1036 1036
 		      var g = new JustGage({
1037
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1037
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
1038 1038
 			    value: <?php echo $data; ?>,
1039 1039
 			    min: 0,
1040 1040
 			    max: <?php print $max; ?>,
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
 <?php
1056 1056
 		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1057 1057
 			if ($year == '' && $month == '') {
1058
-				$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1058
+				$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
1059 1059
 			} else {
1060
-				$hist = $Stats->getStatsSource('hist',$year,$month);
1060
+				$hist = $Stats->getStatsSource('hist', $year, $month);
1061 1061
 			}
1062 1062
 			foreach ($hist as $hists) {
1063 1063
 				//$hist_data = '';
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
 				$source = $hists['source_name'];
1067 1067
 				$hist_array = json_decode($hists['source_data']);
1068 1068
 				$unit = 'km';
1069
-				foreach($hist_array as $distance => $nb)
1069
+				foreach ($hist_array as $distance => $nb)
1070 1070
 				{
1071 1071
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1072 1072
 						$distance = round($distance*0.539957);
@@ -1087,18 +1087,18 @@  discard block
 block discarded – undo
1087 1087
 				$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1088 1088
 ?>
1089 1089
             <div class="col-md-6">
1090
-                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
1090
+                <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2>
1091 1091
 <?php
1092
-				print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1092
+				print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
1093 1093
 				print 'c3.generate({
1094
-				    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1094
+				    bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
1095 1095
 				    data: { x: "x",
1096 1096
 				    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1097 1097
 				    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1098 1098
 				print '</script>';
1099 1099
 ?>
1100 1100
     	    </div>
1101
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1101
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1102 1102
 <?php
1103 1103
 			}
1104 1104
 ?>
Please login to merge, or discard this patch.
Braces   +142 added lines, -60 removed lines patch added patch discarded remove patch
@@ -18,11 +18,15 @@  discard block
 block discarded – undo
18 18
 	require_once('require/class.Spotter.php');
19 19
 }
20 20
 
21
-if (!isset($filter_name)) $filter_name = '';
21
+if (!isset($filter_name)) {
22
+	$filter_name = '';
23
+}
22 24
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23 25
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
24
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25
-}
26
+	if (isset($globalFilter['airline'])) {
27
+		$airline_icao = $globalFilter['airline'][0];
28
+	}
29
+	}
26 30
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
27 31
 	$Spotter = new Spotter();
28 32
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -53,7 +57,12 @@  discard block
 block discarded – undo
53 57
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
54 58
 <div class="column">
55 59
     <div class="info">
56
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
60
+            <h1><?php if (isset($airline_name)) {
61
+	echo _("Statistics for ").$airline_name;
62
+} else {
63
+	echo _("Statistics");
64
+}
65
+?></h1>
57 66
 <?php 
58 67
 	if ($type == 'aircraft') {
59 68
 		$last_update = $Stats->getLastStatsUpdate();
@@ -61,7 +70,9 @@  discard block
 block discarded – undo
61 70
 		if (isset($last_update[0]['value'])) {
62 71
 			date_default_timezone_set('UTC');
63 72
 			$lastupdate = strtotime($last_update[0]['value']);
64
-			if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
73
+			if (isset($globalTimezone) && $globalTimezone != '') {
74
+				date_default_timezone_set($globalTimezone);
75
+			}
65 76
 			print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
66 77
 		}
67 78
 	}
@@ -137,8 +148,9 @@  discard block
 block discarded – undo
137 148
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
138 149
                  <?php
139 150
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
140
-		    if (count($aircraft_array) == 0) print _("No data available");
141
-		    else {
151
+		    if (count($aircraft_array) == 0) {
152
+		    	print _("No data available");
153
+		    } else {
142 154
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
143 155
                     $aircraft_data = '';
144 156
                     foreach($aircraft_array as $aircraft_item)
@@ -160,11 +172,17 @@  discard block
 block discarded – undo
160 172
             	    <?php
161 173
             		if ($year != '' && $month != '') {
162 174
             	    ?>
163
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
175
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
176
+	echo '/'.$airline_icao;
177
+}
178
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
164 179
             	    <?php
165 180
             		} else {
166 181
             	    ?>
167
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
182
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
183
+	echo '/'.$airline_icao;
184
+}
185
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
168 186
             	    <?php
169 187
             		}
170 188
             	    ?>
@@ -195,11 +213,15 @@  discard block
 block discarded – undo
195 213
 				print '</script>';
196 214
 				if ($year != '' && $month != '') {
197 215
 					print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
198
-					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
216
+					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
217
+						echo '/'.$airline_icao;
218
+					}
199 219
 					print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
200 220
 				} else {
201 221
 					print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
202
-					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
222
+					if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
223
+						echo '/'.$airline_icao;
224
+					}
203 225
 					print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
204 226
 				}
205 227
 				print '</div>';
@@ -221,8 +243,9 @@  discard block
 block discarded – undo
221 243
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
222 244
                  <?php
223 245
                   $marine_array = $Marine->countAllMarineTypes();
224
-		    if (count($marine_array) == 0) print _("No data available");
225
-		    else {
246
+		    if (count($marine_array) == 0) {
247
+		    	print _("No data available");
248
+		    } else {
226 249
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
227 250
                     $marine_data = '';
228 251
                     foreach($marine_array as $marine_item)
@@ -277,8 +300,9 @@  discard block
 block discarded – undo
277 300
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
278 301
 <?php
279 302
 			$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
280
-			if (count($pilot_array) == 0) print _("No data available");
281
-			else {
303
+			if (count($pilot_array) == 0) {
304
+				print _("No data available");
305
+			} else {
282 306
 				print '<div id="chart7" class="chart" width="100%"></div><script>';
283 307
 				$pilot_data = '';
284 308
 				foreach($pilot_array as $pilot_item)
@@ -297,7 +321,9 @@  discard block
 block discarded – undo
297 321
 			}
298 322
 			print '<div class="more">';
299 323
 			print '<a href="'.$globalURL.'/statistics/pilot'; 
300
-			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
324
+			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
325
+				echo '/'.$airline_icao;
326
+			}
301 327
 			print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
302 328
 			print '</div>';
303 329
 ?>
@@ -311,8 +337,9 @@  discard block
 block discarded – undo
311 337
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
312 338
 <?php
313 339
 			$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
314
-			if (count($owner_array) == 0) print _("No data available");
315
-			else {
340
+			if (count($owner_array) == 0) {
341
+				print _("No data available");
342
+			} else {
316 343
 				print '<div id="chart7" class="chart" width="100%"></div><script>';
317 344
 				$owner_data = '';
318 345
 				foreach($owner_array as $owner_item)
@@ -331,7 +358,10 @@  discard block
 block discarded – undo
331 358
 			}
332 359
 ?>
333 360
                 <div class="more">
334
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
361
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
362
+	echo '/'.$airline_icao;
363
+}
364
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
335 365
                 </div>
336 366
             </div>
337 367
         
@@ -344,8 +374,9 @@  discard block
 block discarded – undo
344 374
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
345 375
 <?php
346 376
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
347
-			if (count($flightover_array) == 0) print _("No data available");
348
-			else {
377
+			if (count($flightover_array) == 0) {
378
+				print _("No data available");
379
+			} else {
349 380
 				print '<div id="chart10" class="chart" width="100%"></div><script>';
350 381
 				print 'var series = [';
351 382
 				$flightover_data = '';
@@ -388,7 +419,10 @@  discard block
 block discarded – undo
388 419
 			}
389 420
 ?>
390 421
                 <div class="more">
391
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
422
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
423
+	echo '/'.$airline_icao;
424
+}
425
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
392 426
                 </div>
393 427
             </div>
394 428
 <?php
@@ -410,8 +444,9 @@  discard block
 block discarded – undo
410 444
 	<div class="col-md-6">
411 445
             <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
412 446
 <?php
413
-		if (count($flightover_array) == 0) print _("No data available");
414
-		else {
447
+		if (count($flightover_array) == 0) {
448
+			print _("No data available");
449
+		} else {
415 450
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
416 451
 			print 'var series = [';
417 452
 			$flightover_data = '';
@@ -455,7 +490,10 @@  discard block
 block discarded – undo
455 490
 ?>
456 491
                 <!--
457 492
                 <div class="more">
458
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
493
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
494
+	echo '/'.$airline_icao;
495
+}
496
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
459 497
                 </div>
460 498
                 -->
461 499
             </div>
@@ -523,7 +561,9 @@  discard block
 block discarded – undo
523 561
 			});";
524 562
 			print '</script>';
525 563
 			print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
526
-			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
564
+			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
565
+				echo '/'.$airline_icao;
566
+			}
527 567
 			print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
528 568
 		}
529 569
 ?>
@@ -585,7 +625,9 @@  discard block
 block discarded – undo
585 625
 			});";
586 626
 			print '</script>';
587 627
 			print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
588
-			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
628
+			if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
629
+				echo '/'.$airline_icao;
630
+			}
589 631
 			print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
590 632
 		}
591 633
 ?>
@@ -606,8 +648,9 @@  discard block
 block discarded – undo
606 648
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
607 649
 <?php
608 650
 			$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
609
-			if (count($year_array) == 0) print _("No data available");
610
-			else {
651
+			if (count($year_array) == 0) {
652
+				print _("No data available");
653
+			} else {
611 654
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
612 655
 				$year_data = '';
613 656
 				$year_cnt = '';
@@ -627,7 +670,10 @@  discard block
 block discarded – undo
627 670
 			}
628 671
 ?>
629 672
                 <div class="more">
630
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
673
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
674
+	echo '/'.$airline_icao;
675
+}
676
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
631 677
                 </div>
632 678
             </div>
633 679
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -635,8 +681,9 @@  discard block
 block discarded – undo
635 681
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
636 682
 <?php
637 683
 			$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
638
-			if (count($month_array) == 0) print _("No data available");
639
-			else {
684
+			if (count($month_array) == 0) {
685
+				print _("No data available");
686
+			} else {
640 687
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
641 688
 				$month_data = '';
642 689
 				$month_cnt = '';
@@ -656,7 +703,10 @@  discard block
 block discarded – undo
656 703
 			}
657 704
 ?>
658 705
                 <div class="more">
659
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
706
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
707
+	echo '/'.$airline_icao;
708
+}
709
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
660 710
                 </div>
661 711
             </div>
662 712
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -665,8 +715,9 @@  discard block
 block discarded – undo
665 715
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
666 716
 <?php
667 717
 			$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
668
-			if (empty($date_array)) print _("No data available");
669
-			else {
718
+			if (empty($date_array)) {
719
+				print _("No data available");
720
+			} else {
670 721
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
671 722
 				$date_data = '';
672 723
 				$date_cnt = '';
@@ -686,7 +737,10 @@  discard block
 block discarded – undo
686 737
 			}
687 738
 ?>
688 739
                 <div class="more">
689
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
740
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
741
+	echo '/'.$airline_icao;
742
+}
743
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
690 744
                 </div>
691 745
             </div>
692 746
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -694,8 +748,9 @@  discard block
 block discarded – undo
694 748
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
695 749
 <?php
696 750
 			$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
697
-			if (empty($hour_array)) print _("No data available");
698
-			else {
751
+			if (empty($hour_array)) {
752
+				print _("No data available");
753
+			} else {
699 754
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
700 755
 				$hour_data = '';
701 756
 				$hour_cnt = '';
@@ -715,7 +770,10 @@  discard block
 block discarded – undo
715 770
 			}
716 771
 ?>
717 772
                 <div class="more">
718
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
773
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
774
+	echo '/'.$airline_icao;
775
+}
776
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
719 777
                 </div>
720 778
             </div>
721 779
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -737,8 +795,9 @@  discard block
 block discarded – undo
737 795
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
738 796
 <?php
739 797
 			$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
740
-			if (count($year_array) == 0) print _("No data available");
741
-			else {
798
+			if (count($year_array) == 0) {
799
+				print _("No data available");
800
+			} else {
742 801
 				print '<div id="chart8" class="chart" width="100%"></div><script>';
743 802
 				$year_data = '';
744 803
 				$year_cnt = '';
@@ -759,7 +818,10 @@  discard block
 block discarded – undo
759 818
 ?>
760 819
 	    <!--
761 820
                 <div class="more">
762
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
821
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
822
+	echo '/'.$airline_icao;
823
+}
824
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
763 825
                 </div>
764 826
                 -->
765 827
             </div>
@@ -769,8 +831,9 @@  discard block
 block discarded – undo
769 831
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
770 832
 <?php
771 833
 			$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
772
-			if (count($month_array) == 0) print _("No data available");
773
-			else {
834
+			if (count($month_array) == 0) {
835
+				print _("No data available");
836
+			} else {
774 837
 				print '<div id="chart9" class="chart" width="100%"></div><script>';
775 838
 				$month_data = '';
776 839
 				$month_cnt = '';
@@ -791,7 +854,10 @@  discard block
 block discarded – undo
791 854
 ?>
792 855
                <!--
793 856
                 <div class="more">
794
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
857
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
858
+	echo '/'.$airline_icao;
859
+}
860
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
795 861
                 </div>
796 862
                 -->
797 863
                 
@@ -802,8 +868,9 @@  discard block
 block discarded – undo
802 868
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
803 869
 <?php
804 870
 			$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
805
-			if (empty($date_array)) print _("No data available");
806
-			else {
871
+			if (empty($date_array)) {
872
+				print _("No data available");
873
+			} else {
807 874
 				print '<div id="chart5" class="chart" width="100%"></div><script>';
808 875
 				$date_data = '';
809 876
 				$date_cnt = '';
@@ -824,7 +891,10 @@  discard block
 block discarded – undo
824 891
 ?>
825 892
                 <!--
826 893
                 <div class="more">
827
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
894
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
895
+	echo '/'.$airline_icao;
896
+}
897
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
828 898
                 </div>
829 899
                 -->
830 900
             </div>
@@ -833,8 +903,9 @@  discard block
 block discarded – undo
833 903
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
834 904
 <?php
835 905
 			$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
836
-			if (empty($hour_array)) print _("No data available");
837
-			else {
906
+			if (empty($hour_array)) {
907
+				print _("No data available");
908
+			} else {
838 909
 				print '<div id="chart6" class="chart" width="100%"></div><script>';
839 910
 				$hour_data = '';
840 911
 				$hour_cnt = '';
@@ -855,7 +926,10 @@  discard block
 block discarded – undo
855 926
 ?>
856 927
                 <!--
857 928
                 <div class="more">
858
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
929
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
930
+	echo '/'.$airline_icao;
931
+}
932
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
859 933
                 </div>
860 934
                 -->
861 935
             </div>
@@ -878,8 +952,9 @@  discard block
 block discarded – undo
878 952
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
879 953
 <?php
880 954
 			$year_array = $Stats->countFatalitiesByYear();
881
-			if (count($year_array) == 0) print _("No data available");
882
-			else {
955
+			if (count($year_array) == 0) {
956
+				print _("No data available");
957
+			} else {
883 958
 				print '<div id="chart32" class="chart" width="100%"></div><script>';
884 959
 				$year_data = '';
885 960
 				$year_cnt = '';
@@ -909,8 +984,9 @@  discard block
 block discarded – undo
909 984
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
910 985
 <?php
911 986
 			$year_array = $Stats->countFatalitiesLast12Months();
912
-			if (count($year_array) == 0) print _("No data available");
913
-			else {
987
+			if (count($year_array) == 0) {
988
+				print _("No data available");
989
+			} else {
914 990
 				print '<div id="chart33" class="chart" width="100%"></div><script>';
915 991
 				$year_data = '';
916 992
 				$year_cnt = '';
@@ -975,8 +1051,11 @@  discard block
 block discarded – undo
975 1051
 							$distance = $distance;
976 1052
 							$unit = 'km';
977 1053
 						}
978
-						if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
979
-						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1054
+						if (!isset($polar_data)) {
1055
+							$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1056
+						} else {
1057
+							$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1058
+						}
980 1059
 					}
981 1060
 ?>
982 1061
             <div class="col-md-6">
@@ -1028,9 +1107,12 @@  discard block
 block discarded – undo
1028 1107
 				foreach ($msg as $eachmsg) {
1029 1108
 					//$eachmsg = $msg[0];
1030 1109
 					$data = $eachmsg['source_data'];
1031
-					if ($data > 500) $max = (round(($data+100)/100))*100;
1032
-					else $max = 500;
1033
-?>
1110
+					if ($data > 500) {
1111
+						$max = (round(($data+100)/100))*100;
1112
+					} else {
1113
+						$max = 500;
1114
+					}
1115
+					?>
1034 1116
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1035 1117
         	<script>
1036 1118
 		      var g = new JustGage({
Please login to merge, or discard this patch.